]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix deadlock in network poller
authorDmitriy Vyukov <dvyukov@google.com>
Sun, 7 Apr 2013 05:27:54 +0000 (22:27 -0700)
committerDmitriy Vyukov <dvyukov@google.com>
Sun, 7 Apr 2013 05:27:54 +0000 (22:27 -0700)
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

src/pkg/runtime/proc.c

index 0a131871f3c35fe1b63d0e452ad13ed7f4b06cc5..018a453d629b582878019402a1d127103c54f3f9 100644 (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);
 }