diff --git a/sys/src/cmd/cwfs/all.h b/sys/src/cmd/cwfs/all.h index 4c81ed5fd..89a15bea5 100644 --- a/sys/src/cmd/cwfs/all.h +++ b/sys/src/cmd/cwfs/all.h @@ -56,6 +56,7 @@ Timet boottime; Queue* serveq; Queue* raheadq; Rabuf* rabuffree; +QLock reflock; Lock rabuflock; Tlock tlocks[NTLOCK]; Lock tlocklock; diff --git a/sys/src/cmd/cwfs/main.c b/sys/src/cmd/cwfs/main.c index 8cf0ebc79..8f6f2a8e5 100644 --- a/sys/src/cmd/cwfs/main.c +++ b/sys/src/cmd/cwfs/main.c @@ -314,6 +314,8 @@ main(int argc, char **argv) printsizes(); } + qlock(&reflock); + qunlock(&reflock); serveq = newqueue(1000, "9P service"); /* tunable */ raheadq = newqueue(1000, "readahead"); /* tunable */ @@ -449,6 +451,7 @@ serve(void *) Msgbuf *mb; for (;;) { + qlock(&reflock); /* read 9P request from a network input process */ mb = fs_recv(serveq, 0); assert(mb->magic == Mbmagic); @@ -457,6 +460,7 @@ serve(void *) if (cp == nil) panic("serve: nil mb->chan"); rlock(&cp->reflock); + qunlock(&reflock); rlock(&mainlock);