From c4097c29512269f4547ebefb8abdc57a2892b479 Mon Sep 17 00:00:00 2001 From: rsc Date: Tue, 11 May 2004 17:51:27 +0000 Subject: Fix small bugs. --- src/libthread/fdwait.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src/libthread/fdwait.c') diff --git a/src/libthread/fdwait.c b/src/libthread/fdwait.c index 927fc64f..a6890332 100644 --- a/src/libthread/fdwait.c +++ b/src/libthread/fdwait.c @@ -2,12 +2,13 @@ #include #include #include - +#include "threadimpl.h" #include #include #include #define debugpoll 0 +static int noblocked[4096/32]; #ifdef __APPLE__ #include @@ -174,11 +175,15 @@ _threadfdwait(int fd, int rw, ulong pc) struct { Channel c; + Alt *qentry[2]; ulong x; } s; threadfdwaitsetup(); chaninit(&s.c, sizeof(ulong), 1); + s.c.qentry = (volatile Alt**)s.qentry; + s.c.nentry = 2; + memset(s.qentry, 0, sizeof s.qentry); for(i=0; ithread; + if(t && t->lastfd == fd) + return; fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0)|O_NONBLOCK); + if(t) + t->lastfd = fd; + + /* We could lock this but we're probably single-threaded + * and the worst that will happen is we'll run fcntl + * a few more times. + */ + noblocked[fd/(8*sizeof(int))] |= 1<<(fd%(8*sizeof(int))); } long -- cgit v1.2.3