summaryrefslogtreecommitdiff
path: root/sys/src/cmd/auth
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2016-07-24 02:21:32 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2016-07-24 02:21:32 +0200
commita0d4c5e208405f84076891faaa43235bb2b87fc2 (patch)
tree9549cd4cd11c57e3c72d31f4a0424c75b1d5a063 /sys/src/cmd/auth
parenta840b597cad282e837560b65dad89aa0cfd4af77 (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/auth')
-rw-r--r--sys/src/cmd/auth/keyfs.c11
1 files changed, 4 insertions, 7 deletions
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();