mirror of
https://github.com/golang/go
synced 2024-11-17 14:04:48 -07:00
internal/poll: use ignoringEINTR in Darwin Fsync
Also add comment explaining why we don't use ignoringEINTR around call to close. Fixes #41115 Change-Id: Ia7bbe01eaf26003f70d184b7e82803efef2b2c18 Reviewed-on: https://go-review.googlesource.com/c/go/+/258542 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
This commit is contained in:
parent
846dce9d05
commit
b8ec1d5f49
@ -14,7 +14,8 @@ func (fd *FD) Fsync() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer fd.decref()
|
defer fd.decref()
|
||||||
|
return ignoringEINTR(func() error {
|
||||||
_, e1 := fcntl(fd.Sysfd, syscall.F_FULLFSYNC, 0)
|
_, err := fcntl(fd.Sysfd, syscall.F_FULLFSYNC, 0)
|
||||||
return e1
|
return err
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,14 @@ func (fd *FD) destroy() error {
|
|||||||
// Poller may want to unregister fd in readiness notification mechanism,
|
// Poller may want to unregister fd in readiness notification mechanism,
|
||||||
// so this must be executed before CloseFunc.
|
// so this must be executed before CloseFunc.
|
||||||
fd.pd.close()
|
fd.pd.close()
|
||||||
|
|
||||||
|
// We don't use ignoringEINTR here because POSIX does not define
|
||||||
|
// whether the descriptor is closed if close returns EINTR.
|
||||||
|
// If the descriptor is indeed closed, using a loop would race
|
||||||
|
// with some other goroutine opening a new descriptor.
|
||||||
|
// (The Linux kernel guarantees that it is closed on an EINTR error.)
|
||||||
err := CloseFunc(fd.Sysfd)
|
err := CloseFunc(fd.Sysfd)
|
||||||
|
|
||||||
fd.Sysfd = -1
|
fd.Sysfd = -1
|
||||||
runtime_Semrelease(&fd.csema)
|
runtime_Semrelease(&fd.csema)
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user