From 2c770922b73a9da0b5337103b6e673a0607de112 Mon Sep 17 00:00:00 2001 From: Simon Morlat <simon.morlat@linphone.org> Date: Fri, 25 Mar 2011 14:39:39 +0100 Subject: [PATCH] protect osip_list_set_empty() fix spurious "no response" errors at end of calls --- coreapi/sal_eXosip2.c | 21 ++++++++++++++++----- coreapi/sal_eXosip2.h | 1 + 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/coreapi/sal_eXosip2.c b/coreapi/sal_eXosip2.c index 38638716e5..1c04eb190b 100644 --- a/coreapi/sal_eXosip2.c +++ b/coreapi/sal_eXosip2.c @@ -30,9 +30,10 @@ static void text_received(Sal *sal, eXosip_event_t *ev); void _osip_list_set_empty(osip_list_t *l, void (*freefunc)(void*)){ void *data; - while((data=osip_list_get(l,0))!=NULL){ + while(!osip_list_eol(l,0)) { + data=osip_list_get(l,0); osip_list_remove(l,0); - freefunc(data); + if (data) freefunc(data); } } @@ -168,6 +169,7 @@ SalOp * sal_op_new(Sal *sal){ op->masquerade_via=FALSE; op->auto_answer_asked=FALSE; op->auth_info=NULL; + op->terminated=FALSE; return op; } @@ -778,6 +780,7 @@ int sal_call_terminate(SalOp *h){ if (err!=0){ ms_warning("Exosip could not terminate the call: cid=%i did=%i", h->cid,h->did); } + h->terminated=TRUE; return 0; } @@ -1004,6 +1007,7 @@ static int call_proceeding(Sal *sal, eXosip_event_t *ev){ eXosip_lock(); eXosip_call_terminate(ev->cid,ev->did); eXosip_unlock(); + op->terminated=TRUE; return -1; } if (ev->did>0) @@ -1080,6 +1084,7 @@ static void call_terminated(Sal *sal, eXosip_event_t *ev){ } sal->callbacks.call_terminated(op,from!=NULL ? from : sal_op_get_from(op)); if (from) osip_free(from); + op->terminated=TRUE; } static void call_released(Sal *sal, eXosip_event_t *ev){ @@ -1088,7 +1093,7 @@ static void call_released(Sal *sal, eXosip_event_t *ev){ ms_warning("No op associated to this call_released()"); return; } - if (ev->response==NULL){ + if (!op->terminated){ /* no response received so far */ call_failure(sal,ev); } @@ -1871,8 +1876,14 @@ int sal_register(SalOp *h, const char *proxy, const char *from, int expires){ if (h->rid==-1){ eXosip_lock(); h->rid=eXosip_register_build_initial_register(from,proxy,NULL,expires,&msg); - if (contact) register_set_contact(msg,contact); - sal_add_register(h->base.root,h); + if (msg){ + if (contact) register_set_contact(msg,contact); + sal_add_register(h->base.root,h); + }else{ + ms_error("Could not build initial register."); + eXosip_unlock(); + return -1; + } }else{ eXosip_lock(); eXosip_register_build_register(h->rid,expires,&msg); diff --git a/coreapi/sal_eXosip2.h b/coreapi/sal_eXosip2.h index 4db203362f..d55263627b 100644 --- a/coreapi/sal_eXosip2.h +++ b/coreapi/sal_eXosip2.h @@ -65,6 +65,7 @@ struct SalOp{ bool_t reinvite; bool_t masquerade_via; bool_t auto_answer_asked; + bool_t terminated; const SalAuthInfo *auth_info; }; -- GitLab