Commit 9e094ea0 authored by Ian Lance Taylor's avatar Ian Lance Taylor

runtime: record stub netpoll initialization, add lock around note

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/+/204045Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: default avatarMichael Knyszek <mknyszek@google.com>
parent 47efbf0a
...@@ -16,6 +16,7 @@ var netpollNote note ...@@ -16,6 +16,7 @@ var netpollNote note
var netpollBroken uint32 var netpollBroken uint32
func netpollGenericInit() { func netpollGenericInit() {
atomic.Store(&netpollInited, 1)
} }
func netpollBreak() { func netpollBreak() {
...@@ -30,13 +31,17 @@ func netpoll(delay int64) gList { ...@@ -30,13 +31,17 @@ func netpoll(delay int64) gList {
// Implementation for platforms that do not support // Implementation for platforms that do not support
// integrated network poller. // integrated network poller.
if delay != 0 { 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) noteclear(&netpollNote)
atomic.Store(&netpollBroken, 0) atomic.Store(&netpollBroken, 0)
notetsleep(&netpollNote, delay) notetsleep(&netpollNote, delay)
unlock(&netpollStubLock)
} }
return gList{} return gList{}
} }
func netpollinited() bool { func netpollinited() bool {
return false return atomic.Load(&netpollInited) != 0
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment