summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2010-05-15 21:24:19 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2010-05-15 21:24:19 +0000
commitfe4c2fa585e02e9eaa352de0bd297967fd351cd9 (patch)
tree85ce88ab525de7cdd1e595329bab779ecbb87b23
parentd723f59c3ce89196f19e47476f405e857c25e10e (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. Merged revisions 8580 via svnmerge from http://svn.digium.com/svn/dahdi/tools/trunk git-svn-id: http://svn.asterisk.org/svn/dahdi/tools/branches/2.3@8624 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 3ce1d8f..943adcd 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 &
+