summaryrefslogtreecommitdiff
path: root/main/message.c
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2012-09-11 21:17:53 +0000
committerMark Michelson <mmichelson@digium.com>2012-09-11 21:17:53 +0000
commit8963829390ca45b269c99144b1ffb96d17d9a3d3 (patch)
tree0dd0bba1774c982fd091c12c56303ef65737b509 /main/message.c
parentae5aaefd88224c20d246087b3e4277b6c97545cb (diff)
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 ........ Merged revisions 372885 from http://svn.asterisk.org/svn/asterisk/branches/10 ........ Merged revisions 372888 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@372891 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/message.c')
-rw-r--r--main/message.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/main/message.c b/main/message.c
index 1ac9231e3..26fea1aca 100644
--- a/main/message.c
+++ b/main/message.c
@@ -756,7 +756,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
@@ -1318,3 +1329,8 @@ int ast_msg_init(void)
return res;
}
+
+void ast_msg_shutdown(void)
+{
+ msg_q_tp = ast_taskprocessor_unreference(msg_q_tp);
+}