aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFazlul Shahriar <fshahriar@gmail.com>2020-10-09 16:36:34 -0400
committerDan Cross <crossd@gmail.com>2022-07-26 12:11:38 -0400
commit2ca8ede24ada82f22a77ab172a0a8214f623dc94 (patch)
treedfc05c0d33259e36ed9cd111a1d85120e98c99f0 /src
parent23420c24937a8899bf1cfb900b9a5155b6f924ae (diff)
fossil: fix EOF detection when reading 9P message
When the 9P connection is closed, reads on the connection will keep returning 0. So, fossil ends up looping forever, trying to read a 9P message, consuming 100% CPU. The fix interprets 0 bytes read as EOF. Reproduce by killing the 9pserve process serving the fossil service, or by listening on tcp and using 9p(1).
Diffstat (limited to 'src')
-rw-r--r--src/cmd/fossil/9proc.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/cmd/fossil/9proc.c b/src/cmd/fossil/9proc.c
index 23da4f4e..d31a7426 100644
--- a/src/cmd/fossil/9proc.c
+++ b/src/cmd/fossil/9proc.c
@@ -362,9 +362,8 @@ msgRead(void* v)
while(!eof){
m = msgAlloc(con);
- while((n = read9pmsg(fd, m->data, con->msize)) == 0)
- ;
- if(n < 0){
+ n = read9pmsg(fd, m->data, con->msize);
+ if(n <= 0){
m->t.type = Tversion;
m->t.fid = NOFID;
m->t.tag = NOTAG;