From: Joshua Colp Date: Sun, 5 Jan 2014 01:31:19 +0000 (+0000) Subject: res_pjsip_outbound_registration: Create registration client in pj thread. X-Git-Tag: 13.0.0-beta1~680 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=11f18e4724756a3655dcfa3b8ffd40f21549647a;p=thirdparty%2Fasterisk.git 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 --- diff --git a/res/res_pjsip_outbound_registration.c b/res/res_pjsip_outbound_registration.c index e0c99af31f..b9429d36a1 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, + ®istration->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)) {