diff --git a/res/res_pjsip_outbound_registration.c b/res/res_pjsip_outbound_registration.c index dce51468db3f52003b3c69b66dbc9adfd2c84d40..c3afe5d467e97fc31ffe6854aa330580e74d5fb0 100644 --- a/res/res_pjsip_outbound_registration.c +++ b/res/res_pjsip_outbound_registration.c @@ -1338,13 +1338,16 @@ static void registration_response_destroy(void *obj) if (response->rdata) { pjsip_rx_data_free_cloned(response->rdata); + response->rdata = NULL; } if (response->old_request) { pjsip_tx_data_dec_ref(response->old_request); + response->old_request = NULL; } ao2_cleanup(response->client_state); + response->client_state = NULL; } /*! \brief Helper function which determines if a response code is temporal or not */ @@ -1677,6 +1680,11 @@ static ast_sched_cb registration_resend(struct registration_response *response) pjsip_tx_data *tdata = response->old_request; pjsip_via_hdr *via; + if (!client_state || client_state->registration_resend_timer_id == -1 || !tdata) { + ast_debug(2, "Expired registration request, skipping\n"); + return 0; + } + ast_debug(2, "%s: resend registration on %s\n", client_state->registration_name, client_state->transport_name); client_state->registration_resend_timer_id = -1; @@ -2836,7 +2844,12 @@ static int sip_outbound_registration_recovery(void *data) state->client_state->forbidden_retry_interval = registration->forbidden_retry_interval; state->client_state->fatal_retry_interval = registration->fatal_retry_interval; state->client_state->max_retries = registration->max_retries; - state->client_state->registration_resend_timer_id = -1; + if (state->client_state->registration_resend_timer_id != -1) { + if (ast_sched_del(sched, state->client_state->registration_resend_timer_id)) { + ast_log(LOG_ERROR, "Failed to remove scheduled registration resend timer\n"); + } + state->client_state->registration_resend_timer_id = -1; + } state->client_state->failover_retry_interval1 = registration->failover_retry_interval1; state->client_state->failover_retry_interval2 = registration->failover_retry_interval2; state->client_state->failover_max_retries = registration->failover_max_retries;