]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix inability to shutdown gracefully due to an unending channel reference.
authorMark Michelson <mmichelson@digium.com>
Tue, 11 Sep 2012 21:02:33 +0000 (21:02 +0000)
committerMark Michelson <mmichelson@digium.com>
Tue, 11 Sep 2012 21:02:33 +0000 (21:02 +0000)
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/certified/branches/1.8.15@372884 65c4cc65-6c06-0410-ace0-fbb531ad65f3

include/asterisk/_private.h
main/asterisk.c
main/message.c

index 057255fa6bf9b461c9277db9ba3dc467fbfe93dc..1abdcc4003d9291c1b811f53afcd39226ece1e56 100644 (file)
@@ -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.
index d8bc71886a14c8512ed9bdbe307e5897780aaa96..e62ee7dc226608d37a63d20b4e06869994fa4e95 100644 (file)
@@ -1687,6 +1687,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;
index 1c4b10a67bf6b48176ec99c53273808a57b5e1a4..2a6482b2358c438485d49e08b7c758ad06d43080 100644 (file)
@@ -743,7 +743,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
@@ -1305,3 +1316,8 @@ int ast_msg_init(void)
 
        return res;
 }
+
+void ast_msg_shutdown(void)
+{
+       msg_q_tp = ast_taskprocessor_unreference(msg_q_tp);
+}