diff options
| author | rsc <devnull@localhost> | 2004-09-21 01:11:28 +0000 |
|---|---|---|
| committer | rsc <devnull@localhost> | 2004-09-21 01:11:28 +0000 |
| commit | c6687d4591964cb13df87f55ec4770e778a4a55c (patch) | |
| tree | ee669a419904e929ae8ae54fd04c2bb41b5a57b1 /src/libthread/fdwait.c | |
| parent | 3d5e34e146b5ba5c973230abb624ce9126024569 (diff) | |
| download | plan9port-c6687d4591964cb13df87f55ec4770e778a4a55c.tar.gz plan9port-c6687d4591964cb13df87f55ec4770e778a4a55c.zip | |
Continue the pthreads torture.
Diffstat (limited to 'src/libthread/fdwait.c')
| -rw-r--r-- | src/libthread/fdwait.c | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/src/libthread/fdwait.c b/src/libthread/fdwait.c index a715706a..8768e60d 100644 --- a/src/libthread/fdwait.c +++ b/src/libthread/fdwait.c @@ -241,15 +241,16 @@ threadread(int fd, void *a, long n) threadfdnoblock(fd); again: + /* + * Always call wait (i.e. don't optimistically try the read) + * so that the scheduler gets a chance to run other threads. + */ + _threadfdwait(fd, 'r', getcallerpc(&fd)); errno = 0; nn = read(fd, a, n); if(nn <= 0){ - if(errno == EINTR) + if(errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) goto again; - if(errno == EAGAIN || errno == EWOULDBLOCK){ - _threadfdwait(fd, 'r', getcallerpc(&fd)); - goto again; - } } return nn; } @@ -261,14 +262,15 @@ threadrecvfd(int fd) threadfdnoblock(fd); again: + /* + * Always call wait (i.e. don't optimistically try the recvfd) + * so that the scheduler gets a chance to run other threads. + */ + _threadfdwait(fd, 'r', getcallerpc(&fd)); nn = recvfd(fd); if(nn < 0){ - if(errno == EINTR) + if(errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) goto again; - if(errno == EAGAIN || errno == EWOULDBLOCK){ - _threadfdwait(fd, 'r', getcallerpc(&fd)); - goto again; - } } return nn; } @@ -280,14 +282,15 @@ threadsendfd(int fd, int sfd) threadfdnoblock(fd); again: + /* + * Always call wait (i.e. don't optimistically try the sendfd) + * so that the scheduler gets a chance to run other threads. + */ + _threadfdwait(fd, 'w', getcallerpc(&fd)); nn = sendfd(fd, sfd); if(nn < 0){ - if(errno == EINTR) + if(errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) goto again; - if(errno == EAGAIN || errno == EWOULDBLOCK){ - _threadfdwait(fd, 'w', getcallerpc(&fd)); - goto again; - } } return nn; } @@ -315,14 +318,15 @@ _threadwrite(int fd, const void *a, long n) threadfdnoblock(fd); again: + /* + * Always call wait (i.e. don't optimistically try the write) + * so that the scheduler gets a chance to run other threads. + */ + _threadfdwait(fd, 'w', getcallerpc(&fd)); nn = write(fd, a, n); if(nn < 0){ - if(errno == EINTR) + if(errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) goto again; - if(errno == EAGAIN || errno == EWOULDBLOCK){ - _threadfdwait(fd, 'w', getcallerpc(&fd)); - goto again; - } } return nn; } |
