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/9660srv | |
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/9660srv')
-rw-r--r-- | sys/src/cmd/9660srv/main.c | 19 |
1 files changed, 4 insertions, 15 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); |