[asterisk-commits] mjordan: branch group/media_formats-reviewed-trunk r418394 - in /team/group/m...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jul 11 14:27:45 CDT 2014


Author: mjordan
Date: Fri Jul 11 14:27:37 2014
New Revision: 418394

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=418394
Log:
media_formats: Cleanup formats container on shutdown/chan_dahdi on bad load

https://reviewboard.asterisk.org/r/3740/

Modified:
    team/group/media_formats-reviewed-trunk/channels/chan_dahdi.c
    team/group/media_formats-reviewed-trunk/main/format.c

Modified: team/group/media_formats-reviewed-trunk/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/channels/chan_dahdi.c?view=diff&rev=418394&r1=418393&r2=418394
==============================================================================
--- team/group/media_formats-reviewed-trunk/channels/chan_dahdi.c (original)
+++ team/group/media_formats-reviewed-trunk/channels/chan_dahdi.c Fri Jul 11 14:27:37 2014
@@ -19499,6 +19499,7 @@
 	ast_format_cap_append(dahdi_tech.capabilities, ast_format_alaw, 0);
 
 	if (dahdi_native_load(ast_module_info->self, &dahdi_tech)) {
+		ao2_ref(dahdi_tech.capabilities, -1);
 		return AST_MODULE_LOAD_FAILURE;
 	}
 
@@ -19544,8 +19545,10 @@
 #endif	/* defined(HAVE_SS7) */
 	res = setup_dahdi(0);
 	/* Make sure we can register our DAHDI channel type */
-	if (res)
+	if (res) {
+		__unload_module();
 		return AST_MODULE_LOAD_DECLINE;
+	}
 	if (ast_channel_register(&dahdi_tech)) {
 		ast_log(LOG_ERROR, "Unable to register channel class 'DAHDI'\n");
 		__unload_module();

Modified: team/group/media_formats-reviewed-trunk/main/format.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/main/format.c?view=diff&rev=418394&r1=418393&r2=418394
==============================================================================
--- team/group/media_formats-reviewed-trunk/main/format.c (original)
+++ team/group/media_formats-reviewed-trunk/main/format.c Fri Jul 11 14:27:37 2014
@@ -111,6 +111,13 @@
 	return CMP_MATCH;
 }
 
+/*! \brief Function called when the process is shutting down */
+static void format_shutdown(void)
+{
+	ao2_cleanup(interfaces);
+	interfaces = NULL;
+}
+
 int ast_format_init(void)
 {
 	interfaces = ao2_container_alloc_options(AO2_ALLOC_OPT_LOCK_RWLOCK, FORMAT_INTERFACE_BUCKETS, format_interface_hash,
@@ -118,6 +125,8 @@
 	if (!interfaces) {
 		return -1;
 	}
+
+	ast_register_atexit(format_shutdown);
 
 	return 0;
 }




More information about the asterisk-commits mailing list