Hi,

there is a hardcoded sleep 3 in the usb.agent. But this is wrong,
because the kernel runs all hotplug events at once for a new hub. The
result is that every event still runs in parallel, just 3 seconds later.

This patch implements an userland fifo.

touch an unique file
wait one second to let things settle
build a list with lockfiles, oldest last
grab the pid of the oldest agent
if this pid match the running agent, proceed
if all lockfiles are gone, proceed as well, provides a way to workaround
a hanging event
otherwise wait a second and try again


Index: etc/hotplug/usb.agent
===================================================================
--- etc/hotplug/usb.agent       (revision 13)
+++ etc/hotplug/usb.agent       (working copy)
@@ -367,7 +367,15 @@
     # with slow HID devices and "usbmodules".
     # starting with 2.5, all hcds must queue control traffic.
     if [ "$DEVPATH" = "" ]; then
-       sleep 3
+       touch "${REMOVER}.queue.$$"
+       until [ `sleep 1` ] ; do
+               lockfiles=`ls -t /var/run/usb/*.queue.* 2>/dev/null`
+               pid=${lockfiles##*.}
+               debug_mesg $pid $lockfiles
+               test "$pid" = "$$" && { debug_mesg pid $$ proceeds ; break; }
+               test "$lockfiles" = "" && { debug_mesg all lockfiles gone ; break; }
+               debug_mesg wait 1 second for pid $pid
+       done
     fi
 
     usb_convert_vars
@@ -426,6 +434,10 @@
         /sbin/devlabel restart
     fi
 
+    if [ -e "${REMOVER}.queue.$$" ]; then
+       debug_mesg pid $$ done
+       rm -f "${REMOVER}.queue.$$"
+    fi
     ;;
 
 remove)


-- 
USB is for mice, FireWire is for men!


-------------------------------------------------------
This SF.net email is sponsored by:  Etnus, makers of TotalView, The best
thread debugger on the planet. Designed with thread debugging features
you've never dreamed of, try TotalView 6 free at www.etnus.com.
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to