From 24e2a02f9f00458ac3c032177488444da769f13d Mon Sep 17 00:00:00 2001 From: Andreas Granig Date: Wed, 15 Feb 2012 16:54:57 +0000 Subject: [PATCH] Delete full call if only one branch is left. --- daemon/call.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index 082dcd773..441f3c851 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -1445,21 +1445,27 @@ char *call_delete_udp(const char **out, struct callmaster *m) { goto err; if(out[RE_UDP_D_VIABRANCH]) { - /* only delete selective branch */ + /* search given branch */ while(c) { next = c->next; if(g_strcmp0(out[RE_UDP_D_VIABRANCH], c->viabranch) == 0) { - mylog(LOG_INFO, "[%s - %s] Deleting selective call branch", - c->callid, VIA2STR(c->viabranch)); - if(c->prev) - c->prev->next = c->next; - call_destroy(c); + if(!c->prev && !c->next) { + mylog(LOG_INFO, "[%s - %s] Deleting full call because there is only one branch", + c->callid, VIA2STR(c->viabranch)); + call_destroy_all_branches(c); + } else { + mylog(LOG_INFO, "[%s - %s] Deleting selective call branch", + c->callid, VIA2STR(c->viabranch)); + if(c->prev) + c->prev->next = c->next; + call_destroy(c); + } break; } c = next; } } else { - mylog(LOG_INFO, "[%s] Deleting all call branches", c->callid); + mylog(LOG_INFO, "[%s] Deleting full call", c->callid); call_destroy_all_branches(c); }