aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/runtime/netpoll.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2021-09-13 10:37:49 -0700
committerIan Lance Taylor <iant@golang.org>2021-09-13 10:37:49 -0700
commite252b51ccde010cbd2a146485d8045103cd99533 (patch)
treee060f101cdc32bf5e520de8e5275db9d4236b74c /libgo/go/runtime/netpoll.go
parentf10c7c4596dda99d2ee872c995ae4aeda65adbdf (diff)
parent104c05c5284b7822d770ee51a7d91946c7e56d50 (diff)
downloadgcc-e252b51ccde010cbd2a146485d8045103cd99533.zip
gcc-e252b51ccde010cbd2a146485d8045103cd99533.tar.gz
gcc-e252b51ccde010cbd2a146485d8045103cd99533.tar.bz2
Merge from trunk revision 104c05c5284b7822d770ee51a7d91946c7e56d50.
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
}