diff options
author | cinap_lenrek <cinap_lenrek@flatbox.9hal> | 2012-03-09 07:55:01 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@flatbox.9hal> | 2012-03-09 07:55:01 +0100 |
commit | 9b0fc40aee38cd7c8c21f28803fc25af0cc64db4 (patch) | |
tree | dfb380571c9d891667fbec1dd797f76e45133aaa /sys/src | |
parent | bc5ef91bc237bfd125ee44faf6af6203ee2c5407 (diff) |
nusbd: properly terminate worker proc if no hubs can be found
Diffstat (limited to 'sys/src')
-rw-r--r-- | sys/src/cmd/nusb/usbd/hub.c | 4 | ||||
-rw-r--r-- | sys/src/cmd/nusb/usbd/usbd.c | 11 |
2 files changed, 11 insertions, 4 deletions
diff --git a/sys/src/cmd/nusb/usbd/hub.c b/sys/src/cmd/nusb/usbd/hub.c index c23ac0da1..29b1c95af 100644 --- a/sys/src/cmd/nusb/usbd/hub.c +++ b/sys/src/cmd/nusb/usbd/hub.c @@ -668,6 +668,10 @@ work(void) fprint(2, "%s: %s: newhub failed: %r\n", argv0, fn); free(fn); } + + if(hubs == nil) + return; + /* * Enumerate (and acknowledge after first enumeration). * Do NOT perform enumeration concurrently for the same diff --git a/sys/src/cmd/nusb/usbd/usbd.c b/sys/src/cmd/nusb/usbd/usbd.c index ef10145c0..2e96df07f 100644 --- a/sys/src/cmd/nusb/usbd/usbd.c +++ b/sys/src/cmd/nusb/usbd/usbd.c @@ -358,18 +358,21 @@ main(int argc, char **argv) initevent(); rfork(RFNOTEG); - switch(rfork(RFPROC|RFMEM)){ + switch(rfork(RFPROC|RFMEM|RFNOWAIT)){ case -1: sysfatal("rfork: %r"); case 0: work(); exits(nil); } if(argc == 0){ - fd = open("/dev/usb", OREAD); - if(fd < 0) + if((fd = open("/dev/usb", OREAD)) < 0){ + rendezvous(work, nil); sysfatal("/dev/usb: %r"); + } nd = dirreadall(fd, &d); close(fd); - if(nd < 2) + if(nd < 2){ + rendezvous(work, nil); sysfatal("/dev/usb: no hubs"); + } for(i = 0; i < nd; i++) if(strcmp(d[i].name, "ctl") != 0) rendezvous(work, smprint("/dev/usb/%s", d[i].name)); |