From 91d35ad1b86bd9835596704e8ecf1856d3851390 Mon Sep 17 00:00:00 2001 From: Dmitriy Vyukov Date: Sat, 27 Jul 2013 13:46:40 +0400 Subject: [PATCH] runtime: fix potential deadlock in netpoll on windows If netpoll has been told to block, it must not return with nil, otherwise scheduler assumes that netpoll is disabled. R=golang-dev, alex.brainman CC=golang-dev https://golang.org/cl/11920044 --- src/pkg/runtime/netpoll_windows.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pkg/runtime/netpoll_windows.c b/src/pkg/runtime/netpoll_windows.c index 52ba7e46e6..972f1c30ef 100644 --- a/src/pkg/runtime/netpoll_windows.c +++ b/src/pkg/runtime/netpoll_windows.c @@ -71,6 +71,8 @@ runtime·netpoll(bool block) if(iocphandle == INVALID_HANDLE_VALUE) return nil; + gp = nil; +retry: o = nil; errno = 0; qty = 0; @@ -104,7 +106,8 @@ runtime·netpoll(bool block) } o->errno = errno; o->qty = qty; - gp = nil; runtime·netpollready(&gp, (void*)o->runtimeCtx, mode); + if(block && gp == nil) + goto retry; return gp; } -- 2.48.1