diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2016-07-24 02:21:32 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2016-07-24 02:21:32 +0200 |
commit | a0d4c5e208405f84076891faaa43235bb2b87fc2 (patch) | |
tree | 9549cd4cd11c57e3c72d31f4a0424c75b1d5a063 /sys/src/cmd | |
parent | a840b597cad282e837560b65dad89aa0cfd4af77 (diff) |
make error handling in 9p service loops consistent
when we get eof, stop the loop immidiately and do not
rely on the read to eventually return an error.
when convM2S() fails to decode the message, error out
and stop the loop. there is no point in continuing.
Diffstat (limited to 'sys/src/cmd')
-rw-r--r-- | sys/src/cmd/9660srv/main.c | 19 | ||||
-rw-r--r-- | sys/src/cmd/9nfs/9p.c | 6 | ||||
-rw-r--r-- | sys/src/cmd/acme/fsys.c | 3 | ||||
-rw-r--r-- | sys/src/cmd/auth/keyfs.c | 11 | ||||
-rw-r--r-- | sys/src/cmd/aux/9pcon.c | 2 | ||||
-rw-r--r-- | sys/src/cmd/aux/consolefs.c | 17 | ||||
-rw-r--r-- | sys/src/cmd/aux/depend.c | 19 | ||||
-rw-r--r-- | sys/src/cmd/aux/searchfs.c | 22 | ||||
-rw-r--r-- | sys/src/cmd/bzfs/oramfs.c | 17 | ||||
-rw-r--r-- | sys/src/cmd/cfs/cfs.c | 6 | ||||
-rw-r--r-- | sys/src/cmd/cpu.c | 9 | ||||
-rw-r--r-- | sys/src/cmd/cwfs/srv.c | 18 | ||||
-rw-r--r-- | sys/src/cmd/dossrv/xfssrv.c | 19 | ||||
-rw-r--r-- | sys/src/cmd/exportfs/exportfs.c | 5 | ||||
-rw-r--r-- | sys/src/cmd/ip/ftpfs/ftpfs.c | 16 | ||||
-rw-r--r-- | sys/src/cmd/lnfs.c | 19 | ||||
-rw-r--r-- | sys/src/cmd/ndb/cs.c | 8 | ||||
-rw-r--r-- | sys/src/cmd/paqfs/paqfs.c | 11 | ||||
-rw-r--r-- | sys/src/cmd/plumb/fsys.c | 7 | ||||
-rw-r--r-- | sys/src/cmd/ratfs/proto.c | 16 | ||||
-rw-r--r-- | sys/src/cmd/rio/fsys.c | 5 | ||||
-rw-r--r-- | sys/src/cmd/tapefs/fs.c | 34 | ||||
-rw-r--r-- | sys/src/cmd/telco/telco.c | 13 | ||||
-rw-r--r-- | sys/src/cmd/vac/vacfs.c | 9 | ||||
-rw-r--r-- | sys/src/cmd/vnc/exportfs.c | 8 |
25 files changed, 95 insertions, 224 deletions
diff --git a/sys/src/cmd/9660srv/main.c b/sys/src/cmd/9660srv/main.c index 94e2a5d8d..0ccdccf10 100644 --- a/sys/src/cmd/9660srv/main.c +++ b/sys/src/cmd/9660srv/main.c @@ -164,22 +164,11 @@ io(int srvfd) pid = getpid(); fmtinstall('F', fcallfmt); - for(;;){ - /* - * reading from a pipe or a network device - * will give an error after a few eof reads. - * however, we cannot tell the difference - * between a zero-length read and an interrupt - * on the processes writing to us, - * so we wait for the error. - */ - n = read9pmsg(srvfd, mdata, sizeof mdata); + while((n = read9pmsg(srvfd, mdata, sizeof mdata)) != 0){ if(n < 0) - break; - if(n == 0) - continue; - if(convM2S(mdata, n, req) == 0) - continue; + panic(1, "mount read"); + if(convM2S(mdata, n, req) != n) + panic(1, "convM2S format error"); if(chatty) fprint(2, "9660srv %d:<-%F\n", pid, req); diff --git a/sys/src/cmd/9nfs/9p.c b/sys/src/cmd/9nfs/9p.c index 74919f2e8..ab62977d0 100644 --- a/sys/src/cmd/9nfs/9p.c +++ b/sys/src/cmd/9nfs/9p.c @@ -40,13 +40,13 @@ xmesg(Session *s, int t) } again: n = read9pmsg(s->fd, s->data, messagesize); + if(n == 0) + return -1; if(n < 0){ clog("xmesg read error: %r\n"); return -1; } - if(n == 0) - goto again; - if(convM2S(s->data, n, &s->f) <= 0){ + if(convM2S(s->data, n, &s->f) != n){ clog("xmesg bad convM2S %d %.2x %.2x %.2x %.2x\n", n, ((uchar*)s->data)[0], ((uchar*)s->data)[1], ((uchar*)s->data)[2], ((uchar*)s->data)[3]); diff --git a/sys/src/cmd/acme/fsys.c b/sys/src/cmd/acme/fsys.c index edc65537d..7235bbe22 100644 --- a/sys/src/cmd/acme/fsys.c +++ b/sys/src/cmd/acme/fsys.c @@ -148,8 +148,7 @@ fsysproc(void *) x = nil; for(;;){ buf = emalloc(messagesize+UTFmax); /* overflow for appending partial rune in xfidwrite */ - while((n = read9pmsg(sfd, buf, messagesize)) == 0 && !closing) - ; + n = read9pmsg(sfd, buf, messagesize); if(n <= 0){ if(closing) break; diff --git a/sys/src/cmd/auth/keyfs.c b/sys/src/cmd/auth/keyfs.c index 0fa72e3ad..efcca7d54 100644 --- a/sys/src/cmd/auth/keyfs.c +++ b/sys/src/cmd/auth/keyfs.c @@ -1038,14 +1038,11 @@ io(int in, int out) /* after restart, let the system settle for 5 mins before warning */ lastwarning = time(0) - 24*60*60 + 5*60; - for(;;){ - n = read9pmsg(in, mdata, messagesize); - if(n == 0) - continue; + while((n = read9pmsg(in, mdata, messagesize)) != 0){ if(n < 0) - error("mount read %d", n); - if(convM2S(mdata, n, &rhdr) == 0) - continue; + error("mount read: %r"); + if(convM2S(mdata, n, &rhdr) != n) + error("convM2S format error: %r"); if(newkeys()) readusers(); diff --git a/sys/src/cmd/aux/9pcon.c b/sys/src/cmd/aux/9pcon.c index f8bbf3c18..9edf26510 100644 --- a/sys/src/cmd/aux/9pcon.c +++ b/sys/src/cmd/aux/9pcon.c @@ -49,7 +49,7 @@ watch(int fd) sysfatal("out of memory"); while((n = read9pmsg(fd, buf, messagesize)) > 0){ - if(convM2S(buf, n, &f) == 0){ + if(convM2S(buf, n, &f) != n){ print("convM2S: %r\n"); continue; } diff --git a/sys/src/cmd/aux/consolefs.c b/sys/src/cmd/aux/consolefs.c index ebc5e1230..feef1eef3 100644 --- a/sys/src/cmd/aux/consolefs.c +++ b/sys/src/cmd/aux/consolefs.c @@ -681,18 +681,13 @@ fsrun(void *v) } free(d); r = allocreq(fs, messagesize); - while((n = read9pmsg(fs->fd, r->buf, messagesize)) == 0) - ; + n = read9pmsg(fs->fd, r->buf, messagesize); + if(n == 0) + threadexitsall("unmounted"); if(n < 0) - fatal("unmounted"); - - if(convM2S(r->buf, n, &r->f) == 0){ - fprint(2, "can't convert %ux %ux %ux\n", r->buf[0], - r->buf[1], r->buf[2]); - free(r); - continue; - } - + fatal("mount read: %r"); + if(convM2S(r->buf, n, &r->f) != n) + fatal("convM2S format error: %r"); f = fsgetfid(fs, r->f.fid); r->fid = f; diff --git a/sys/src/cmd/aux/depend.c b/sys/src/cmd/aux/depend.c index 6132b2d22..0a06ed710 100644 --- a/sys/src/cmd/aux/depend.c +++ b/sys/src/cmd/aux/depend.c @@ -365,18 +365,14 @@ fsrun(void *a) for(;;){ r = allocreq(messagesize); qlock(&iolock); - while((n = read9pmsg(fs->fd, r->buf, messagesize)) == 0) - ; - qunlock(&iolock); + n = read9pmsg(fs->fd, r->buf, messagesize); + if(n == 0) + threadexitsall("unmounted"); if(n < 0) - fatal("read9pmsg error: %r"); - - if(convM2S(r->buf, n, &r->f) == 0){ - fprint(2, "can't convert %ux %ux %ux\n", r->buf[0], - r->buf[1], r->buf[2]); - free(r); - continue; - } + fatal("mount read: %r"); + if(convM2S(r->buf, n, &r->f) != n) + fatal("convM2S format error: %r"); + qunlock(&iolock); f = fsgetfid(fs, r->f.fid); r->fid = f; @@ -388,7 +384,6 @@ fsrun(void *a) (*fcall[t])(fs, r, f); fsputfid(fs, f); } - } /* diff --git a/sys/src/cmd/aux/searchfs.c b/sys/src/cmd/aux/searchfs.c index 7c1ad84f1..4a617f8e2 100644 --- a/sys/src/cmd/aux/searchfs.c +++ b/sys/src/cmd/aux/searchfs.c @@ -592,26 +592,12 @@ fsrun(Fs *fs, int fd) int n; buf = emalloc(messagesize); - for(;;){ - /* - * reading from a pipe or a network device - * will give an error after a few eof reads - * however, we cannot tell the difference - * between a zero-length read and an interrupt - * on the processes writing to us, - * so we wait for the error - */ - n = read9pmsg(fd, buf, messagesize); - if(n == 0) - continue; + while((n = read9pmsg(fd, buf, messagesize)) != 0){ if(n < 0) - fatal("mount read"); - + fatal("mount read: %r"); rpc.data = (char*)buf + IOHDRSZ; - if(convM2S(buf, n, &rpc) == 0) - continue; - // fprint(2, "recv: %F\n", &rpc); - + if(convM2S(buf, n, &rpc) != n) + fatal("convM2S format error: %r"); /* * flushes are way too hard. diff --git a/sys/src/cmd/bzfs/oramfs.c b/sys/src/cmd/bzfs/oramfs.c index 8fb32a2c3..e5d7ad0a2 100644 --- a/sys/src/cmd/bzfs/oramfs.c +++ b/sys/src/cmd/bzfs/oramfs.c @@ -743,22 +743,11 @@ io(void) pid = getpid(); - for(;;){ - /* - * reading from a pipe or a network device - * will give an error after a few eof reads. - * however, we cannot tell the difference - * between a zero-length read and an interrupt - * on the processes writing to us, - * so we wait for the error. - */ - n = read9pmsg(mfd[0], mdata, messagesize); + while((n = read9pmsg(mfd[0], mdata, messagesize)) != 0){ if(n < 0) error("mount read: %r"); - if(n == 0) - continue; - if(convM2S(mdata, n, &thdr) == 0) - continue; + if(convM2S(mdata, n, &thdr) != n) + error("convM2S format error: %r"); if(debug) fprint(2, "ramfs %d:<-%F\n", pid, &thdr); diff --git a/sys/src/cmd/cfs/cfs.c b/sys/src/cmd/cfs/cfs.c index b11448be8..82a508684 100644 --- a/sys/src/cmd/cfs/cfs.c +++ b/sys/src/cmd/cfs/cfs.c @@ -808,14 +808,14 @@ rcvmsg(P9fs *p, Fcall *f) char buf[128]; olen = p->len; - while((p->len = read9pmsg(p->fd[0], datarcv, sizeof(datarcv))) == 0) - ; + p->len = read9pmsg(p->fd[0], datarcv, sizeof(datarcv)); + if(p->len == 0) + exits(""); if(p->len < 0){ snprint(buf, sizeof buf, "read9pmsg(%d)->%ld: %r", p->fd[0], p->len); error(buf); } - if((rlen = convM2S(datarcv, p->len, f)) != p->len) error("rcvmsg format error, expected length %d, got %d", rlen, p->len); diff --git a/sys/src/cmd/cpu.c b/sys/src/cmd/cpu.c index 1994aaf28..bc82316d9 100644 --- a/sys/src/cmd/cpu.c +++ b/sys/src/cmd/cpu.c @@ -1028,14 +1028,7 @@ notefs(int fd) ncpunote = 0; for(;;){ n = read9pmsg(fd, buf, sizeof(buf)); - if(n < 0){ - if(dbg) - fprint(2, "read9pmsg(%d) returns %d: %r\n", fd, n); - break; - } - if(n == 0) - continue; - if(convM2S(buf, n, &f) <= BIT16SZ) + if(n <= 0 || convM2S(buf, n, &f) != n) break; if(dbg) fprint(2, "notefs: ->%F\n", &f); diff --git a/sys/src/cmd/cwfs/srv.c b/sys/src/cmd/cwfs/srv.c index b3f5d7b65..e022b9fbf 100644 --- a/sys/src/cmd/cwfs/srv.c +++ b/sys/src/cmd/cwfs/srv.c @@ -104,8 +104,9 @@ srvi(void *aux) Msgbuf *mb, *ms; uchar *b, *p, *e; int n, m; - char buf[ERRMAX]; + char err[ERRMAX]; + err[0] = 0; chan = aux; srv = chan->pdata; @@ -116,13 +117,13 @@ srvi(void *aux) e = b + mb->count; Read: - while((n = read(srv->fd, p, e - p)) >= 0){ + while((n = read(srv->fd, p, e - p)) > 0){ p += n; while((p - b) >= BIT32SZ){ m = GBIT32(b); if((m < BIT32SZ) || (m > mb->count)){ - werrstr("bad length in 9P2000 message header"); - goto Error; + strcpy(err, "bad length in 9P2000 message header"); + goto Hangup; } if((n = (p - b) - m) < 0){ e = b + m; @@ -149,12 +150,11 @@ Read: e = b + mb->count; } -Error: - rerrstr(buf, sizeof(buf)); - if(strstr(buf, "interrupt")) - goto Read; + if(n < 0) + errstr(err, sizeof(err)); - chanhangup(chan, buf); +Hangup: + chanhangup(chan, err); srvput(srv); mbfree(mb); diff --git a/sys/src/cmd/dossrv/xfssrv.c b/sys/src/cmd/dossrv/xfssrv.c index ddc9b2bb6..7bceb74fc 100644 --- a/sys/src/cmd/dossrv/xfssrv.c +++ b/sys/src/cmd/dossrv/xfssrv.c @@ -135,22 +135,11 @@ io(int srvfd) pid = getpid(); fmtinstall('F', fcallfmt); - for(;;){ - /* - * reading from a pipe or a network device - * will give an error after a few eof reads. - * however, we cannot tell the difference - * between a zero-length read and an interrupt - * on the processes writing to us, - * so we wait for the error. - */ - n = read9pmsg(srvfd, mdata, sizeof mdata); + while((n = read9pmsg(srvfd, mdata, sizeof mdata)) != 0){ if(n < 0) - break; - if(n == 0) - continue; - if(convM2S(mdata, n, req) == 0) - continue; + panic("mount read"); + if(convM2S(mdata, n, req) != n) + panic("convM2S format error"); if(chatty) fprint(2, "dossrv %d:<-%F\n", pid, req); diff --git a/sys/src/cmd/exportfs/exportfs.c b/sys/src/cmd/exportfs/exportfs.c index a434d1cdd..7fac15ba3 100644 --- a/sys/src/cmd/exportfs/exportfs.c +++ b/sys/src/cmd/exportfs/exportfs.c @@ -408,12 +408,11 @@ main(int argc, char **argv) */ for(;;) { r = getsbuf(); - while((n = read9pmsg(0, r->buf, messagesize)) == 0) - ; + n = read9pmsg(0, r->buf, messagesize); if(n <= 0) fatal(nil); Message: - if(convM2S(r->buf, n, &r->work) == 0) + if(convM2S(r->buf, n, &r->work) != n) fatal("convM2S format error"); DEBUG(DFD, "%F\n", &r->work); diff --git a/sys/src/cmd/ip/ftpfs/ftpfs.c b/sys/src/cmd/ip/ftpfs/ftpfs.c index 540ce853b..b67dde99e 100644 --- a/sys/src/cmd/ip/ftpfs/ftpfs.c +++ b/sys/src/cmd/ip/ftpfs/ftpfs.c @@ -255,23 +255,19 @@ kaproc(void) void io(void) { - char *err, buf[ERRMAX]; + char *err; int n; kapid = kaproc(); while(!dying){ n = read9pmsg(mfd, mdata, messagesize); - if(n < 0){ - errstr(buf, sizeof buf); - if(buf[0]=='\0' || strstr(buf, "hungup")) - exits(""); - fatal("mount read: %s\n", buf); - } if(n == 0) - continue; - if(convM2S(mdata, n, &thdr) == 0) - continue; + break; + if(n < 0) + fatal("mount read: %r"); + if(convM2S(mdata, n, &thdr) != n) + fatal("convM2S format error: %r"); if(debug) fprint(2, "<-%F\n", &thdr);/**/ diff --git a/sys/src/cmd/lnfs.c b/sys/src/cmd/lnfs.c index c34669b94..dcc2a245d 100644 --- a/sys/src/cmd/lnfs.c +++ b/sys/src/cmd/lnfs.c @@ -526,22 +526,11 @@ io(void) pid = getpid(); - for(;;){ - /* - * reading from a pipe or a network device - * will give an error after a few eof reads. - * however, we cannot tell the difference - * between a zero-length read and an interrupt - * on the processes writing to us, - * so we wait for the error. - */ - n = read9pmsg(mfd[0], mdata, messagesize); + while((n = read9pmsg(mfd[0], mdata, messagesize)) != 0){ if(n < 0) - sysfatal("mount read"); - if(n == 0) - continue; - if(convM2S(mdata, n, &thdr) == 0) - continue; + sysfatal("mount read: %r"); + if(convM2S(mdata, n, &thdr) != n) + sysfatal("convM2S format error: %r"); if(debug) fprint(2, "%s %d:<-%F\n", argv0, pid, &thdr); diff --git a/sys/src/cmd/ndb/cs.c b/sys/src/cmd/ndb/cs.c index 093df27cf..755efe4b1 100644 --- a/sys/src/cmd/ndb/cs.c +++ b/sys/src/cmd/ndb/cs.c @@ -321,14 +321,14 @@ mountinit(char *service, char *mntpt) procsetname("%s", mntpt); break; case -1: - error("fork failed\n"); + error("fork failed"); default: /* * put ourselves into the file system */ close(p[0]); if(mount(p[1], -1, mntpt, MAFTER, "") < 0) - error("mount failed\n"); + error("mount failed"); _exits(0); } mfd[0] = mfd[1] = p[0]; @@ -447,13 +447,13 @@ io(void) if(n < 0) error("mount read"); if(n == 0) - continue; + break; job = newjob(); if(convM2S(mdata, n, &job->request) != n){ syslog(1, logfile, "format error %ux %ux %ux %ux %ux", mdata[0], mdata[1], mdata[2], mdata[3], mdata[4]); freejob(job); - continue; + break; } qlock(&dblock); mf = newfid(job->request.fid); diff --git a/sys/src/cmd/paqfs/paqfs.c b/sys/src/cmd/paqfs/paqfs.c index 8fe05cc05..f4be7b6f1 100644 --- a/sys/src/cmd/paqfs/paqfs.c +++ b/sys/src/cmd/paqfs/paqfs.c @@ -812,14 +812,11 @@ io(int fd) pid = getpid(); - for(;;){ - n = read9pmsg(fd, mdata, mesgsize); + while((n = read9pmsg(fd, mdata, mesgsize)) != 0){ if(n < 0) - sysfatal("mount read"); - if(n == 0) - continue; - if(convM2S(mdata, n, &rhdr) == 0) - continue; + sysfatal("mount read: %r"); + if(convM2S(mdata, n, &rhdr) != n) + sysfatal("convM2S format error: %r"); if(debug) fprint(2, "paqfs %d:<-%F\n", pid, &rhdr); diff --git a/sys/src/cmd/plumb/fsys.c b/sys/src/cmd/plumb/fsys.c index 0a5f6fbdd..d68ea0bc3 100644 --- a/sys/src/cmd/plumb/fsys.c +++ b/sys/src/cmd/plumb/fsys.c @@ -237,10 +237,11 @@ fsysproc(void*) if(buf == nil) error("malloc failed: %r"); qlock(&readlock); - while((n = read9pmsg(srvfd, buf, messagesize)) == 0) - ; - if(n < 0) + n = read9pmsg(srvfd, buf, messagesize); + if(n == 0) threadexitsall("unmounted"); + if(n < 0) + error("mount read: %r"); if(readlock.head == nil) /* no other processes waiting to read; start one */ proccreate(fsysproc, nil, Stack); qunlock(&readlock); diff --git a/sys/src/cmd/ratfs/proto.c b/sys/src/cmd/ratfs/proto.c index 7ed046fdd..21abbc282 100644 --- a/sys/src/cmd/ratfs/proto.c +++ b/sys/src/cmd/ratfs/proto.c @@ -56,16 +56,14 @@ io(void) Fcall rhdr; int n; - for(;;){ - n = read9pmsg(srvfd, rbuf, sizeof rbuf-1); - if(n <= 0) - fatal("mount read"); - if(convM2S(rbuf, n, &rhdr) == 0){ + while((n = read9pmsg(srvfd, rbuf, sizeof rbuf-1)) != 0){ + if(n < 0) + fatal("mount read: %r"); + if(convM2S(rbuf, n, &rhdr) != n){ if(debugfd >= 0) fprint(2, "%s: malformed message\n", argv0); - continue; + fatal("convM2S format error: %r"); } - if(debugfd >= 0) fprint(debugfd, "<-%F\n", &rhdr);/**/ @@ -94,9 +92,9 @@ reply(Fcall *r, char *error) fprint(debugfd, "->%F\n", r);/**/ n = convS2M(r, rbuf, sizeof rbuf); if(n == 0) - sysfatal("convS2M: %r"); + fatal("convS2M: %r"); if(write(srvfd, rbuf, n) < 0) - sysfatal("reply: %r"); + fatal("reply: %r"); } diff --git a/sys/src/cmd/rio/fsys.c b/sys/src/cmd/rio/fsys.c index c1ab79b53..3c1749910 100644 --- a/sys/src/cmd/rio/fsys.c +++ b/sys/src/cmd/rio/fsys.c @@ -195,9 +195,8 @@ filsysproc(void *arg) buf = malloc(messagesize+UTFmax); /* UTFmax for appending partial rune in xfidwrite */ if(buf == nil) error(Enomem); - while((n = read9pmsg(fs->sfd, buf, messagesize)) == 0) - yield(); - if(n < 0){ + n = read9pmsg(fs->sfd, buf, messagesize); + if(n <= 0){ yield(); /* if threadexitsall'ing, will not return */ fprint(2, "rio: %d: read9pmsg: %d %r\n", getpid(), n); errorshouldabort = 0; diff --git a/sys/src/cmd/tapefs/fs.c b/sys/src/cmd/tapefs/fs.c index b052c0af6..caf57a819 100644 --- a/sys/src/cmd/tapefs/fs.c +++ b/sys/src/cmd/tapefs/fs.c @@ -491,35 +491,15 @@ void io(void) { char *err; - int n, nerr; - char buf[ERRMAX]; - - errstr(buf, sizeof buf); - for(nerr=0, buf[0]='\0'; nerr<100; nerr++){ - /* - * reading from a pipe or a network device - * will give an error after a few eof reads - * however, we cannot tell the difference - * between a zero-length read and an interrupt - * on the processes writing to us, - * so we wait for the error - */ - n = read9pmsg(mfd[0], mdata, sizeof mdata); - if(n==0) - continue; - if(n < 0){ - if(buf[0]=='\0') - errstr(buf, sizeof buf); - continue; - } - nerr = 0; - buf[0] = '\0'; + int n; + + while((n = read9pmsg(mfd[0], mdata, sizeof mdata)) != 0){ + if(n < 0) + error("mount read"); if(convM2S(mdata, n, &rhdr) != n) error("convert error in convM2S"); - if(verbose) fprint(2, "tapefs: <=%F\n", &rhdr);/**/ - thdr.data = (char*)mdata + IOHDRSZ; thdr.stat = mdata + IOHDRSZ; if(!fcalls[rhdr.type]) @@ -542,10 +522,6 @@ io(void) if(write(mfd[1], mdata, n) != n) error("mount write"); } - if(buf[0]=='\0' || strstr(buf, "hungup")) - exits(""); - fprint(2, "%s: mount read: %s\n", argv0, buf); - exits(buf); } int diff --git a/sys/src/cmd/telco/telco.c b/sys/src/cmd/telco/telco.c index 87fb1ef96..e754ca30d 100644 --- a/sys/src/cmd/telco/telco.c +++ b/sys/src/cmd/telco/telco.c @@ -914,18 +914,7 @@ io(void) char *err; int n; - for(;;){ - /* - * reading from a pipe or a network device - * will give an error after a few eof reads - * however, we cannot tell the difference - * between a zero-length read and an interrupt - * on the processes writing to us, - * so we wait for the error - */ - n = read9pmsg(mfd[0], mdata, messagesize); - if(n == 0) - continue; + while((n = read9pmsg(mfd[0], mdata, messagesize)) != 0){ if(n < 0) error("mount read"); if(convM2S(mdata, n, &thdr) != n) diff --git a/sys/src/cmd/vac/vacfs.c b/sys/src/cmd/vac/vacfs.c index cc1a5ca06..d94021744 100644 --- a/sys/src/cmd/vac/vacfs.c +++ b/sys/src/cmd/vac/vacfs.c @@ -704,12 +704,9 @@ io(void) char *err; int n; - for(;;){ - n = read9pmsg(mfd[0], mdata, sizeof mdata); + while((n = read9pmsg(mfd[0], mdata, sizeof mdata)) != 0){ if(n < 0) - break; - if(n == 0) - continue; + sysfatal("mount read: %r"); if(convM2Su(mdata, n, &rhdr, dotu) != n) sysfatal("convM2S conversion error"); @@ -733,7 +730,7 @@ io(void) fprint(2, "vacfs:->%F\n", &thdr); n = convS2Mu(&thdr, mdata, messagesize, dotu); if(n <= BIT16SZ) - sysfatal("convS2Mu conversion error"); + sysfatal("convS2M conversion error"); if(err) vtfree(err); diff --git a/sys/src/cmd/vnc/exportfs.c b/sys/src/cmd/vnc/exportfs.c index 07e20e477..0c31d953d 100644 --- a/sys/src/cmd/vnc/exportfs.c +++ b/sys/src/cmd/vnc/exportfs.c @@ -149,10 +149,9 @@ exportproc(Export *fs) errdepth(ed); q = smalloc(sizeof(Exq)); - while((n = read9pmsg(fs->io, q->buf, Maxrpc)) == 0) - ; - if(n < 0 || convM2S(q->buf, n, &q->rpc) != n) - goto bad; + n = read9pmsg(fs->io, q->buf, Maxrpc); + if(n <= 0 || convM2S(q->buf, n, &q->rpc) != n) + break; if(exdebug) print("export %d <- %F\n", getpid(), &q->rpc); @@ -181,7 +180,6 @@ exportproc(Export *fs) kproc("exportfs", exslave, nil); rendwakeup(&exq.rwait); } -bad: free(q); if(exdebug) fprint(2, "export proc shutting down: %r\n"); |