]> Cypherpunks.ru repositories - gostls13.git/commit
runtime: adjust netpollWaiters after goroutines are ready
authorIan Lance Taylor <iant@golang.org>
Wed, 19 Jul 2023 23:09:35 +0000 (16:09 -0700)
committerGopher Robot <gobot@golang.org>
Thu, 20 Jul 2023 15:45:57 +0000 (15:45 +0000)
commitf51c55bfc382443b61ca3257c1ffea59eee2559f
tree646c5b640b8f420814331c164782c5000f3ecbe3
parent890b96f7abd8ba5b2243959d9b49c212a0fc4d78
runtime: adjust netpollWaiters after goroutines are ready

The runtime was adjusting netpollWaiters before the waiting
goroutines were marked as ready. This could cause the scheduler
to report a deadlock because there were no goroutines ready to run.
Keeping netpollWaiters non-zero ensures that at least one goroutine
will call netpoll(-1) from findRunnable.

This does mean that if a program has network activity for a while
and then never has it again, and also has no timers, then we can leave
an M stranded in a call to netpoll from which it will never return.
At least this won't be a common case. And it's not new; this has been
a potential problem for some time.

Fixes #61454

Change-Id: I17c7f891c2bb1262fda12c6929664e64686463c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/511455
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
src/runtime/netpoll.go
src/runtime/netpoll_aix.go
src/runtime/netpoll_epoll.go
src/runtime/netpoll_fake.go
src/runtime/netpoll_kqueue.go
src/runtime/netpoll_solaris.go
src/runtime/netpoll_stub.go
src/runtime/netpoll_wasip1.go
src/runtime/netpoll_windows.go
src/runtime/proc.go