]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: record stub netpoll initialization, add lock around note
authorIan Lance Taylor <iant@golang.org>
Wed, 30 Oct 2019 00:34:52 +0000 (17:34 -0700)
committerIan Lance Taylor <iant@golang.org>
Wed, 30 Oct 2019 03:48:03 +0000 (03:48 +0000)
This fixes the Plan 9 support for the new timer code.

Updates #6239
Updates #27707

Change-Id: Ia498c399b8924910b97fcde07545fae3588aad47
Reviewed-on: https://go-review.googlesource.com/c/go/+/204045
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
src/runtime/netpoll_stub.go

index ab92b0424e0a621104ac2f6bf7e856636bb6e257..fe45cfbd400f2ba5275942a7d313acc053131fbd 100644 (file)
@@ -16,6 +16,7 @@ var netpollNote note
 var netpollBroken uint32
 
 func netpollGenericInit() {
+       atomic.Store(&netpollInited, 1)
 }
 
 func netpollBreak() {
@@ -30,13 +31,17 @@ func netpoll(delay int64) gList {
        // Implementation for platforms that do not support
        // integrated network poller.
        if delay != 0 {
+               // This lock ensures that only one goroutine tries to use
+               // the note. It should normally be completely uncontended.
+               lock(&netpollStubLock)
                noteclear(&netpollNote)
                atomic.Store(&netpollBroken, 0)
                notetsleep(&netpollNote, delay)
+               unlock(&netpollStubLock)
        }
        return gList{}
 }
 
 func netpollinited() bool {
-       return false
+       return atomic.Load(&netpollInited) != 0
 }