summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraiju <aiju@phicode.de>2011-07-29 16:24:52 +0200
committeraiju <aiju@phicode.de>2011-07-29 16:24:52 +0200
commit7f27b397caa5b6b585a186c2351831d2788fa5f9 (patch)
tree677035d0394a9a015ff046977104cb5f5e1ee852
parent61d322679b65aedb569af6f4e90764c106eca9ef (diff)
downloadplan9front-7f27b397caa5b6b585a186c2351831d2788fa5f9.tar.xz
nusb: more locking, also close dfd
-rw-r--r--sys/src/cmd/nusb/usbd/hub.c3
-rw-r--r--sys/src/cmd/nusb/usbd/usbd.c6
2 files changed, 9 insertions, 0 deletions
diff --git a/sys/src/cmd/nusb/usbd/hub.c b/sys/src/cmd/nusb/usbd/hub.c
index d18760318..6d64c001d 100644
--- a/sys/src/cmd/nusb/usbd/hub.c
+++ b/sys/src/cmd/nusb/usbd/hub.c
@@ -6,6 +6,7 @@
#include "fns.h"
Hub *hubs;
+QLock hublock;
static int nhubs;
static int mustdump;
static int pollms = Pollms;
@@ -676,6 +677,7 @@ work(void)
* have to poll the root hub(s) in any case.
*/
for(;;){
+ qlock(&hublock);
Again:
for(h = hubs; h != nil; h = h->next)
for(i = 1; i <= h->nport; i++)
@@ -683,6 +685,7 @@ Again:
/* changes in hub list; repeat */
goto Again;
}
+ qunlock(&hublock);
sleep(pollms);
if(mustdump)
dump();
diff --git a/sys/src/cmd/nusb/usbd/usbd.c b/sys/src/cmd/nusb/usbd/usbd.c
index 1217bcdf5..79990e233 100644
--- a/sys/src/cmd/nusb/usbd/usbd.c
+++ b/sys/src/cmd/nusb/usbd/usbd.c
@@ -239,12 +239,16 @@ enumerate(Event **l)
static void
usbdopen(Req *req)
{
+ extern QLock hublock;
+
if(req->fid->qid.path == Qusbevent){
+ qlock(&hublock);
qlock(&evlock);
enumerate(&req->fid->aux);
((Event *)req->fid->aux)->ref++;
((Event *)req->fid->aux)->prev--;
qunlock(&evlock);
+ qunlock(&hublock);
}
respond(req, nil);
}
@@ -307,6 +311,8 @@ startdev(Port *p)
fprint(2, "okay what?\n");
return -1;
}
+ close(d->dfd);
+ d->dfd = -1;
pushevent(formatdev(d));
return 0;
}