From: ian Date: Thu, 26 Nov 2015 00:24:21 +0000 (+0000) Subject: PR go/61303 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=12178003b25390b4b6f7e50ae340bf3b8e45a0bc;p=thirdparty%2Fgcc.git PR go/61303 runtime: don't overallocate in select code If we've already allocated an fd_set, don't allocate another one. Also, don't bother to read from rdwake if it wasn't returned in select. Fixes https://gcc.gnu.org/PR61303. Reviewed-on: https://go-review.googlesource.com/17243 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@230922 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 9fe9d5e1042d..80136abcf76c 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -0d979f0b860cfd879754150e0ae5e1018b94d7c4 +81eb6a3f425b2158c67ee32c0cc973a72ce9d6be The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/libgo/runtime/netpoll_select.c b/libgo/runtime/netpoll_select.c index b46133591184..033661d17f24 100644 --- a/libgo/runtime/netpoll_select.c +++ b/libgo/runtime/netpoll_select.c @@ -135,6 +135,8 @@ runtime_netpoll(bool block) byte b; struct stat st; + allocatedfds = false; + retry: runtime_lock(&selectlock); @@ -146,11 +148,13 @@ runtime_netpoll(bool block) } if(inuse) { - prfds = runtime_SysAlloc(4 * sizeof fds, &mstats.other_sys); - pwfds = prfds + 1; - pefds = pwfds + 1; - ptfds = pefds + 1; - allocatedfds = true; + if(!allocatedfds) { + prfds = runtime_SysAlloc(4 * sizeof fds, &mstats.other_sys); + pwfds = prfds + 1; + pefds = pwfds + 1; + ptfds = pefds + 1; + allocatedfds = true; + } } else { prfds = &grfds; pwfds = &gwfds; @@ -216,7 +220,7 @@ runtime_netpoll(bool block) mode = 'r' + 'w'; --c; } - if(i == rdwake) { + if(i == rdwake && mode != 0) { while(read(rdwake, &b, sizeof b) > 0) ; continue;