]> Cypherpunks repositories - gostls13.git/commit
runtime: for kqueue treat EVFILT_READ with EV_EOF as permitting a write
authorIan Lance Taylor <iant@golang.org>
Thu, 19 Oct 2017 23:01:43 +0000 (16:01 -0700)
committerIan Lance Taylor <iant@golang.org>
Fri, 20 Oct 2017 22:26:30 +0000 (22:26 +0000)
commit23aad448b1e3f7c3b4ba2af90120bde91ac865b4
treed0b60cd4e817998a50a07b9ce62b92954b110e69
parent4e64ee423c3a755ed31c3c98bfba98adc5995b4a
runtime: for kqueue treat EVFILT_READ with EV_EOF as permitting a write

On systems that use kqueue, we always register descriptors for both
EVFILT_READ and EVFILT_WRITE. On at least FreeBSD and OpenBSD, when
the write end of a pipe is registered for EVFILT_READ and EVFILT_WRITE
events, and the read end of the pipe is closed, kqueue reports an
EVFILT_READ event with EV_EOF set, but does not report an EVFILT_WRITE
event. Since the write to the pipe is waiting for an EVFILT_WRITE
event, closing the read end of a pipe can cause the write end to hang
rather than attempt another write which will fail with EPIPE.

Fix this by treating EVFILT_READ with EV_EOF set as making both reads
and writes ready to proceed.

The real test for this is in CL 71770, which tests using various
timeouts with pipes.

Updates #22114

Change-Id: Ib23fbaaddbccd8eee77bdf18f27a7f0aa50e2742
Reviewed-on: https://go-review.googlesource.com/71973
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
22 files changed:
src/internal/poll/fd_unix.go
src/net/write_unix_test.go [new file with mode: 0644]
src/runtime/defs1_netbsd_386.go
src/runtime/defs1_netbsd_amd64.go
src/runtime/defs1_netbsd_arm.go
src/runtime/defs_darwin.go
src/runtime/defs_darwin_386.go
src/runtime/defs_darwin_amd64.go
src/runtime/defs_darwin_arm.go
src/runtime/defs_darwin_arm64.go
src/runtime/defs_dragonfly.go
src/runtime/defs_dragonfly_amd64.go
src/runtime/defs_freebsd.go
src/runtime/defs_freebsd_386.go
src/runtime/defs_freebsd_amd64.go
src/runtime/defs_freebsd_arm.go
src/runtime/defs_netbsd.go
src/runtime/defs_openbsd.go
src/runtime/defs_openbsd_386.go
src/runtime/defs_openbsd_amd64.go
src/runtime/defs_openbsd_arm.go
src/runtime/netpoll_kqueue.go