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/9nfs | |
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/9nfs')
-rw-r--r-- | sys/src/cmd/9nfs/9p.c | 6 |
1 files changed, 3 insertions, 3 deletions
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]); |