Pipes cannot use SOCK_DGRAM. Back to SOCK_STREAM.

Add debugging to fdwait.

Rewrite getcallerpc on PowerMac to be correct.
This commit is contained in:
rsc 2004-03-05 02:25:41 +00:00
parent 02a1a5c18b
commit c91bd3283a
7 changed files with 27 additions and 18 deletions

View file

@ -167,7 +167,7 @@ threadmain(int argc, char **argv)
void void
mainproc(void *v) mainproc(void *v)
{ {
int n; int n, nn;
Fcall f; Fcall f;
USED(v); USED(v);
@ -186,8 +186,10 @@ mainproc(void *v)
f.tag = NOTAG; f.tag = NOTAG;
n = convS2M(&f, vbuf, sizeof vbuf); n = convS2M(&f, vbuf, sizeof vbuf);
if(verbose > 1) fprint(2, "* <- %F\n", &f); if(verbose > 1) fprint(2, "* <- %F\n", &f);
write(1, vbuf, n); nn = write(1, vbuf, n);
n = read9pmsg(0, vbuf, sizeof vbuf); if(n != nn)
sysfatal("error writing Tversion: %r\n");
n = threadread9pmsg(0, vbuf, sizeof vbuf);
if(convM2S(vbuf, n, &f) != n) if(convM2S(vbuf, n, &f) != n)
sysfatal("convM2S failure"); sysfatal("convM2S failure");
if(f.msize < msize) if(f.msize < msize)

View file

@ -63,8 +63,6 @@ threadmain(int argc, char *argv[])
int ncol; int ncol;
Display *d; Display *d;
extern int _threaddebuglevel;
_threaddebuglevel = ~0;
rfork(RFENVG|RFNAMEG); rfork(RFENVG|RFNAMEG);
ncol = -1; ncol = -1;

View file

@ -127,7 +127,7 @@ popinput(void)
return 1; return 1;
} }
int static int
getc(void) getc(void)
{ {
if(input == nil) if(input == nil)

View file

@ -0,0 +1,7 @@
#include <lib9.h>
ulong
getcallerpc(void *x)
{
return (((ulong*)(x))[-4]);
}

View file

@ -1,5 +0,0 @@
.text
.globl _getcallerpc
_getcallerpc:
mflr r3
blr

View file

@ -6,5 +6,5 @@
int int
p9pipe(int fd[2]) p9pipe(int fd[2])
{ {
return socketpair(AF_UNIX, SOCK_DGRAM, 0, fd); return socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
} }

View file

@ -167,7 +167,7 @@ threadfdwaitsetup(void)
} }
void void
threadfdwait(int fd, int rw) _threadfdwait(int fd, int rw, ulong pc)
{ {
int i; int i;
@ -192,10 +192,17 @@ threadfdwait(int fd, int rw)
pfd[i].fd = fd; pfd[i].fd = fd;
pfd[i].events = rw=='r' ? POLLIN : POLLOUT; pfd[i].events = rw=='r' ? POLLIN : POLLOUT;
polls[i].c = &s.c; 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); recvul(&s.c);
} }
void
threadfdwait(int fd, int rw)
{
_threadfdwait(fd, rw, getcallerpc(&fd));
}
void void
threadsleep(int ms) threadsleep(int ms)
{ {
@ -230,7 +237,7 @@ again:
if(errno == EINTR) if(errno == EINTR)
goto again; goto again;
if(errno == EAGAIN || errno == EWOULDBLOCK){ if(errno == EAGAIN || errno == EWOULDBLOCK){
threadfdwait(fd, 'r'); _threadfdwait(fd, 'r', getcallerpc(&fd));
goto again; goto again;
} }
} }
@ -249,7 +256,7 @@ again:
if(errno == EINTR) if(errno == EINTR)
goto again; goto again;
if(errno == EAGAIN || errno == EWOULDBLOCK){ if(errno == EAGAIN || errno == EWOULDBLOCK){
threadfdwait(fd, 'r'); _threadfdwait(fd, 'r', getcallerpc(&fd));
goto again; goto again;
} }
} }
@ -268,7 +275,7 @@ again:
if(errno == EINTR) if(errno == EINTR)
goto again; goto again;
if(errno == EAGAIN || errno == EWOULDBLOCK){ if(errno == EAGAIN || errno == EWOULDBLOCK){
threadfdwait(fd, 'w'); _threadfdwait(fd, 'w', getcallerpc(&fd));
goto again; goto again;
} }
} }
@ -303,7 +310,7 @@ again:
if(errno == EINTR) if(errno == EINTR)
goto again; goto again;
if(errno == EAGAIN || errno == EWOULDBLOCK){ if(errno == EAGAIN || errno == EWOULDBLOCK){
threadfdwait(fd, 'w'); _threadfdwait(fd, 'w', getcallerpc(&fd));
goto again; goto again;
} }
} }