[asterisk-commits] coreyfarrell: branch 11 r433495 - in /branches/11: include/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Mar 26 17:16:44 CDT 2015


Author: coreyfarrell
Date: Thu Mar 26 17:16:31 2015
New Revision: 433495

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=433495
Log:
Replace most uses of ast_register_atexit with ast_register_cleanup.

Since 'core stop now' and 'core restart now' do not stop modules,
it is unsafe for most of the core to run cleanups.  Originally all
cleanups used ast_register_atexit, and were only changed when it
was shown to be unsafe.  ast_register_atexit is now used only when
absolutely required to prevent corruption and close child processes.

Exceptions that need to use ast_register_atexit:
* CDR: Flush records.
* res_musiconhold: Kill external applications.
* AstDB: Close the DB.
* canary_exit: Kill canary process.

ASTERISK-24142 #close
Reported by: David Brillert

ASTERISK-24683 #close
Reported by: Peter Katzmann

ASTERISK-24805 #close
Reported by: Badalian Vyacheslav

ASTERISK-24881 #close
Reported by: Corey Farrell

Review: https://reviewboard.asterisk.org/r/4500/
Review: https://reviewboard.asterisk.org/r/4501/

Modified:
    branches/11/include/asterisk.h
    branches/11/main/aoc.c
    branches/11/main/asterisk.c
    branches/11/main/astfd.c
    branches/11/main/astmm.c
    branches/11/main/astobj2.c
    branches/11/main/ccss.c
    branches/11/main/cel.c
    branches/11/main/channel.c
    branches/11/main/cli.c
    branches/11/main/config.c
    branches/11/main/data.c
    branches/11/main/dnsmgr.c
    branches/11/main/event.c
    branches/11/main/features.c
    branches/11/main/file.c
    branches/11/main/format.c
    branches/11/main/http.c
    branches/11/main/image.c
    branches/11/main/indications.c
    branches/11/main/manager.c
    branches/11/main/message.c
    branches/11/main/named_acl.c
    branches/11/main/pbx.c
    branches/11/main/stun.c
    branches/11/main/taskprocessor.c
    branches/11/main/test.c
    branches/11/main/threadstorage.c
    branches/11/main/timing.c
    branches/11/main/translate.c
    branches/11/main/udptl.c
    branches/11/main/utils.c
    branches/11/main/xmldoc.c

Modified: branches/11/include/asterisk.h
URL: http://svnview.digium.com/svn/asterisk/branches/11/include/asterisk.h?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/include/asterisk.h (original)
+++ branches/11/include/asterisk.h Thu Mar 26 17:16:31 2015
@@ -86,6 +86,11 @@
  *
  * \retval 0 on success.
  * \retval -1 on error.
+ *
+ * \note This function should be rarely used in situations where
+ * something must be shutdown to avoid corruption, excessive data
+ * loss, or when external programs must be stopped.  All other
+ * cleanup in the core should use ast_register_cleanup.
  */
 int ast_register_atexit(void (*func)(void));
 

Modified: branches/11/main/aoc.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/aoc.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/aoc.c (original)
+++ branches/11/main/aoc.c Thu Mar 26 17:16:31 2015
@@ -1611,6 +1611,6 @@
 }
 int ast_aoc_cli_init(void)
 {
-	ast_register_atexit(aoc_shutdown);
+	ast_register_cleanup(aoc_shutdown);
 	return ast_cli_register_multiple(aoc_cli, ARRAY_LEN(aoc_cli));
 }

Modified: branches/11/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/asterisk.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/asterisk.c (original)
+++ branches/11/main/asterisk.c Thu Mar 26 17:16:31 2015
@@ -4374,7 +4374,7 @@
 	ast_lastreloadtime = ast_startuptime = ast_tvnow();
 	ast_cli_register_multiple(cli_asterisk_shutdown, ARRAY_LEN(cli_asterisk_shutdown));
 	ast_cli_register_multiple(cli_asterisk, ARRAY_LEN(cli_asterisk));
-	ast_register_atexit(main_atexit);
+	ast_register_cleanup(main_atexit);
 
 	run_startup_commands();
 

Modified: branches/11/main/astfd.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/astfd.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/astfd.c (original)
+++ branches/11/main/astfd.c Thu Mar 26 17:16:31 2015
@@ -281,7 +281,7 @@
 
 int ast_fd_init(void)
 {
-	ast_register_atexit(fd_shutdown);
+	ast_register_cleanup(fd_shutdown);
 	return ast_cli_register(&cli_show_fd);
 }
 

Modified: branches/11/main/astmm.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/astmm.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/astmm.c (original)
+++ branches/11/main/astmm.c Thu Mar 26 17:16:31 2015
@@ -1429,7 +1429,7 @@
 		ast_log(LOG_ERROR, "Could not open malloc debug log file: %s\n", filename);
 	}
 
-	ast_register_atexit(mm_atexit_ast);
+	ast_register_cleanup(mm_atexit_ast);
 }
 
 #endif	/* defined(__AST_DEBUG_MALLOC) */

Modified: branches/11/main/astobj2.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/astobj2.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/astobj2.c (original)
+++ branches/11/main/astobj2.c Thu Mar 26 17:16:31 2015
@@ -1748,7 +1748,7 @@
 	ast_cli_register_multiple(cli_astobj2, ARRAY_LEN(cli_astobj2));
 #endif
 
-	ast_register_atexit(astobj2_cleanup);
+	ast_register_cleanup(astobj2_cleanup);
 
 	return 0;
 }

Modified: branches/11/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/ccss.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/ccss.c (original)
+++ branches/11/main/ccss.c Thu Mar 26 17:16:31 2015
@@ -4583,7 +4583,7 @@
 	initialize_cc_devstate_map();
 	res |= ast_devstate_prov_add("ccss", ccss_device_state);
 
-	ast_register_atexit(cc_shutdown);
+	ast_register_cleanup(cc_shutdown);
 
 	return res;
 }

Modified: branches/11/main/cel.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/cel.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/cel.c (original)
+++ branches/11/main/cel.c Thu Mar 26 17:16:31 2015
@@ -892,7 +892,7 @@
 		return -1;
 	}
 
-	ast_register_atexit(ast_cel_engine_term);
+	ast_register_cleanup(ast_cel_engine_term);
 
 	return 0;
 }

Modified: branches/11/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/channel.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/channel.c (original)
+++ branches/11/main/channel.c Thu Mar 26 17:16:31 2015
@@ -8666,7 +8666,7 @@
 
 	ast_plc_reload();
 
-	ast_register_atexit(channels_shutdown);
+	ast_register_cleanup(channels_shutdown);
 }
 
 /*! \brief Print call group and pickup group ---*/

Modified: branches/11/main/cli.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/cli.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/cli.c (original)
+++ branches/11/main/cli.c Thu Mar 26 17:16:31 2015
@@ -2000,7 +2000,7 @@
 void ast_builtins_init(void)
 {
 	ast_cli_register_multiple(cli_cli, ARRAY_LEN(cli_cli));
-	ast_register_atexit(cli_shutdown);
+	ast_register_cleanup(cli_shutdown);
 }
 
 /*!

Modified: branches/11/main/config.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/config.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/config.c (original)
+++ branches/11/main/config.c Thu Mar 26 17:16:31 2015
@@ -3368,7 +3368,7 @@
 int register_config_cli(void)
 {
 	ast_cli_register_multiple(cli_config, ARRAY_LEN(cli_config));
-	ast_register_atexit(config_shutdown);
+	ast_register_cleanup(config_shutdown);
 	return 0;
 }
 

Modified: branches/11/main/data.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/data.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/data.c (original)
+++ branches/11/main/data.c Thu Mar 26 17:16:31 2015
@@ -3343,7 +3343,7 @@
 
 	AST_TEST_REGISTER(test_data_get);
 
-	ast_register_atexit(data_shutdown);
+	ast_register_cleanup(data_shutdown);
 
 	return res;
 }

Modified: branches/11/main/dnsmgr.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/dnsmgr.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/dnsmgr.c (original)
+++ branches/11/main/dnsmgr.c Thu Mar 26 17:16:31 2015
@@ -427,7 +427,7 @@
 	ast_cli_register(&cli_status);
 	ast_cli_register(&cli_refresh);
 
-	ast_register_atexit(dnsmgr_shutdown);
+	ast_register_cleanup(dnsmgr_shutdown);
 
 	return do_reload(1);
 }

Modified: branches/11/main/event.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/event.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/event.c (original)
+++ branches/11/main/event.c Thu Mar 26 17:16:31 2015
@@ -1882,7 +1882,7 @@
 
 	ast_cli_register_multiple(event_cli, ARRAY_LEN(event_cli));
 
-	ast_register_atexit(event_shutdown);
+	ast_register_cleanup(event_shutdown);
 
 	return 0;
 

Modified: branches/11/main/features.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/features.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/features.c (original)
+++ branches/11/main/features.c Thu Mar 26 17:16:31 2015
@@ -9108,7 +9108,7 @@
 	res |= AST_TEST_REGISTER(features_test);
 #endif	/* defined(TEST_FRAMEWORK) */
 
-	ast_register_atexit(features_shutdown);
+	ast_register_cleanup(features_shutdown);
 
 	return res;
 }

Modified: branches/11/main/file.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/file.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/file.c (original)
+++ branches/11/main/file.c Thu Mar 26 17:16:31 2015
@@ -1594,6 +1594,6 @@
 int ast_file_init(void)
 {
 	ast_cli_register_multiple(cli_file, ARRAY_LEN(cli_file));
-	ast_register_atexit(file_shutdown);
+	ast_register_cleanup(file_shutdown);
 	return 0;
 }

Modified: branches/11/main/format.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/format.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/format.c (original)
+++ branches/11/main/format.c Thu Mar 26 17:16:31 2015
@@ -1113,7 +1113,7 @@
 		goto init_list_cleanup;
 	}
 
-	ast_register_atexit(format_list_shutdown);
+	ast_register_cleanup(format_list_shutdown);
 	return 0;
 init_list_cleanup:
 

Modified: branches/11/main/http.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/http.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/http.c (original)
+++ branches/11/main/http.c Thu Mar 26 17:16:31 2015
@@ -1312,7 +1312,7 @@
 	ast_http_uri_link(&statusuri);
 	ast_http_uri_link(&staticuri);
 	ast_cli_register_multiple(cli_http, ARRAY_LEN(cli_http));
-	ast_register_atexit(http_shutdown);
+	ast_register_cleanup(http_shutdown);
 
 	return __ast_http_load(0);
 }

Modified: branches/11/main/image.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/image.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/image.c (original)
+++ branches/11/main/image.c Thu Mar 26 17:16:31 2015
@@ -214,6 +214,6 @@
 int ast_image_init(void)
 {
 	ast_cli_register_multiple(cli_image, ARRAY_LEN(cli_image));
-	ast_register_atexit(image_shutdown);
+	ast_register_cleanup(image_shutdown);
 	return 0;
 }

Modified: branches/11/main/indications.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/indications.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/indications.c (original)
+++ branches/11/main/indications.c Thu Mar 26 17:16:31 2015
@@ -1184,7 +1184,7 @@
 
 	ast_cli_register_multiple(cli_indications, ARRAY_LEN(cli_indications));
 
-	ast_register_atexit(indications_shutdown);
+	ast_register_cleanup(indications_shutdown);
 	return 0;
 }
 

Modified: branches/11/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/manager.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/manager.c (original)
+++ branches/11/main/manager.c Thu Mar 26 17:16:31 2015
@@ -7635,7 +7635,7 @@
 		struct ao2_container *temp_event_docs;
 #endif
 
-		ast_register_atexit(manager_shutdown);
+		ast_register_cleanup(manager_shutdown);
 
 		/* Register default actions */
 		ast_manager_register_xml_core("Ping", 0, action_ping);

Modified: branches/11/main/message.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/message.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/message.c (original)
+++ branches/11/main/message.c Thu Mar 26 17:16:31 2015
@@ -1379,7 +1379,7 @@
 	res |= ast_register_application2(app_msg_send, msg_send_exec, NULL, NULL, NULL);
 	res |= ast_manager_register_xml_core("MessageSend", EVENT_FLAG_MESSAGE, action_messagesend);
 
-	ast_register_atexit(message_shutdown);
+	ast_register_cleanup(message_shutdown);
 
 	return res;
 }

Modified: branches/11/main/named_acl.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/named_acl.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/named_acl.c (original)
+++ branches/11/main/named_acl.c Thu Mar 26 17:16:31 2015
@@ -567,7 +567,7 @@
 {
 	ast_cli_register_multiple(cli_named_acl, ARRAY_LEN(cli_named_acl));
 
-	ast_register_atexit(named_acl_cleanup);
+	ast_register_cleanup(named_acl_cleanup);
 
 	if (aco_info_init(&cfg_info)) {
 		return 0;

Modified: branches/11/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/pbx.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/pbx.c (original)
+++ branches/11/main/pbx.c Thu Mar 26 17:16:31 2015
@@ -12054,7 +12054,7 @@
 {
 	int x;
 
-	ast_register_atexit(unload_pbx);
+	ast_register_cleanup(unload_pbx);
 
 	/* Initialize the PBX */
 	ast_verb(1, "Asterisk PBX Core Initializing\n");
@@ -12480,7 +12480,7 @@
 	hintdevices = ao2_container_alloc(HASH_EXTENHINT_SIZE, hintdevice_hash_cb, hintdevice_cmp_multiple);
 	statecbs = ao2_container_alloc(1, NULL, statecbs_cmp);
 
-	ast_register_atexit(pbx_shutdown);
+	ast_register_cleanup(pbx_shutdown);
 
 	return (hints && hintdevices && statecbs) ? 0 : -1;
 }

Modified: branches/11/main/stun.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/stun.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/stun.c (original)
+++ branches/11/main/stun.c Thu Mar 26 17:16:31 2015
@@ -516,5 +516,5 @@
 void ast_stun_init(void)
 {
 	ast_cli_register_multiple(cli_stun, sizeof(cli_stun) / sizeof(struct ast_cli_entry));
-	ast_register_atexit(stun_shutdown);
-}
+	ast_register_cleanup(stun_shutdown);
+}

Modified: branches/11/main/taskprocessor.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/taskprocessor.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/taskprocessor.c (original)
+++ branches/11/main/taskprocessor.c Thu Mar 26 17:16:31 2015
@@ -145,7 +145,7 @@
 
 	ast_cli_register_multiple(taskprocessor_clis, ARRAY_LEN(taskprocessor_clis));
 
-	ast_register_atexit(tps_shutdown);
+	ast_register_cleanup(tps_shutdown);
 
 	return 0;
 }

Modified: branches/11/main/test.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/test.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/test.c (original)
+++ branches/11/main/test.c Thu Mar 26 17:16:31 2015
@@ -943,7 +943,7 @@
 #ifdef TEST_FRAMEWORK
 	/* Register cli commands */
 	ast_cli_register_multiple(test_cli, ARRAY_LEN(test_cli));
-	ast_register_atexit(test_shutdown);
+	ast_register_cleanup(test_shutdown);
 #endif
 
 	return 0;

Modified: branches/11/main/threadstorage.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/threadstorage.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/threadstorage.c (original)
+++ branches/11/main/threadstorage.c Thu Mar 26 17:16:31 2015
@@ -258,7 +258,7 @@
 {
 	pthread_mutex_init(&threadstoragelock, NULL);
 	ast_cli_register_multiple(cli, ARRAY_LEN(cli));
-	ast_register_atexit(threadstorage_shutdown);
+	ast_register_cleanup(threadstorage_shutdown);
 }
 
 #endif /* !defined(DEBUG_THREADLOCALS) */

Modified: branches/11/main/timing.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/timing.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/timing.c (original)
+++ branches/11/main/timing.c Thu Mar 26 17:16:31 2015
@@ -313,7 +313,7 @@
 		return -1;
 	}
 
-	ast_register_atexit(timing_shutdown);
+	ast_register_cleanup(timing_shutdown);
 
 	return ast_cli_register_multiple(cli_timing, ARRAY_LEN(cli_timing));
 }

Modified: branches/11/main/translate.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/translate.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/translate.c (original)
+++ branches/11/main/translate.c Thu Mar 26 17:16:31 2015
@@ -1420,6 +1420,6 @@
 	ast_rwlock_init(&tablelock);
 	res = matrix_resize(1);
 	res |= ast_cli_register_multiple(cli_translate, ARRAY_LEN(cli_translate));
-	ast_register_atexit(translate_shutdown);
+	ast_register_cleanup(translate_shutdown);
 	return res;
 }

Modified: branches/11/main/udptl.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/udptl.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/udptl.c (original)
+++ branches/11/main/udptl.c Thu Mar 26 17:16:31 2015
@@ -1524,5 +1524,5 @@
 
 	ast_cli_register_multiple(cli_udptl, ARRAY_LEN(cli_udptl));
 
-	ast_register_atexit(udptl_shutdown);
-}
+	ast_register_cleanup(udptl_shutdown);
+}

Modified: branches/11/main/utils.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/utils.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/utils.c (original)
+++ branches/11/main/utils.c Thu Mar 26 17:16:31 2015
@@ -2285,7 +2285,7 @@
 	ast_cli_register_multiple(utils_cli, ARRAY_LEN(utils_cli));
 #endif
 #endif
-	ast_register_atexit(utils_shutdown);
+	ast_register_cleanup(utils_shutdown);
 	return 0;
 }
 

Modified: branches/11/main/xmldoc.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/xmldoc.c?view=diff&rev=433495&r1=433494&r2=433495
==============================================================================
--- branches/11/main/xmldoc.c (original)
+++ branches/11/main/xmldoc.c Thu Mar 26 17:16:31 2015
@@ -2396,7 +2396,7 @@
 	ast_xml_init();
 
 	/* register function to be run when asterisk finish. */
-	ast_register_atexit(xmldoc_unload_documentation);
+	ast_register_cleanup(xmldoc_unload_documentation);
 
 	globbuf.gl_offs = 0;    /* slots to reserve in gl_pathv */
 




More information about the asterisk-commits mailing list