mirror of git://gcc.gnu.org/git/gcc.git
re PR go/61303 (gccgo: segfault, regression since 4.8.2)
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
From-SVN: r230923
This commit is contained in:
parent
1f8e5bf5d2
commit
c7ed358227
|
|
@ -135,6 +135,8 @@ runtime_netpoll(bool block)
|
||||||
byte b;
|
byte b;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
|
allocatedfds = false;
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
runtime_lock(&selectlock);
|
runtime_lock(&selectlock);
|
||||||
|
|
||||||
|
|
@ -146,11 +148,13 @@ runtime_netpoll(bool block)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(inuse) {
|
if(inuse) {
|
||||||
prfds = runtime_SysAlloc(4 * sizeof fds, &mstats.other_sys);
|
if(!allocatedfds) {
|
||||||
pwfds = prfds + 1;
|
prfds = runtime_SysAlloc(4 * sizeof fds, &mstats.other_sys);
|
||||||
pefds = pwfds + 1;
|
pwfds = prfds + 1;
|
||||||
ptfds = pefds + 1;
|
pefds = pwfds + 1;
|
||||||
allocatedfds = true;
|
ptfds = pefds + 1;
|
||||||
|
allocatedfds = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
prfds = &grfds;
|
prfds = &grfds;
|
||||||
pwfds = &gwfds;
|
pwfds = &gwfds;
|
||||||
|
|
@ -216,7 +220,7 @@ runtime_netpoll(bool block)
|
||||||
mode = 'r' + 'w';
|
mode = 'r' + 'w';
|
||||||
--c;
|
--c;
|
||||||
}
|
}
|
||||||
if(i == rdwake) {
|
if(i == rdwake && mode != 0) {
|
||||||
while(read(rdwake, &b, sizeof b) > 0)
|
while(read(rdwake, &b, sizeof b) > 0)
|
||||||
;
|
;
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue