summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2010-04-29 15:06:38 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2010-04-29 15:06:38 +0000
commit9425536ffa15b030dfb638ade3d757518c746f96 (patch)
tree649f7a45544bc95d000aa2639a3b7b68ea6e51a4
parent0f00a726462066b3de43a2f5eed684e63f507afc (diff)
Load xpp firmware in the background (udev)
Move loading the the xpp firmwares (when called from udev) to a background sub-process. This helps with: * Don't block udev * It seems that with older systems (e.g. CentOS 5) we need to wait a bit for the device file to appear (in one of the upcoming udev events). If we keep blocking udev, we won't have the device file. The 'sleep' does not seem to be required for newer systems (e.g. Debian Lenny). git-svn-id: http://svn.asterisk.org/svn/dahdi/tools/trunk@8580 a0bf4364-ded3-4de4-8d8a-66a801d63aff
-rw-r--r--xpp/xpp_fxloader25
1 files changed, 22 insertions, 3 deletions
diff --git a/xpp/xpp_fxloader b/xpp/xpp_fxloader
index ca70823..ef13cf4 100644
--- a/xpp/xpp_fxloader
+++ b/xpp/xpp_fxloader
@@ -67,6 +67,7 @@ USB_PREFIX=
FIRMWARE_DIR="${FIRMWARE_DIR:-/usr/share/dahdi}"
ASTRIBANK_HEXLOAD=${ASTRIBANK_HEXLOAD:-/usr/sbin/astribank_hexload}
ASTRIBANK_TOOL=${ASTRIBANK_TOOL:-/usr/sbin/astribank_tool}
+XPP_UDEV_SLEEP_TIME="${XPP_UDEV_SLEEP_TIME:-1}"
USB_FW="${USB_FW:-USB_FW.hex}"
@@ -313,8 +314,23 @@ if [ "$XPP_HOTPLUG_DISABLED" != '' ]; then
exit 0
fi
-if [ "$ACTION" = "add" ] && [ -w "$DEVICE" ]
-then
+if [ "$ACTION" != add ]; then
+ exit 0;
+fi
+
+# This procedure is run in the background to do the actual work of loading the
+# firmware. Running it in the background allows udev to continue doing other tasks
+# and thus provide a faster startup.
+#
+# On some systems (e.g. CentOS 5) we get the relevant udev event before the device
+# file is ready. Which is why we want the background process to wait a bit first.
+udev_delayed_load() {
+ # Make sure the new device is writable:
+ sleep "$XPP_UDEV_SLEEP_TIME"
+ if [ ! -w "$DEVICE" ]; then
+ return;
+ fi
+
$LOGGER "Trying to find what to do for product $PRODUCT, device $DEVICE"
prod_id=`echo "$PRODUCT" | cut -d/ -f2`
case "$PRODUCT" in
@@ -333,4 +349,7 @@ then
load_fw_device "$DEVICE" "$FIRM_FPGA"
;;
esac
-fi
+}
+
+udev_delayed_load &
+