summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2012-03-22 17:38:57 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2012-03-22 17:38:57 +0000
commit6ea852769e7d5d47c01d36f8f7cecb13ecb7d6a9 (patch)
treed3de1b9a945f289717441a7da8954f24d9ead672
parent90122d756dae65c2ff4bb5d102d096916bb6c90a (diff)
xpp: astribank_hook: wait for udev to settle
When running the astribank_hook (only on Astribanks, in XPP_HOTPLUG_DAHDI mode), wait for all other Astribanks to create all the required device files. Signed-off-by: Oron Peled <oron.peled@xorcom.com> Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com> git-svn-id: http://svn.asterisk.org/svn/dahdi/tools/trunk@10585 a0bf4364-ded3-4de4-8d8a-66a801d63aff
-rwxr-xr-xxpp/astribank_hook27
1 files changed, 27 insertions, 0 deletions
diff --git a/xpp/astribank_hook b/xpp/astribank_hook
index 074ea31..0888733 100755
--- a/xpp/astribank_hook
+++ b/xpp/astribank_hook
@@ -68,7 +68,34 @@ NUM_WANTED=`clean_lines | sed '/^$/d' | wc -l`
NUM_GOOD=`matched_devices | wc -l`
LOCK="/var/lock/twinstar_startup"
+# Wait until udev finished processing our requests
+# so we know the device files were actually created
+# before trying dahdi_cfg et-al.
+wait_for_udev() {
+ UDEV_SETTLE_MAX_TIME=10
+
+ echo "Waiting for udev to settle down..."
+ if [ -x /sbin/udevsettle ]; then
+ # Old system, stand-alone udevsettle command
+ time /sbin/udevsettle --timeout="$UDEV_SETTLE_MAX_TIME"
+ elif [ -x /sbin/udevadm ]; then
+ # Assume modern system, udevadm has settle parameter
+ if ! time /sbin/udevadm settle --timeout="$UDEV_SETTLE_MAX_TIME"
+ then
+ echo "udevadm failed ($?)."
+ echo "Fallback to sleep $UDEV_SETTLE_MAX_TIME seconds."
+ sleep "$UDEV_SETTLE_MAX_TIME"
+ fi
+ else
+ echo "No udevsettle/udevadm."
+ echo "Fallback to sleep $UDEV_SETTLE_MAX_TIME seconds."
+ sleep "$UDEV_SETTLE_MAX_TIME"
+ fi
+ sleep 1 # Wait a bit more (races)
+}
+
start_dahdi() {
+ wait_for_udev
script=/etc/init.d/dahdi
echo "Starting $script."
"$script" start | logger -i -t "$script"