[dahdi-commits] dahdi/tools.git branch "master" updated.

SVN commits to the DAHDI project dahdi-commits at lists.digium.com
Sat Nov 8 10:05:17 CST 2014


branch "master" has been updated
       via  631d32680fe1dbb257916ee3a0cb2baea3062c19 (commit)
       via  44fe560f3be4993339918a71a81fc50e52c2731a (commit)
       via  1a78b71fac5d27b24781fa0bee0e40d02108ff92 (commit)
       via  f11b93765902777e011f4e667fd048bbcf1fd92e (commit)
       via  cd6083b6ce65ea83f76aacac774e1315233c254d (commit)
       via  0eb77e626ef5d71804825d7701432ec6d68c5e6e (commit)
       via  2e1c15baa3f8696178ca63c53458ae8040a210c9 (commit)
      from  094bb2c1e80ec09e8964b5819ad62be3840efad7 (commit)

Summary of changes:
 dahdi.init                  |    8 +++
 init.conf.sample            |    1 +
 xpp/astribank_hook          |  113 +++++++++++++++++++++++++++++++++++--------
 xpp/astribank_is_starting.c |    2 +
 xpp/waitfor_xpds            |   14 +++---
 5 files changed, 109 insertions(+), 29 deletions(-)


- Log -----------------------------------------------------------------
commit 631d32680fe1dbb257916ee3a0cb2baea3062c19
Author: Oron Peled <oron.peled at xorcom.com>
Date:   Tue Oct 28 13:56:10 2014 -0400

    xpp: waitfor_xpds: Always remove Astribank semaphore
    
    If we waited -- no Astribanks are "in initialization"
    
    Signed-off-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>

diff --git a/xpp/waitfor_xpds b/xpp/waitfor_xpds
index 2d08013..fa7ab4f 100755
--- a/xpp/waitfor_xpds
+++ b/xpp/waitfor_xpds
@@ -154,7 +154,6 @@ if [ "$XPP_HOTPLUG_DAHDI" = yes ]; then
 		echo -n 1>&2 "Other DAHDI initializations... "
 		astribank_is_starting -v -w 1>&2
 	fi
-else
-	# Non-hotplug -- Sequential initialization, remove semaphore
-	astribank_is_starting -v -r 1>&2
 fi
+# All Astribanks initialized -- remove semaphore
+astribank_is_starting -v -r 1>&2

commit 44fe560f3be4993339918a71a81fc50e52c2731a
Author: Oron Peled <oron.peled at xorcom.com>
Date:   Tue Oct 28 13:43:48 2014 -0400

    xpp/astribank_hook: remove Astribank initialization
    
    If this is the last seen Astribank
    
    Signed-off-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>

diff --git a/xpp/astribank_hook b/xpp/astribank_hook
index 59c79ea..05d1c17 100755
--- a/xpp/astribank_hook
+++ b/xpp/astribank_hook
@@ -172,6 +172,13 @@ old_synchronous_stop() {
 	fi
 }
 
+ab_list() {
+	find /sys/devices -name idVendor 2>/dev/null | \
+		xargs grep -H  'e4e4' 2>/dev/null | \
+		sed -e 's/idVendor.*/idProduct/' | xargs grep -H '11[3456]' | \
+		sed 's,/[^/]*$,,' || :
+}
+
 tws_watchdog_enable() {
 	devdir="/sys$DEVPATH"
 	label=`cat "$devdir/label"`
@@ -197,6 +204,11 @@ case "$ACTION" in
 add)
 	;;
 remove)
+	ab=`ab_list | wc -l`
+	if [ "$ab" -eq 0 ]; then
+		$LOGGER "$prefix: No more Astribanks -- remove astribank_is_starting semaphore"
+		astribank_is_starting -v -r 2>&1 | $LOGGER
+	fi
 	;;
 online)
 	if can_full_async; then

commit 1a78b71fac5d27b24781fa0bee0e40d02108ff92
Author: Oron Peled <oron.peled at xorcom.com>
Date:   Tue Oct 28 13:50:30 2014 -0400

    xpp: waitfor_xpds: documentation
    
    Signed-off-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>

diff --git a/xpp/waitfor_xpds b/xpp/waitfor_xpds
index 4f60f5d..2d08013 100755
--- a/xpp/waitfor_xpds
+++ b/xpp/waitfor_xpds
@@ -95,10 +95,12 @@ if ! dahdi_hardware="`which dahdi_hardware 2>/dev/null`"; then
 	exit 0
 fi
 
+# Just make sure
 if [ "`$dahdi_hardware | grep xpp_usb`" != "" ]; then
 	astribank_is_starting -v -a
 fi
 if ! astribank_is_starting; then
+	# No Astribanks ever seen -- nothing to do
 	exit 0
 fi
 

commit f11b93765902777e011f4e667fd048bbcf1fd92e
Author: Oron Peled <oron.peled at xorcom.com>
Date:   Wed Oct 22 15:02:58 2014 -0400

    xpp: can use modern Asterisk hotplug support
    
    * New asynchronous behavior is used only when two conditions are met:
      - Finding new $ASTERISK_SUPPORTS_DAHDI_HOTPLUG=yes in /etc/dahdi/init.conf
        This should be set only when Asterisk support hotplug and configured
        to use it (no_failed_channels==1).
      - DAHDI auto_assign_spans==0
    
    * Adapt /usr/share/dahdi/astribank_hook:
      - Refactor old twinstar behavior into functions
      - Add new behavior in a function (just enable the Asrribank watchdog)
      - Call the correct function.
    
    * Adapt init script:
      If asynchronous behavior is on, don't wait for all Astribanks to
      finish initialization (it's enough that we saw all/some of them)
    
    Signed-off-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
    Acked-by: Russ Meyerriecks <rmeyerriecks at digium.com>

diff --git a/dahdi.init b/dahdi.init
index 2b77fd3..68420c7 100755
--- a/dahdi.init
+++ b/dahdi.init
@@ -144,6 +144,14 @@ hotplug_exit_after_load() {
 
 # Initialize the Xorcom Astribank (xpp/) using perl utiliites:
 xpp_startup() {
+	if [ "$ASTERISK_SUPPORTS_DAHDI_HOTPLUG" = yes ]; then
+		aas_param='/sys/module/dahdi/parameters/auto_assign_spans'
+		aas=`cat "$aas_param" 2>/dev/null`
+		if [ "$aas" = 0 ]; then
+			echo 1>&2 "Don't wait for Astribanks (use Asterisk hotplug-support)"
+			return 0
+		fi
+	fi
 	# do nothing if there are no astribank devices:
 	if ! /usr/share/dahdi/waitfor_xpds; then return 0; fi
 
diff --git a/init.conf.sample b/init.conf.sample
index e431f1a..6bbb199 100644
--- a/init.conf.sample
+++ b/init.conf.sample
@@ -17,6 +17,7 @@
 #XPP_FIRMWARE_DIR=/usr/share/dahdi
 #XPP_HOTPLUG_DISABLED=yes
 #XPP_HOTPLUG_DAHDI=yes
+#ASTERISK_SUPPORTS_DAHDI_HOTPLUG=yes
 
 # Disable udev handling:
 #DAHDI_UDEV_DISABLE_DEVICES=yes
diff --git a/xpp/astribank_hook b/xpp/astribank_hook
index 0888733..59c79ea 100755
--- a/xpp/astribank_hook
+++ b/xpp/astribank_hook
@@ -16,6 +16,8 @@ PATH="$dir:/usr/sbin:/sbin:/usr/bin:/bin"
 
 set -e
 
+LOCK="/var/lock/twinstar_startup"
+
 [ -r /etc/dahdi/init.conf ] && . /etc/dahdi/init.conf
 
 # For lab testing
@@ -32,17 +34,38 @@ if [ "$XPP_HOTPLUG_DAHDI" != yes ]; then
 fi
 
 export XPPORDER_CONF="$dahdi_conf/xpp_order"
-if [ ! -r "$XPPORDER_CONF" ]; then
-	(
-		echo "Skip($ACTION): No '$XPPORDER_CONF'"
-		echo "Removing uneeded startup semaphore"
-		astribank_is_starting -v -r 2>&1
-	) 2>&1 | $LOGGER
-	exit 0
-fi
 export DAHDI_CFG_CMD="dahdi_cfg -c $dahdi_conf/system.conf"
 export CALLED_FROM_ATRIBANK_HOOK=yes
 
+can_full_async() {
+	# Can we work aynchronously:
+	#    - Need modern Asterisk that accept hotplug DAHDI devices.
+	#    - Need DAHDI with "auto_assign_spans" == 0
+	if [ "$ASTERISK_SUPPORTS_DAHDI_HOTPLUG" = yes ]; then
+		aas_param='/sys/module/dahdi/parameters/auto_assign_spans'
+		aas=`cat "$aas_param" 2>/dev/null`
+		if [ "$aas" = 0 ]; then
+			return 0
+		else
+			$LOGGER "No async operation ($aas_param != 0)"
+		fi
+	else
+		$LOGGER "No async operation (ASTERISK_SUPPORTS_DAHDI_HOTPLUG!=yes)"
+	fi
+	return 1
+}
+
+check_xpporder_conf() {
+	if [ ! -r "$XPPORDER_CONF" ]; then
+		(
+			echo "Skip($ACTION): No '$XPPORDER_CONF'"
+			echo "Removing uneeded startup semaphore"
+			astribank_is_starting -v -r 2>&1
+		) 2>&1 | $LOGGER
+		exit 0
+	fi
+}
+
 clean_lines() {
 	sed -e 's/#.*//' -e 'y/\t/ /' -e 's/^ *//' -e 's/ *$//' -e '$s/$/\n/' "$XPPORDER_CONF"
 }
@@ -64,10 +87,6 @@ matched_devices() {
 	done
 }
 
-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.
@@ -110,13 +129,9 @@ start_dahdi() {
 	rm -f "$LOCK"
 }
 
-#echo "$0: $ACTION($XBUS_NAME)" | $LOGGER
-case "$ACTION" in
-add)
-	;;
-remove)
-	;;
-online)
+old_synchronous_start() {
+	NUM_GOOD=`matched_devices | wc -l`
+	NUM_WANTED=`clean_lines | sed '/^$/d' | wc -l`
 	echo "$ACTION($XBUS_NAME): $NUM_GOOD/$NUM_WANTED from $XPPORDER_CONF" | $LOGGER
 	if [ "$NUM_GOOD" -eq "$NUM_WANTED" ]; then
 		(
@@ -142,8 +157,11 @@ online)
 			fi
 		) < /dev/null 2>&1 | $LOGGER &
 	fi
-	;;
-offline)
+}
+
+old_synchronous_stop() {
+	NUM_GOOD=`matched_devices | wc -l`
+	NUM_WANTED=`clean_lines | sed '/^$/d' | wc -l`
 	echo "$ACTION($XBUS_NAME): $NUM_GOOD/$NUM_WANTED from $XPPORDER_CONF" | $LOGGER
 	if [ "$NUM_GOOD" -eq 0 ]; then
 		echo "All Astribanks offline" | $LOGGER
@@ -152,6 +170,47 @@ offline)
 		fi
 		rm -f "$LOCK"
 	fi
+}
+
+tws_watchdog_enable() {
+	devdir="/sys$DEVPATH"
+	label=`cat "$devdir/label"`
+	connector=`cat "$devdir/connector"`
+	xbus=`echo "$devdir" | sed 's,.*/,,'`
+	prefix="${xbus}: [${label}] @${connector}"
+	TWS_NOAUTOJUMPFILE="$TWS_DIR/twinstar_no_autojump"
+	if [ -e "$TWS_NOAUTOJUMPFILE" ]; then
+		$LOGGER "$prefix: ignore wd (found $TWS_NOAUTOJUMPFILE)"
+	else
+		# Re-arm Astribank watchdog
+		transportdir="$devdir/transport"
+		busnum=`cat "$transportdir/busnum" 2>/dev/null || :`
+		devnum=`cat "$transportdir/devnum" 2>/dev/null || :`
+		devaddr=`printf "%03d/%03d" "$busnum" "$devnum"`
+		$LOGGER "$prefix: enabling twinstar watchdog"
+		astribank_tool -D "$devaddr" -w 1 2>&1 | $LOGGER
+	fi
+}
+
+#echo "$0: $ACTION($XBUS_NAME)" | $LOGGER
+case "$ACTION" in
+add)
+	;;
+remove)
+	;;
+online)
+	if can_full_async; then
+		tws_watchdog_enable
+	else
+		old_synchronous_start
+	fi
+	;;
+offline)
+	if can_full_async; then
+		:	# Nothing to do
+	else
+		old_synchronous_stop
+	fi
 	;;
 *)
 	echo "$0: Unknown ACTION='$ACTION'" | $LOGGER

commit cd6083b6ce65ea83f76aacac774e1315233c254d
Author: Oron Peled <oron.peled at xorcom.com>
Date:   Tue Oct 28 13:48:16 2014 -0400

    xpp: waitfor_xpds: assume astribank_is_starting exists
    
    It's in the same package (dahdi-tools) for a long time
    
    Signed-off-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>

diff --git a/xpp/waitfor_xpds b/xpp/waitfor_xpds
index 8a46a1d..4f60f5d 100755
--- a/xpp/waitfor_xpds
+++ b/xpp/waitfor_xpds
@@ -94,10 +94,7 @@ if ! dahdi_hardware="`which dahdi_hardware 2>/dev/null`"; then
 	echo >&2 "$0: Missing dahdi_hardware"
 	exit 0
 fi
-if ! astribank_is_starting="`which astribank_is_starting 2>/dev/null`"; then
-	echo >&2 "$0: Missing astribank_is_starting"
-	exit 0
-fi
+
 if [ "`$dahdi_hardware | grep xpp_usb`" != "" ]; then
 	astribank_is_starting -v -a
 fi

commit 0eb77e626ef5d71804825d7701432ec6d68c5e6e
Author: Oron Peled <oron.peled at xorcom.com>
Date:   Tue Oct 28 11:53:29 2014 -0400

    xpp: waitfor_xpds: expansion error with no ABs
    
    Fix an exansion error in case there were no Astribanks on the system.
    
    Signed-off-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>

diff --git a/xpp/waitfor_xpds b/xpp/waitfor_xpds
index 79e2806..8a46a1d 100755
--- a/xpp/waitfor_xpds
+++ b/xpp/waitfor_xpds
@@ -52,7 +52,7 @@ ab_serial_nums() {
 }
 
 detected_serial_nums() {
-	for i in /sys/bus/astribanks/devices/*/transport; do
+	for i in `ls -1d /sys/bus/astribanks/devices/*/transport 2>/dev/null`; do
 		s=`cat "$i/serial" 2>/dev/null` || :
 		if [ "$s" = '' ]; then
 			echo "NO-SERIAL"

commit 2e1c15baa3f8696178ca63c53458ae8040a210c9
Author: Oron Peled <oron.peled at xorcom.com>
Date:   Tue Oct 28 13:28:04 2014 -0400

    xpp: astribank_is_starting: improve '-v' output
    
    Do print a message if no semaphore exists. It means that either there
    are no Astribanks, or existing Astribanks were already initialized.
    
    Signed-off-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>

diff --git a/xpp/astribank_is_starting.c b/xpp/astribank_is_starting.c
index 072004f..da565c9 100644
--- a/xpp/astribank_is_starting.c
+++ b/xpp/astribank_is_starting.c
@@ -125,6 +125,8 @@ static int absem_detected(void)
 	if((absem = absem_get(0)) < 0) {
 		if(debug)
 			fprintf(stderr, "%s: absem does not exist\n", progname);
+		if(verbose)
+			printf("No Astribanks are initializing\n");
 		return absem;
 	}
 	if(debug)

-----------------------------------------------------------------------


-- 
dahdi/tools.git



More information about the dahdi-commits mailing list