mirror of
https://github.com/golang/go.git
synced 2024-09-22 02:48:50 +00:00
os: disable the use of netpoll on directories as well on *BSDs
Follow up CL 156379. Updates #19093 Change-Id: I5ea3177fc5911d3af71cbb32584249e419e9d4a3 Reviewed-on: https://go-review.googlesource.com/c/go/+/172937 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
14b5b4a2a1
commit
059f2d4a46
@ -122,25 +122,27 @@ func newFile(fd uintptr, name string, kind newFileKind) *File {
|
||||
// we assume they know what they are doing so we allow it to be
|
||||
// used with kqueue.
|
||||
if kind == kindOpenFile {
|
||||
var st syscall.Stat_t
|
||||
switch runtime.GOOS {
|
||||
case "dragonfly", "freebsd", "netbsd", "openbsd":
|
||||
case "darwin", "dragonfly", "freebsd", "netbsd", "openbsd":
|
||||
var st syscall.Stat_t
|
||||
err := syscall.Fstat(fdi, &st)
|
||||
typ := st.Mode & syscall.S_IFMT
|
||||
// Don't try to use kqueue with regular files on *BSDs.
|
||||
// On FreeBSD a regular file is always
|
||||
// reported as ready for writing.
|
||||
// On Dragonfly, NetBSD and OpenBSD the fd is signaled
|
||||
// only once as ready (both read and write).
|
||||
// Issue 19093.
|
||||
if err := syscall.Fstat(fdi, &st); err == nil && st.Mode&syscall.S_IFMT == syscall.S_IFREG {
|
||||
// Also don't add directories to the netpoller.
|
||||
if err == nil && (typ == syscall.S_IFREG || typ == syscall.S_IFDIR) {
|
||||
pollable = false
|
||||
}
|
||||
|
||||
case "darwin":
|
||||
// In addition to the behavior described above for regular files,
|
||||
// on Darwin, kqueue does not work properly with fifos:
|
||||
// closing the last writer does not cause a kqueue event
|
||||
// for any readers. See issue #24164.
|
||||
if err := syscall.Fstat(fdi, &st); err == nil && (st.Mode&syscall.S_IFMT == syscall.S_IFIFO || st.Mode&syscall.S_IFMT == syscall.S_IFREG) {
|
||||
if runtime.GOOS == "darwin" && typ == syscall.S_IFIFO {
|
||||
pollable = false
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user