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
This commit is contained in:
Joshua Colp
2014-01-05 01:31:19 +00:00
parent 3eee3f21ad
commit 11f18e4724

View File

@@ -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)) {