aboutsummaryrefslogtreecommitdiff
path: root/src/internal/poll/fd_unix.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/internal/poll/fd_unix.go')
-rw-r--r--src/internal/poll/fd_unix.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/internal/poll/fd_unix.go b/src/internal/poll/fd_unix.go
index f6f6c52f31..2e77e76c87 100644
--- a/src/internal/poll/fd_unix.go
+++ b/src/internal/poll/fd_unix.go
@@ -74,7 +74,14 @@ func (fd *FD) destroy() error {
// Poller may want to unregister fd in readiness notification mechanism,
// so this must be executed before CloseFunc.
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)
+
fd.Sysfd = -1
runtime_Semrelease(&fd.csema)
return err