1
0
mirror of https://github.com/golang/go synced 2024-11-12 03:40:21 -07:00

runtime: fix deadlock in network poller

The invariant is that there must be at least one running P or a thread polling network.
It was broken.
Fixes #5216.

R=golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/8459043
This commit is contained in:
Dmitriy Vyukov 2013-04-06 22:27:54 -07:00
parent 6732ad94c7
commit 0b5d55984f

View File

@ -875,6 +875,13 @@ handoffp(P *p)
startm(p, false);
return;
}
// If this is the last running P and nobody is polling network,
// need to wakeup another M to poll network.
if(runtime·sched.npidle == runtime·gomaxprocs-1 && runtime·atomicload64(&runtime·sched.lastpoll) != 0) {
runtime·unlock(&runtime·sched);
startm(p, false);
return;
}
pidleput(p);
runtime·unlock(&runtime·sched);
}