return err != nil && stringsHasSuffix(err.Error(), "interrupted")
}
-// PollDescriptor returns the descriptor being used by the poller,
-// or ^uintptr(0) if there isn't one. This is only used for testing.
-func PollDescriptor() uintptr {
- return ^uintptr(0)
+// IsPollDescriptor returns true if fd is the descriptor being used by the poller.
+// This is only used for testing.
+func IsPollDescriptor(fd uintptr) bool {
+ return false
}
// RawControl invokes the user-defined function f for a non-IO
return nil
}
-// PollDescriptor returns the descriptor being used by the poller,
-// or ^uintptr(0) if there isn't one. This is only used for testing.
-func PollDescriptor() uintptr {
- return ^uintptr(0)
+// IsPollDescriptor returns true if fd is the descriptor being used by the poller.
+// This is only used for testing.
+func IsPollDescriptor(fd uintptr) bool {
+ return false
}
func runtimeNano() int64
func runtime_pollServerInit()
-func runtime_pollServerDescriptor() uintptr
func runtime_pollOpen(fd uintptr) (uintptr, int)
func runtime_pollClose(ctx uintptr)
func runtime_pollWait(ctx uintptr, mode int) int
func runtime_pollReset(ctx uintptr, mode int) int
func runtime_pollSetDeadline(ctx uintptr, d int64, mode int)
func runtime_pollUnblock(ctx uintptr)
+func runtime_isPollServerDescriptor(fd uintptr) bool
type pollDesc struct {
runtimeCtx uintptr
return nil
}
-// PollDescriptor returns the descriptor being used by the poller,
-// or ^uintptr(0) if there isn't one. This is only used for testing.
-func PollDescriptor() uintptr {
- return runtime_pollServerDescriptor()
+// IsPollDescriptor returns true if fd is the descriptor being used by the poller.
+// This is only used for testing.
+func IsPollDescriptor(fd uintptr) bool {
+ return runtime_isPollServerDescriptor(fd)
}
// The poll (epoll/kqueue) descriptor can be numerically
// either between stderr and the testlog-fd, or after
// testlog-fd.
- if poll.PollDescriptor() == n {
+ if poll.IsPollDescriptor(n) {
n++
}
for _, arg := range os.Args {
func closeUnexpectedFds(t *testing.T, m string) {
for fd := basefds(); fd <= 101; fd++ {
- if fd == poll.PollDescriptor() {
+ if poll.IsPollDescriptor(fd) {
continue
}
err := os.NewFile(fd, "").Close()
ofcmd = "fstat"
case "plan9":
ofcmd = "/bin/cat"
+ case "aix":
+ ofcmd = "procfiles"
}
args := os.Args
// Now verify that there are no other open fds.
var files []*os.File
for wantfd := basefds() + 1; wantfd <= 100; wantfd++ {
- if wantfd == poll.PollDescriptor() {
+ if poll.IsPollDescriptor(wantfd) {
continue
}
f, err := os.Open(os.Args[0])
switch runtime.GOOS {
case "plan9":
args = []string{fmt.Sprintf("/proc/%d/fd", os.Getpid())}
+ case "aix":
+ args = []string{fmt.Sprint(os.Getpid())}
default:
args = []string{"-p", fmt.Sprint(os.Getpid())}
}
return atomic.Load(&netpollInited) != 0
}
-//go:linkname poll_runtime_pollServerDescriptor internal/poll.runtime_pollServerDescriptor
-
-// poll_runtime_pollServerDescriptor returns the descriptor being used,
-// or ^uintptr(0) if the system does not use a poll descriptor.
-func poll_runtime_pollServerDescriptor() uintptr {
- return netpolldescriptor()
+//go:linkname poll_runtime_isPollServerDescriptor internal/poll.runtime_isPollServerDescriptor
+
+// poll_runtime_isPollServerDescriptor returns true if fd is a
+// descriptor being used by netpoll.
+func poll_runtime_isPollServerDescriptor(fd uintptr) bool {
+ fds := netpolldescriptor()
+ if GOOS != "aix" {
+ return fd == fds
+ } else {
+ // AIX have a pipe in its netpoll implementation.
+ // Therefore, two fd are returned by netpolldescriptor using a mask.
+ return fd == fds&0xFFFF || fd == (fds>>16)&0xFFFF
+ }
}
//go:linkname poll_runtime_pollOpen internal/poll.runtime_pollOpen