summaryrefslogtreecommitdiff
path: root/res/res_pjsip_outbound_registration.c
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2014-01-05 01:31:19 +0000
committerJoshua Colp <jcolp@digium.com>2014-01-05 01:31:19 +0000
commit11f18e4724756a3655dcfa3b8ffd40f21549647a (patch)
tree215d818fac039c052a9aba8e45b9c443e49ce416 /res/res_pjsip_outbound_registration.c
parent3eee3f21ad8b7ea82874ba89575d06fb626be4d7 (diff)
res_pjsip_outbound_registration: Create registration client in pj thread.
Depending on which threading was loading the outbound registration it was possible for the registration client to be allocated outside of a pj thread. This change moves the creation inside the synchronous task where it is guaranteed it will occur in a pj thread. Reported by: Rob Thomas ........ Merged revisions 404923 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@404924 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_pjsip_outbound_registration.c')
-rw-r--r--res/res_pjsip_outbound_registration.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/res/res_pjsip_outbound_registration.c b/res/res_pjsip_outbound_registration.c
index e0c99af31..b9429d36a 100644
--- a/res/res_pjsip_outbound_registration.c
+++ b/res/res_pjsip_outbound_registration.c
@@ -538,10 +538,7 @@ static struct sip_outbound_registration_state *sip_outbound_registration_state_a
return NULL;
}
- if ((pjsip_regc_create(ast_sip_get_pjsip_endpoint(), state->client_state, sip_outbound_registration_response_cb, &state->client_state->client) != PJ_SUCCESS) ||
- !(state->client_state->serializer = ast_sip_create_serializer())) {
- /* This is on purpose, normal operation will have it be deallocated within the serializer */
- pjsip_regc_destroy(state->client_state->client);
+ if (!(state->client_state->serializer = ast_sip_create_serializer())) {
ao2_cleanup(state->client_state);
ao2_cleanup(state);
return NULL;
@@ -725,6 +722,12 @@ static int sip_outbound_registration_regc_alloc(void *data)
}
}
+ if (!registration->state->client_state->client &&
+ pjsip_regc_create(ast_sip_get_pjsip_endpoint(), registration->state->client_state, sip_outbound_registration_response_cb,
+ &registration->state->client_state->client) != PJ_SUCCESS) {
+ return -1;
+ }
+
pjsip_regc_set_transport(registration->state->client_state->client, &selector);
if (!ast_strlen_zero(registration->outbound_proxy)) {