aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/netpoll.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2019-04-10 17:56:18 -0700
committerIan Lance Taylor <iant@golang.org>2019-10-22 18:41:00 +0000
commit2e0aa581b4a2544249ad2f8e86e17204ca778ca7 (patch)
treefd16f15efc56946b7f51343440457726b32be80a /src/runtime/netpoll.go
parent3db6d46a4e0ee33eb34cef29f797ab7c12530a80 (diff)
downloadgo-2e0aa581b4a2544249ad2f8e86e17204ca778ca7.tar.xz
runtime: add new addtimer function
When we add a timer, make sure that the network poller is initialized, since we will use it if we have to wait for the timer to be ready. Updates #27707 Change-Id: I0637fe646bade2cc5ce50b745712292aa9c445b1 Reviewed-on: https://go-review.googlesource.com/c/go/+/171830 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/runtime/netpoll.go')
-rw-r--r--src/runtime/netpoll.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/runtime/netpoll.go b/src/runtime/netpoll.go
index 536dae3d4f..939b27061e 100644
--- a/src/runtime/netpoll.go
+++ b/src/runtime/netpoll.go
@@ -100,8 +100,13 @@ var (
//go:linkname poll_runtime_pollServerInit internal/poll.runtime_pollServerInit
func poll_runtime_pollServerInit() {
- netpollinit()
- atomic.Store(&netpollInited, 1)
+ netpollGenericInit()
+}
+
+func netpollGenericInit() {
+ if atomic.Cas(&netpollInited, 0, 1) {
+ netpollinit()
+ }
}
func netpollinited() bool {