[asterisk-commits] russell: branch 1.6.2 r268147 - in /branches/1.6.2: ./ res/res_smdi.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jun 4 16:21:15 CDT 2010


Author: russell
Date: Fri Jun  4 16:21:10 2010
New Revision: 268147

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=268147
Log:
Merged revisions 266735 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
  r266735 | tilghman | 2010-06-01 13:02:24 -0500 (Tue, 01 Jun 2010) | 7 lines
  
  Don't register functions until the last possible point, so they're not unloaded unnecessarily.
  
  (closes issue #15996)
   Reported by: junky
   Patches: 
         sdmi_wait.diff uploaded by junky (license 177)
........

Modified:
    branches/1.6.2/   (props changed)
    branches/1.6.2/res/res_smdi.c

Propchange: branches/1.6.2/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.2/res/res_smdi.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.2/res/res_smdi.c?view=diff&rev=268147&r1=268146&r2=268147
==============================================================================
--- branches/1.6.2/res/res_smdi.c (original)
+++ branches/1.6.2/res/res_smdi.c Fri Jun  4 16:21:10 2010
@@ -1335,37 +1335,37 @@
 	.read = smdi_msg_read,
 };
 
-static int unload_module(void);
+static int _unload_module(int fromload);
 
 static int load_module(void)
 {
 	int res;
-	
+
 	/* initialize our containers */
 	memset(&smdi_ifaces, 0, sizeof(smdi_ifaces));
 	ASTOBJ_CONTAINER_INIT(&smdi_ifaces);
-	
+
 	ast_mutex_init(&mwi_monitor.lock);
 	ast_cond_init(&mwi_monitor.cond, NULL);
-
-	ast_custom_function_register(&smdi_msg_retrieve_function);
-	ast_custom_function_register(&smdi_msg_function);
 
 	/* load the config and start the listener threads*/
 	res = smdi_load(0);
 	if (res < 0) {
-		unload_module();
+		_unload_module(1);
 		return res;
 	} else if (res == 1) {
-		unload_module();
+		_unload_module(1);
 		ast_log(LOG_NOTICE, "No SMDI interfaces are available to listen on, not starting SMDI listener.\n");
 		return AST_MODULE_LOAD_DECLINE;
 	}
-	
+
+	ast_custom_function_register(&smdi_msg_retrieve_function);
+	ast_custom_function_register(&smdi_msg_function);
+
 	return AST_MODULE_LOAD_SUCCESS;
 }
 
-static int unload_module(void)
+static int _unload_module(int fromload)
 {
 	/* this destructor stops any running smdi_read threads */
 	ASTOBJ_CONTAINER_DESTROYALL(&smdi_ifaces, ast_smdi_interface_destroy);
@@ -1382,10 +1382,17 @@
 		pthread_join(mwi_monitor.thread, NULL);
 	}
 
-	ast_custom_function_unregister(&smdi_msg_retrieve_function);
-	ast_custom_function_unregister(&smdi_msg_function);
+	if (!fromload) {
+		ast_custom_function_unregister(&smdi_msg_retrieve_function);
+		ast_custom_function_unregister(&smdi_msg_function);
+	}
 
 	return 0;
+}
+
+static int unload_module(void)
+{
+	return _unload_module(0);
 }
 
 static int reload(void)




More information about the asterisk-commits mailing list