Commit 823e3e45 authored by jehan's avatar jehan

fix various crashed linked to channel live cycle

parent 1b878f34
......@@ -173,13 +173,17 @@ static int keep_alive_timer_func(void *user_data, unsigned int events) {
belle_sip_listening_point_t* lp=(belle_sip_listening_point_t*)user_data;
belle_sip_list_t* iterator;
belle_sip_channel_t* channel;
for (iterator=lp->channels;iterator!=NULL;iterator=iterator->next) {
channel=(belle_sip_channel_t*)iterator->data;
if (send_keep_alive(channel)) {
channel_set_state(channel,BELLE_SIP_CHANNEL_ERROR);
belle_sip_channel_close(channel);
}
/*list is copied to make sure it is not altered in case of error*/
for (iterator=belle_sip_list_copy(lp->channels);iterator!=NULL;iterator=iterator->next) {
channel=(belle_sip_channel_t*)iterator->data;
belle_sip_object_ref(channel); /*to make sure channels are still valid even if error is reported*/
if (channel->state == BELLE_SIP_CHANNEL_READY && send_keep_alive(channel)) { /*only send keep alive if ready*/
channel_set_state(channel,BELLE_SIP_CHANNEL_ERROR);
belle_sip_channel_close(channel);
}
belle_sip_object_unref(channel);
}
belle_sip_list_free(iterator);
return BELLE_SIP_CONTINUE;
}
void belle_sip_listening_point_set_keep_alive(belle_sip_listening_point_t *lp,int ms) {
......
......@@ -96,6 +96,7 @@ static void belle_sip_provider_dispatch_request(belle_sip_provider_t* prov, bell
ev.dialog=belle_sip_provider_find_dialog(prov,req,1/*request=uas*/);
if (strcmp("ACK",belle_sip_request_get_method(req))==0 && ev.dialog){
belle_sip_warning("Provider [%p] received an unexpected stateless ACK",prov);
if (belle_sip_dialog_handle_ack(ev.dialog,req)==-1){
/*absorbed ACK retransmission, ignore */
return;
......
......@@ -197,9 +197,10 @@ void belle_sip_server_transaction_on_request(belle_sip_server_transaction_t *t,
belle_sip_ist_t *ist=(belle_sip_ist_t*)t;
if (belle_sip_ist_process_ack(ist,(belle_sip_message_t*)req)==0){
belle_sip_dialog_t *dialog=t->base.dialog;
if (dialog && belle_sip_dialog_handle_ack(dialog,req)==-1)
dialog=NULL;
server_transaction_notify(t,req,dialog);
if (dialog && belle_sip_dialog_handle_ack(dialog,req)==0)
server_transaction_notify(t,req,dialog);
/*else nothing to do because retransmission of ACK*/
}
}else{
belle_sip_warning("ACK received for non-invite server transaction ?");
......
......@@ -120,6 +120,7 @@ static int on_udp_data(belle_sip_udp_listening_point_t *lp, unsigned int events)
,&ai);
if (chan!=NULL){
belle_sip_message("udp_listening_point: new channel created to %s:%i",chan->peer_name,chan->peer_port);
chan->lp=(belle_sip_listening_point_t*)lp; /*FIXME, exactly the same code as for channel creation from provider. might be good to factorize*/
belle_sip_listening_point_add_channel((belle_sip_listening_point_t*)lp,chan);
belle_sip_channel_add_listener(chan,lp->base.channel_listener);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment