From 338650f9339903c8eab373c16408b6d5a6f910ef Mon Sep 17 00:00:00 2001 From: Shaun Ruffell Date: Fri, 6 Nov 2009 16:15:33 +0000 Subject: dahdi.init: Unload the dahdi_echocan modules last. If the echocan factory is associated with a channel, the reference on the echocan module will not be released until after the board driver is unloaded. git-svn-id: http://svn.asterisk.org/svn/dahdi/tools/trunk@7494 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- dahdi.init | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/dahdi.init b/dahdi.init index 297fb6d..7fb16cc 100755 --- a/dahdi.init +++ b/dahdi.init @@ -74,14 +74,26 @@ unload_module() { set -- $line # $1: the original module, $2: size, $3: refcount, $4: deps list mods=`echo $4 | tr , ' '` + ec_modules="" # xpp_usb keeps the xpds below busy if an xpp hardware is # connected. Hence must be removed before them: case "$module" in xpd_*) mods="xpp_usb $mods";; esac for mod in $mods; do - # run in a subshell, so it won't step over our vars: + (echo $mod | grep dahdi_echocan) > /dev/null 2>&1 + if [ $? != 0 ]; then + # run in a subshell, so it won't step over our vars: + (unload_module $mod) + else + ec_modules="$mod $ec_modules" + fi + # TODO: the following is probably the error handling we want: + # if [ $? != 0 ]; then return 1; fi + done + # Now that all the other dependencies are unloaded, we can unload the + # dahdi_echocan modules. The drivers that register spans may keep + # references on the echocan modules before they are unloaded. + for mod in $ec_modules; do (unload_module $mod) - # TODO: the following is probably the error handling we want: - # if [ $? != 0 ]; then return 1; fi done rmmod $module } -- cgit v1.2.3