[svn-commits] dlee: branch 12 r398149 - in /branches/12: include/asterisk/ main/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Aug 30 15:58:12 CDT 2013


Author: dlee
Date: Fri Aug 30 15:58:07 2013
New Revision: 398149

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=398149
Log:
Fix graceful shutdown crash.

The cleanup code for optional_api needs to happen after all of the optional
API users and providers have unused/unprovided. Unfortunately, regsitering the
atexit() handler at the beginning of main() isn't soon enough, since module
destructors run after that.

Modified:
    branches/12/include/asterisk/optional_api.h
    branches/12/main/asterisk.c
    branches/12/main/optional_api.c

Modified: branches/12/include/asterisk/optional_api.h
URL: http://svnview.digium.com/svn/asterisk/branches/12/include/asterisk/optional_api.h?view=diff&rev=398149&r1=398148&r2=398149
==============================================================================
--- branches/12/include/asterisk/optional_api.h (original)
+++ branches/12/include/asterisk/optional_api.h Fri Aug 30 15:58:07 2013
@@ -175,14 +175,6 @@
  */
 void ast_optional_api_unuse(const char *symname, ast_optional_fn *optional_ref,
 	const char *module);
-
-/*!
- * \brief Call at exit to clean up optional_api internals.
- *
- * Since the optional_api code might run before main() starts, it can't safely
- * register its own cleanup handlers. That has to be done within main().
- */
-void optional_api_cleanup(void);
 
 #define AST_OPTIONAL_API_NAME(name) __##name
 

Modified: branches/12/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/asterisk.c?view=diff&rev=398149&r1=398148&r2=398149
==============================================================================
--- branches/12/main/asterisk.c (original)
+++ branches/12/main/asterisk.c Fri Aug 30 15:58:07 2013
@@ -247,7 +247,6 @@
 #include "asterisk/stasis_endpoints.h"
 #include "asterisk/stasis_system.h"
 #include "asterisk/security_events.h"
-#include "asterisk/optional_api.h"
 
 #include "../defaults.h"
 
@@ -4169,10 +4168,6 @@
 			ast_el_read_history(filename);
 	}
 
-#if defined(OPTIONAL_API)
-	ast_register_cleanup(optional_api_cleanup);
-#endif
-
 	ast_json_init();
 	ast_ulaw_init();
 	ast_alaw_init();

Modified: branches/12/main/optional_api.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/optional_api.c?view=diff&rev=398149&r1=398148&r2=398149
==============================================================================
--- branches/12/main/optional_api.c (original)
+++ branches/12/main/optional_api.c Fri Aug 30 15:58:07 2013
@@ -158,18 +158,8 @@
 	size_t len;
 } apis;
 
-void optional_api_cleanup(void)
-{
-	while (apis.len--) {
-		optional_api_destroy(apis.list[apis.len]);
-	}
-	free(apis.list);
-	apis.list = NULL;
-	apis.maxlen = 0;
-}
-
-/*!
- * \brief Gets (or creates) the \ref optional_api for the give function.
+/*!
+ * \brief Gets (or creates) the \ref optional_api for the given function.
  *
  * \param sysname Name of the function to look up.
  * \return Corresponding \ref optional_api.
@@ -181,9 +171,11 @@
 	size_t i;
 
 	/* Find one, if we already have it */
-	for (i = 0; i < apis.len; ++i) {
-		if (strcmp(symname, apis.list[i]->symname) == 0) {
-			return apis.list[i];
+	if (apis.list) {
+		for (i = 0; i < apis.len; ++i) {
+			if (strcmp(symname, apis.list[i]->symname) == 0) {
+				return apis.list[i];
+			}
 		}
 	}
 




More information about the svn-commits mailing list