diff options
Diffstat (limited to 'main/message.c')
-rw-r--r-- | main/message.c | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/main/message.c b/main/message.c index c04413dc8..f764e2774 100644 --- a/main/message.c +++ b/main/message.c @@ -1302,6 +1302,30 @@ int ast_msg_tech_unregister(const struct ast_msg_tech *tech) return 0; } +void ast_msg_shutdown() +{ + if (msg_q_tp) { + msg_q_tp = ast_taskprocessor_unreference(msg_q_tp); + } +} + +/*! \internal \brief Clean up other resources on Asterisk shutdown + * \note This does not include the msg_q_tp object, which must be disposed + * of prior to Asterisk checking for channel destruction in its shutdown + * sequence. The atexit handlers are executed after this occurs. */ +static void message_shutdown(void) +{ + ast_custom_function_unregister(&msg_function); + ast_custom_function_unregister(&msg_data_function); + ast_unregister_application(app_msg_send); + ast_manager_unregister("MessageSend"); + + if (msg_techs) { + ao2_ref(msg_techs, -1); + msg_techs = NULL; + } +} + /* * \internal * \brief Initialize stuff during Asterisk startup. @@ -1331,10 +1355,7 @@ int ast_msg_init(void) res |= ast_register_application2(app_msg_send, msg_send_exec, NULL, NULL, NULL); res |= ast_manager_register_xml_core("MessageSend", EVENT_FLAG_MESSAGE, action_messagesend); - return res; -} + ast_register_atexit(message_shutdown); -void ast_msg_shutdown(void) -{ - msg_q_tp = ast_taskprocessor_unreference(msg_q_tp); + return res; } |