diff options
author | cinap_lenrek <cinap_lenrek@gmx.de> | 2013-03-11 01:16:34 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@gmx.de> | 2013-03-11 01:16:34 +0100 |
commit | 631aef280d0363ea853b0ab878005e48153b5eea (patch) | |
tree | c2fa3af95277b317c9dc87a345317fe99b6b1445 /sys/src/ape/lib/ap/plan9/read.c | |
parent | d526ee0750815820ac70e030ff87775ac56785e3 (diff) |
ape: fix thread race with close() and select()
in ape close(), do the real filedescriptor _CLOSE() *after* we cleared
the _fdinfo[] slot because once closed, we dont own the slot anymore and
another process doing open() can trash the slot. make sure open() retuns
fd < OPEN_MAX.
double check in _startbuf() holding mux->lock if the fd is already buffered
preveting running double copyprocs on a fd.
dont zero the mux->rwant/ewant bitmaps at the end of select() as we do not
hold the mix->lock.
in _closebuf() kill copyproc while holding the mux->lock to make sure the
copyproc isnt holding it at the time it is killed. run kill() multiple times
to make sure the proc is gone.
Diffstat (limited to 'sys/src/ape/lib/ap/plan9/read.c')
-rw-r--r-- | sys/src/ape/lib/ap/plan9/read.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/src/ape/lib/ap/plan9/read.c b/sys/src/ape/lib/ap/plan9/read.c index 471ab7e33..435a6d7f2 100644 --- a/sys/src/ape/lib/ap/plan9/read.c +++ b/sys/src/ape/lib/ap/plan9/read.c @@ -38,7 +38,7 @@ read(int d, void *buf, size_t nbytes) } n = _readbuf(d, buf, nbytes, noblock); }else{ - n = _READ(d, buf, nbytes); + n = _READ(d, buf, nbytes); if(n < 0) _syserrno(); } |