diff --git a/src/cmd/9pserve.c b/src/cmd/9pserve.c index 44965a13..8acd5524 100644 --- a/src/cmd/9pserve.c +++ b/src/cmd/9pserve.c @@ -167,7 +167,7 @@ threadmain(int argc, char **argv) void mainproc(void *v) { - int n; + int n, nn; Fcall f; USED(v); @@ -186,8 +186,10 @@ mainproc(void *v) f.tag = NOTAG; n = convS2M(&f, vbuf, sizeof vbuf); if(verbose > 1) fprint(2, "* <- %F\n", &f); - write(1, vbuf, n); - n = read9pmsg(0, vbuf, sizeof vbuf); + nn = write(1, vbuf, n); + if(n != nn) + sysfatal("error writing Tversion: %r\n"); + n = threadread9pmsg(0, vbuf, sizeof vbuf); if(convM2S(vbuf, n, &f) != n) sysfatal("convM2S failure"); if(f.msize < msize) diff --git a/src/cmd/acme/acme.c b/src/cmd/acme/acme.c index 4e047c1d..87924caa 100644 --- a/src/cmd/acme/acme.c +++ b/src/cmd/acme/acme.c @@ -63,8 +63,6 @@ threadmain(int argc, char *argv[]) int ncol; Display *d; -extern int _threaddebuglevel; -_threaddebuglevel = ~0; rfork(RFENVG|RFNAMEG); ncol = -1; diff --git a/src/cmd/plumb/rules.c b/src/cmd/plumb/rules.c index b51bb61f..52a3d8e5 100644 --- a/src/cmd/plumb/rules.c +++ b/src/cmd/plumb/rules.c @@ -127,7 +127,7 @@ popinput(void) return 1; } -int +static int getc(void) { if(input == nil) diff --git a/src/lib9/getcallerpc-PowerMacintosh.c b/src/lib9/getcallerpc-PowerMacintosh.c new file mode 100644 index 00000000..679a72cf --- /dev/null +++ b/src/lib9/getcallerpc-PowerMacintosh.c @@ -0,0 +1,7 @@ +#include + +ulong +getcallerpc(void *x) +{ + return (((ulong*)(x))[-4]); +} diff --git a/src/lib9/getcallerpc-PowerMacintosh.s b/src/lib9/getcallerpc-PowerMacintosh.s deleted file mode 100644 index 3571b744..00000000 --- a/src/lib9/getcallerpc-PowerMacintosh.s +++ /dev/null @@ -1,5 +0,0 @@ -.text -.globl _getcallerpc -_getcallerpc: - mflr r3 - blr diff --git a/src/lib9/pipe.c b/src/lib9/pipe.c index 5d0e47c1..f9fe2420 100644 --- a/src/lib9/pipe.c +++ b/src/lib9/pipe.c @@ -6,5 +6,5 @@ int p9pipe(int fd[2]) { - return socketpair(AF_UNIX, SOCK_DGRAM, 0, fd); + return socketpair(AF_UNIX, SOCK_STREAM, 0, fd); } diff --git a/src/libthread/fdwait.c b/src/libthread/fdwait.c index 170305eb..e8e3129c 100644 --- a/src/libthread/fdwait.c +++ b/src/libthread/fdwait.c @@ -167,7 +167,7 @@ threadfdwaitsetup(void) } void -threadfdwait(int fd, int rw) +_threadfdwait(int fd, int rw, ulong pc) { int i; @@ -192,10 +192,17 @@ threadfdwait(int fd, int rw) pfd[i].fd = fd; pfd[i].events = rw=='r' ? POLLIN : POLLOUT; polls[i].c = &s.c; - //threadstate("fdwait %d %d", f->fd, e); + //fprint(2, "%s [%3d] fdwait %d %c list *0x%lux\n", + argv0, threadid(), fd, rw, pc); recvul(&s.c); } +void +threadfdwait(int fd, int rw) +{ + _threadfdwait(fd, rw, getcallerpc(&fd)); +} + void threadsleep(int ms) { @@ -230,7 +237,7 @@ again: if(errno == EINTR) goto again; if(errno == EAGAIN || errno == EWOULDBLOCK){ - threadfdwait(fd, 'r'); + _threadfdwait(fd, 'r', getcallerpc(&fd)); goto again; } } @@ -249,7 +256,7 @@ again: if(errno == EINTR) goto again; if(errno == EAGAIN || errno == EWOULDBLOCK){ - threadfdwait(fd, 'r'); + _threadfdwait(fd, 'r', getcallerpc(&fd)); goto again; } } @@ -268,7 +275,7 @@ again: if(errno == EINTR) goto again; if(errno == EAGAIN || errno == EWOULDBLOCK){ - threadfdwait(fd, 'w'); + _threadfdwait(fd, 'w', getcallerpc(&fd)); goto again; } } @@ -303,7 +310,7 @@ again: if(errno == EINTR) goto again; if(errno == EAGAIN || errno == EWOULDBLOCK){ - threadfdwait(fd, 'w'); + _threadfdwait(fd, 'w', getcallerpc(&fd)); goto again; } }