diff options
author | Mark Michelson <mmichelson@digium.com> | 2015-04-03 21:53:28 +0000 |
---|---|---|
committer | Mark Michelson <mmichelson@digium.com> | 2015-04-03 21:53:28 +0000 |
commit | 1ee8424f27780ac3f1e96018e01622d081b640f2 (patch) | |
tree | 6b1d1f9876b4b2aa107ac048ece392760ca29dc7 /res/res_pjsip_messaging.c | |
parent | 169e57d2e066eb49ed2a881aabfbc212a46f01d2 (diff) |
res_pjsip_messaging: Serialize outbound SIP MESSAGEs
Outbound SIP MESSAGEs had the potential to be sent out
of order from how they were specified in a set of
dialplan steps.
This change creates a serializer for sending outbound
MESSAGE requests on. This ensures that the MESSAGEs are
sent by Asterisk in the same order that they were sent
from the dialplan.
ASTERISK-24937 #close
Reported by Mark Michelson
Review: https://reviewboard.asterisk.org/r/4579
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@433968 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_pjsip_messaging.c')
-rw-r--r-- | res/res_pjsip_messaging.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/res/res_pjsip_messaging.c b/res/res_pjsip_messaging.c index 5caf89374..daa043c73 100644 --- a/res/res_pjsip_messaging.c +++ b/res/res_pjsip_messaging.c @@ -42,6 +42,7 @@ #include "asterisk/pbx.h" #include "asterisk/res_pjsip.h" #include "asterisk/res_pjsip_session.h" +#include "asterisk/taskprocessor.h" const pjsip_method pjsip_message_method = {PJSIP_OTHER_METHOD, {"MESSAGE", 7} }; @@ -49,6 +50,8 @@ const pjsip_method pjsip_message_method = {PJSIP_OTHER_METHOD, {"MESSAGE", 7} }; #define MAX_BODY_SIZE 1024 #define MAX_USER_SIZE 128 +static struct ast_taskprocessor *message_serializer; + /*! * \internal * \brief Checks to make sure the request has the correct content type. @@ -593,7 +596,7 @@ static int sip_msg_send(const struct ast_msg *msg, const char *to, const char *f } if (!(mdata = msg_data_create(msg, to, from)) || - ast_sip_push_task(NULL, msg_send, mdata)) { + ast_sip_push_task(message_serializer, msg_send, mdata)) { ao2_ref(mdata, -1); return -1; } @@ -748,6 +751,13 @@ static int load_module(void) return AST_MODULE_LOAD_DECLINE; } + message_serializer = ast_sip_create_serializer(); + if (!message_serializer) { + ast_sip_unregister_service(&messaging_module); + ast_msg_tech_unregister(&msg_tech); + return AST_MODULE_LOAD_DECLINE; + } + ast_sip_session_register_supplement(&messaging_supplement); return AST_MODULE_LOAD_SUCCESS; } @@ -757,6 +767,7 @@ static int unload_module(void) ast_sip_session_unregister_supplement(&messaging_supplement); ast_msg_tech_unregister(&msg_tech); ast_sip_unregister_service(&messaging_module); + ast_taskprocessor_unreference(message_serializer); return 0; } |