diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-11-26 00:24:21 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-11-26 00:24:21 +0000 |
commit | 12178003b25390b4b6f7e50ae340bf3b8e45a0bc (patch) | |
tree | c853bd52fd73b08be9644ba4fccfd3de7381eaca /libgo | |
parent | 9f45aa5c1e70fd8987e113d0ca6f8b19222f8b2c (diff) | |
download | gcc-12178003b25390b4b6f7e50ae340bf3b8e45a0bc.tar.gz |
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
Diffstat (limited to 'libgo')
-rw-r--r-- | libgo/runtime/netpoll_select.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/libgo/runtime/netpoll_select.c b/libgo/runtime/netpoll_select.c index b4613359118..033661d17f2 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; |