From: Automerge script Date: Tue, 11 Sep 2012 21:22:13 +0000 (+0000) Subject: Merged revisions 372885 via svnmerge from X-Git-Tag: 10.9.0-digiumphones-rc1~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7cbdf4fc1637c9fdd5d2e52ccd950ee6ae77ca49;p=thirdparty%2Fasterisk.git Merged revisions 372885 via svnmerge from file:///srv/subversion/repos/asterisk/branches/10 ........ r372885 | mmichelson | 2012-09-11 16:04:36 -0500 (Tue, 11 Sep 2012) | 18 lines Fix inability to shutdown gracefully due to an unending channel reference. message.c makes use of a special message queue channel that exists in thread storage. This channel never goes away due to the fact that the taskprocessor used by message.c does not get shut down, meaning that it never ends the thread that stores the channel. This patch fixes the problem by shutting down the taskprocessor when Asterisk is shut down. In addition, the thread storage has a destructor that will release the channel reference when the taskprocessor is destroyed. (closes issue AST-937) Reported by Jason Parker Patches: AST-937.patch uploaded by Mark Michelson (License #5049) Tested by Jason Parker ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/10-digiumphones@372901 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/include/asterisk/_private.h b/include/asterisk/_private.h index 37c49d9af3..e1f8c7246b 100644 --- a/include/asterisk/_private.h +++ b/include/asterisk/_private.h @@ -48,6 +48,7 @@ int ast_cel_engine_reload(void); /*!< Provided by cel.c */ int ast_ssl_init(void); /*!< Provided by ssl.c */ int ast_test_init(void); /*!< Provided by test.c */ int ast_msg_init(void); /*!< Provided by message.c */ +void ast_msg_shutdown(void); /*!< Provided by message.c */ /*! * \brief Reload asterisk modules. diff --git a/main/asterisk.c b/main/asterisk.c index 1698b53da4..7ca824bbb3 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -1694,6 +1694,7 @@ static int can_safely_quit(shutdown_nice_t niceness, int restart) * (if in batch mode). really_quit happens to call it again when running * the atexit handlers, otherwise this would be a bit early. */ ast_cdr_engine_term(); + ast_msg_shutdown(); if (niceness == SHUTDOWN_NORMAL) { time_t s, e; diff --git a/main/message.c b/main/message.c index 387e7cd60c..d192a4bfca 100644 --- a/main/message.c +++ b/main/message.c @@ -757,7 +757,18 @@ static void chan_cleanup(struct ast_channel *chan) ast_channel_unlock(chan); } -AST_THREADSTORAGE(msg_q_chan); +static void destroy_msg_q_chan(void *data) +{ + struct ast_channel **chan = data; + + if (!*chan) { + return; + } + + ast_channel_release(*chan); +} + +AST_THREADSTORAGE_CUSTOM(msg_q_chan, NULL, destroy_msg_q_chan); /*! * \internal @@ -1319,3 +1330,8 @@ int ast_msg_init(void) return res; } + +void ast_msg_shutdown(void) +{ + msg_q_tp = ast_taskprocessor_unreference(msg_q_tp); +}