ref: ea597253dfff146087a67c5a4661d8eae94239b8
parent: 1b75c86846e8881e7188e8ebb7ea40eea7d8466a
author: cinap_lenrek <cinap_lenrek@flatbox.9hal>
date: Fri Mar 9 02:55:01 EST 2012
nusbd: properly terminate worker proc if no hubs can be found
--- a/sys/src/cmd/nusb/usbd/hub.c
+++ b/sys/src/cmd/nusb/usbd/hub.c
@@ -668,6 +668,10 @@
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
--- a/sys/src/cmd/nusb/usbd/usbd.c
+++ b/sys/src/cmd/nusb/usbd/usbd.c
@@ -358,18 +358,21 @@
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));--
⑨