Skip to content

Commit

Permalink
runtime: record stub netpoll initialization, add lock around note
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ianlancetaylor committed Oct 30, 2019
1 parent 47efbf0 commit 9e094ea
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/runtime/netpoll_stub.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var netpollNote note
var netpollBroken uint32

func netpollGenericInit() {
atomic.Store(&netpollInited, 1)
}

func netpollBreak() {
Expand All @@ -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
}

0 comments on commit 9e094ea

Please sign in to comment.