[svn-commits] tzafrir: tools/trunk r8580 - /tools/trunk/xpp/xpp_fxloader

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Apr 29 10:06:41 CDT 2010


Author: tzafrir
Date: Thu Apr 29 10:06:38 2010
New Revision: 8580

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=8580
Log:
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).

Modified:
    tools/trunk/xpp/xpp_fxloader

Modified: tools/trunk/xpp/xpp_fxloader
URL: http://svnview.digium.com/svn/dahdi/tools/trunk/xpp/xpp_fxloader?view=diff&rev=8580&r1=8579&r2=8580
==============================================================================
--- tools/trunk/xpp/xpp_fxloader (original)
+++ tools/trunk/xpp/xpp_fxloader Thu Apr 29 10:06:38 2010
@@ -67,6 +67,7 @@
 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 @@
 	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 @@
 		load_fw_device "$DEVICE" "$FIRM_FPGA"
 		;;
 	esac	
-fi
+}
+
+udev_delayed_load &
+




More information about the svn-commits mailing list