plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

commit c91bd3283a44946fd420ce68c43580aa0d327546
parent 02a1a5c18bec9ca13fad2b7b12ae65c580f6fdf4
Author: rsc <devnull@localhost>
Date:   Fri,  5 Mar 2004 02:25:41 +0000

Pipes cannot use SOCK_DGRAM.  Back to SOCK_STREAM.
Add debugging to fdwait.

Rewrite getcallerpc on PowerMac to be correct.

Diffstat:
Msrc/cmd/9pserve.c | 8+++++---
Msrc/cmd/acme/acme.c | 2--
Msrc/cmd/plumb/rules.c | 2+-
Asrc/lib9/getcallerpc-PowerMacintosh.c | 7+++++++
Dsrc/lib9/getcallerpc-PowerMacintosh.s | 5-----
Msrc/lib9/pipe.c | 2+-
Msrc/libthread/fdwait.c | 19+++++++++++++------
7 files changed, 27 insertions(+), 18 deletions(-)

diff --git 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 @@ -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 @@ -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 @@ -0,0 +1,7 @@ +#include <lib9.h> + +ulong +getcallerpc(void *x) +{ + return (((ulong*)(x))[-4]); +} diff --git a/src/lib9/getcallerpc-PowerMacintosh.s b/src/lib9/getcallerpc-PowerMacintosh.s @@ -1,5 +0,0 @@ -.text -.globl _getcallerpc -_getcallerpc: - mflr r3 - blr diff --git 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 @@ -167,7 +167,7 @@ threadfdwaitsetup(void) } void -threadfdwait(int fd, int rw) +_threadfdwait(int fd, int rw, ulong pc) { int i; @@ -192,11 +192,18 @@ 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) { struct { @@ -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; } }