[asterisk-commits] rmudgett: branch 10 r377136 - in /branches/10: ./ include/asterisk/ main/ mai...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Dec 3 14:33:11 CST 2012
Author: rmudgett
Date: Mon Dec 3 14:33:08 2012
New Revision: 377136
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=377136
Log:
Cleanup core main on exit.
* Cleanup time zones on exit.
* Make exit clean/unclean report consistent for AMI and CLI in
really_quit().
(issue ASTERISK-20649)
Reported by: Corey Farrell
Patches:
core-cleanup-1_8-10.patch (license #5909) patch uploaded by Corey Farrell
core-cleanup-11-trunk.patch (license #5909) patch uploaded by Corey Farrell
Modified
........
Merged revisions 377135 from http://svn.asterisk.org/svn/asterisk/branches/1.8
Modified:
branches/10/ (props changed)
branches/10/include/asterisk/_private.h
branches/10/main/asterisk.c
branches/10/main/stdtime/localtime.c
Propchange: branches/10/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.
Modified: branches/10/include/asterisk/_private.h
URL: http://svnview.digium.com/svn/asterisk/branches/10/include/asterisk/_private.h?view=diff&rev=377136&r1=377135&r2=377136
==============================================================================
--- branches/10/include/asterisk/_private.h (original)
+++ branches/10/include/asterisk/_private.h Mon Dec 3 14:33:08 2012
@@ -19,6 +19,7 @@
int load_pbx(void); /*!< Provided by pbx.c */
int init_logger(void); /*!< Provided by logger.c */
void close_logger(void); /*!< Provided by logger.c */
+void clean_time_zones(void); /*!< Provided by localtime.c */
int init_framer(void); /*!< Provided by frame.c */
int ast_term_init(void); /*!< Provided by term.c */
int astdb_init(void); /*!< Provided by db.c */
Modified: branches/10/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/main/asterisk.c?view=diff&rev=377136&r1=377135&r2=377136
==============================================================================
--- branches/10/main/asterisk.c (original)
+++ branches/10/main/asterisk.c Mon Dec 3 14:33:08 2012
@@ -1751,6 +1751,8 @@
static void really_quit(int num, shutdown_nice_t niceness, int restart)
{
+ int active_channels;
+
if (niceness >= SHUTDOWN_NICE) {
ast_module_shutdown();
}
@@ -1777,21 +1779,23 @@
}
}
}
+ active_channels = ast_active_channels();
/* The manager event for shutdown must happen prior to ast_run_atexits, as
* the manager interface will dispose of its sessions as part of its
* shutdown.
*/
manager_event(EVENT_FLAG_SYSTEM, "Shutdown", "Shutdown: %s\r\n"
"Restart: %s\r\n",
- ast_active_channels() ? "Uncleanly" : "Cleanly",
+ active_channels ? "Uncleanly" : "Cleanly",
restart ? "True" : "False");
if (option_verbose)
ast_verbose("Executing last minute cleanups\n");
ast_run_atexits();
/* Called on exit */
- if (option_verbose && ast_opt_console)
- ast_verbose("Asterisk %s ending (%d).\n", ast_active_channels() ? "uncleanly" : "cleanly", num);
+ if (option_verbose && ast_opt_console) {
+ ast_verbose("Asterisk %s ending (%d).\n", active_channels ? "uncleanly" : "cleanly", num);
+ }
ast_debug(1, "Asterisk ending (%d).\n", num);
if (ast_socket > -1) {
pthread_cancel(lthread);
@@ -1818,6 +1822,7 @@
/* close logger */
close_logger();
+ clean_time_zones();
/* If there is a consolethread running send it a SIGHUP
so it can execvp, otherwise we can do it ourselves */
@@ -1831,6 +1836,7 @@
} else {
/* close logger */
close_logger();
+ clean_time_zones();
}
exit(0);
@@ -2229,14 +2235,25 @@
#define ASTERISK_PROMPT2 "%s*CLI> "
-static struct ast_cli_entry cli_asterisk[] = {
- AST_CLI_DEFINE(handle_abort_shutdown, "Cancel a running shutdown"),
+/*!
+ * \brief Shutdown Asterisk CLI commands.
+ *
+ * \note These CLI commands cannot be unregistered at shutdown
+ * because one of them is likely the reason for the shutdown.
+ * The CLI generates a warning if a command is in-use when it is
+ * unregistered.
+ */
+static struct ast_cli_entry cli_asterisk_shutdown[] = {
AST_CLI_DEFINE(handle_stop_now, "Shut down Asterisk immediately"),
AST_CLI_DEFINE(handle_stop_gracefully, "Gracefully shut down Asterisk"),
AST_CLI_DEFINE(handle_stop_when_convenient, "Shut down Asterisk at empty call volume"),
AST_CLI_DEFINE(handle_restart_now, "Restart Asterisk immediately"),
AST_CLI_DEFINE(handle_restart_gracefully, "Restart Asterisk gracefully"),
AST_CLI_DEFINE(handle_restart_when_convenient, "Restart Asterisk at empty call volume"),
+};
+
+static struct ast_cli_entry cli_asterisk[] = {
+ AST_CLI_DEFINE(handle_abort_shutdown, "Cancel a running shutdown"),
AST_CLI_DEFINE(show_warranty, "Show the warranty (if any) for this copy of Asterisk"),
AST_CLI_DEFINE(show_license, "Show the license(s) for this copy of Asterisk"),
AST_CLI_DEFINE(handle_version, "Display version info"),
@@ -3356,6 +3373,11 @@
}
}
+static void main_atexit(void)
+{
+ ast_cli_unregister_multiple(cli_asterisk, ARRAY_LEN(cli_asterisk));
+}
+
int main(int argc, char *argv[])
{
int c;
@@ -4066,7 +4088,9 @@
#endif /* defined(__AST_DEBUG_MALLOC) */
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);
run_startup_commands();
Modified: branches/10/main/stdtime/localtime.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/main/stdtime/localtime.c?view=diff&rev=377136&r1=377135&r2=377136
==============================================================================
--- branches/10/main/stdtime/localtime.c (original)
+++ branches/10/main/stdtime/localtime.c Mon Dec 3 14:33:08 2012
@@ -71,6 +71,7 @@
#include "private.h"
#include "tzfile.h"
+#include "asterisk/_private.h"
#include "asterisk/lock.h"
#include "asterisk/localtime.h"
#include "asterisk/strings.h"
@@ -427,7 +428,7 @@
closedir(sp->dir);
}
#endif
- free(sp);
+ ast_free(sp);
/* Just in case the signal was sent late */
AST_LIST_LOCK(&zonelist);
@@ -1417,6 +1418,17 @@
return -1;
}
+void clean_time_zones(void)
+{
+ struct state *sp;
+
+ AST_LIST_LOCK(&zonelist);
+ while ((sp = AST_LIST_REMOVE_HEAD(&zonelist, list))) {
+ ast_free(sp);
+ }
+ AST_LIST_UNLOCK(&zonelist);
+}
+
static const struct state *ast_tzset(const char *zone)
{
struct state *sp;
More information about the asterisk-commits
mailing list