nusb: more locking, also close dfd
This commit is contained in:
parent
61d322679b
commit
7f27b397ca
2 changed files with 9 additions and 0 deletions
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue