aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/runtime/netpoll.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/runtime/netpoll.go')
-rw-r--r--libgo/go/runtime/netpoll.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/libgo/go/runtime/netpoll.go b/libgo/go/runtime/netpoll.go
index da00b57..82380f6 100644
--- a/libgo/go/runtime/netpoll.go
+++ b/libgo/go/runtime/netpoll.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+//go:build aix || darwin || dragonfly || freebsd || hurd || (js && wasm) || linux || netbsd || openbsd || solaris || windows
// +build aix darwin dragonfly freebsd hurd js,wasm linux netbsd openbsd solaris windows
package runtime
@@ -25,6 +26,9 @@ import (
// Arm edge-triggered notifications for fd. The pd argument is to pass
// back to netpollready when fd is ready. Return an errno value.
//
+// func netpollclose(fd uintptr) int32
+// Disable notifications for fd. Return an errno value.
+//
// func netpoll(delta int64) gList
// Poll the network. If delta < 0, block indefinitely. If delta == 0,
// poll without blocking. If delta > 0, block for up to delta nanoseconds.
@@ -164,9 +168,12 @@ func poll_runtime_pollOpen(fd uintptr) (uintptr, int) {
pd.self = pd
unlock(&pd.lock)
- var errno int32
- errno = netpollopen(fd, pd)
- return uintptr(unsafe.Pointer(pd)), int(errno)
+ errno := netpollopen(fd, pd)
+ if errno != 0 {
+ pollcache.free(pd)
+ return 0, int(errno)
+ }
+ return uintptr(unsafe.Pointer(pd)), 0
}
//go:linkname poll_runtime_pollClose internal_1poll.runtime__pollClose
@@ -567,8 +574,7 @@ func (c *pollCache) alloc() *pollDesc {
func (pd *pollDesc) makeArg() (i interface{}) {
x := (*eface)(unsafe.Pointer(&i))
x._type = pdType
- // For gccgo, we still use pd.self here, not &pd.self.
- x.data = unsafe.Pointer(pd.self)
+ x.data = unsafe.Pointer(&pd.self)
return
}