mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-02 10:22:46 +00:00
Merged revisions 377138 via svnmerge from
file:///srv/subversion/repos/asterisk/trunk ................ r377138 | rmudgett | 2012-12-03 14:46:11 -0600 (Mon, 03 Dec 2012) | 23 lines 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 ........ Merged revisions 377136 from http://svn.asterisk.org/svn/asterisk/branches/10 ........ Merged revisions 377137 from http://svn.asterisk.org/svn/asterisk/branches/11 ................ git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377145 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -19,6 +19,7 @@ int load_modules(unsigned int); /*!< Provided by loader.c */
|
|||||||
int load_pbx(void); /*!< Provided by pbx.c */
|
int load_pbx(void); /*!< Provided by pbx.c */
|
||||||
int init_logger(void); /*!< Provided by logger.c */
|
int init_logger(void); /*!< Provided by logger.c */
|
||||||
void close_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 init_framer(void); /*!< Provided by frame.c */
|
||||||
int ast_term_init(void); /*!< Provided by term.c */
|
int ast_term_init(void); /*!< Provided by term.c */
|
||||||
int astdb_init(void); /*!< Provided by db.c */
|
int astdb_init(void); /*!< Provided by db.c */
|
||||||
|
@@ -1847,6 +1847,8 @@ static int can_safely_quit(shutdown_nice_t niceness, int restart)
|
|||||||
|
|
||||||
static void really_quit(int num, shutdown_nice_t niceness, int restart)
|
static void really_quit(int num, shutdown_nice_t niceness, int restart)
|
||||||
{
|
{
|
||||||
|
int active_channels;
|
||||||
|
|
||||||
if (niceness >= SHUTDOWN_NICE) {
|
if (niceness >= SHUTDOWN_NICE) {
|
||||||
ast_module_shutdown();
|
ast_module_shutdown();
|
||||||
}
|
}
|
||||||
@@ -1873,6 +1875,7 @@ static void really_quit(int num, shutdown_nice_t niceness, int restart)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
active_channels = ast_active_channels();
|
||||||
/* The manager event for shutdown must happen prior to ast_run_atexits, as
|
/* 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
|
* the manager interface will dispose of its sessions as part of its
|
||||||
* shutdown.
|
* shutdown.
|
||||||
@@ -1898,13 +1901,13 @@ static void really_quit(int num, shutdown_nice_t niceness, int restart)
|
|||||||
***/
|
***/
|
||||||
manager_event(EVENT_FLAG_SYSTEM, "Shutdown", "Shutdown: %s\r\n"
|
manager_event(EVENT_FLAG_SYSTEM, "Shutdown", "Shutdown: %s\r\n"
|
||||||
"Restart: %s\r\n",
|
"Restart: %s\r\n",
|
||||||
ast_active_channels() ? "Uncleanly" : "Cleanly",
|
active_channels ? "Uncleanly" : "Cleanly",
|
||||||
restart ? "True" : "False");
|
restart ? "True" : "False");
|
||||||
|
|
||||||
ast_verb(0, "Executing last minute cleanups\n");
|
ast_verb(0, "Executing last minute cleanups\n");
|
||||||
ast_run_atexits();
|
ast_run_atexits();
|
||||||
/* Called on exit */
|
/* Called on exit */
|
||||||
ast_verb(0, "Asterisk %s ending (%d).\n", ast_active_channels() ? "uncleanly" : "cleanly", num);
|
ast_verb(0, "Asterisk %s ending (%d).\n", active_channels ? "uncleanly" : "cleanly", num);
|
||||||
ast_debug(1, "Asterisk ending (%d).\n", num);
|
ast_debug(1, "Asterisk ending (%d).\n", num);
|
||||||
if (ast_socket > -1) {
|
if (ast_socket > -1) {
|
||||||
pthread_cancel(lthread);
|
pthread_cancel(lthread);
|
||||||
@@ -1929,6 +1932,7 @@ static void really_quit(int num, shutdown_nice_t niceness, int restart)
|
|||||||
|
|
||||||
/* close logger */
|
/* close logger */
|
||||||
close_logger();
|
close_logger();
|
||||||
|
clean_time_zones();
|
||||||
|
|
||||||
/* If there is a consolethread running send it a SIGHUP
|
/* If there is a consolethread running send it a SIGHUP
|
||||||
so it can execvp, otherwise we can do it ourselves */
|
so it can execvp, otherwise we can do it ourselves */
|
||||||
@@ -1942,6 +1946,7 @@ static void really_quit(int num, shutdown_nice_t niceness, int restart)
|
|||||||
} else {
|
} else {
|
||||||
/* close logger */
|
/* close logger */
|
||||||
close_logger();
|
close_logger();
|
||||||
|
clean_time_zones();
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
@@ -2375,14 +2380,25 @@ static char *show_license(struct ast_cli_entry *e, int cmd, struct ast_cli_args
|
|||||||
|
|
||||||
#define ASTERISK_PROMPT2 "%s*CLI> "
|
#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_now, "Shut down Asterisk immediately"),
|
||||||
AST_CLI_DEFINE(handle_stop_gracefully, "Gracefully shut down Asterisk"),
|
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_stop_when_convenient, "Shut down Asterisk at empty call volume"),
|
||||||
AST_CLI_DEFINE(handle_restart_now, "Restart Asterisk immediately"),
|
AST_CLI_DEFINE(handle_restart_now, "Restart Asterisk immediately"),
|
||||||
AST_CLI_DEFINE(handle_restart_gracefully, "Restart Asterisk gracefully"),
|
AST_CLI_DEFINE(handle_restart_gracefully, "Restart Asterisk gracefully"),
|
||||||
AST_CLI_DEFINE(handle_restart_when_convenient, "Restart Asterisk at empty call volume"),
|
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_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(show_license, "Show the license(s) for this copy of Asterisk"),
|
||||||
AST_CLI_DEFINE(handle_version, "Display version info"),
|
AST_CLI_DEFINE(handle_version, "Display version info"),
|
||||||
@@ -3549,6 +3565,11 @@ static void print_intro_message(const char *runuser, const char *rungroup)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void main_atexit(void)
|
||||||
|
{
|
||||||
|
ast_cli_unregister_multiple(cli_asterisk, ARRAY_LEN(cli_asterisk));
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
@@ -4276,7 +4297,9 @@ int main(int argc, char *argv[])
|
|||||||
#endif /* defined(__AST_DEBUG_MALLOC) */
|
#endif /* defined(__AST_DEBUG_MALLOC) */
|
||||||
|
|
||||||
ast_lastreloadtime = ast_startuptime = ast_tvnow();
|
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_cli_register_multiple(cli_asterisk, ARRAY_LEN(cli_asterisk));
|
||||||
|
ast_register_atexit(main_atexit);
|
||||||
|
|
||||||
run_startup_commands();
|
run_startup_commands();
|
||||||
|
|
||||||
|
@@ -71,6 +71,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
#include "private.h"
|
#include "private.h"
|
||||||
#include "tzfile.h"
|
#include "tzfile.h"
|
||||||
|
|
||||||
|
#include "asterisk/_private.h"
|
||||||
#include "asterisk/lock.h"
|
#include "asterisk/lock.h"
|
||||||
#include "asterisk/localtime.h"
|
#include "asterisk/localtime.h"
|
||||||
#include "asterisk/strings.h"
|
#include "asterisk/strings.h"
|
||||||
@@ -444,7 +445,7 @@ static void *kqueue_daemon(void *data)
|
|||||||
closedir(sp->dir);
|
closedir(sp->dir);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
free(sp);
|
ast_free(sp);
|
||||||
|
|
||||||
/* Just in case the signal was sent late */
|
/* Just in case the signal was sent late */
|
||||||
AST_LIST_LOCK(&zonelist);
|
AST_LIST_LOCK(&zonelist);
|
||||||
@@ -1436,6 +1437,17 @@ static int gmtload(struct state *sp)
|
|||||||
return -1;
|
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)
|
static const struct state *ast_tzset(const char *zone)
|
||||||
{
|
{
|
||||||
struct state *sp;
|
struct state *sp;
|
||||||
|
Reference in New Issue
Block a user