From 39766afdf60b2dbf9e4b8c58360724509cb7d3e6 Mon Sep 17 00:00:00 2001 From: Andreas Granig Date: Thu, 16 Feb 2012 12:38:16 +0000 Subject: [PATCH] Update callhash on removal of first call in linked list. --- daemon/call.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index f8dfee87b..383a23bcc 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -1128,8 +1128,14 @@ static void call_destroy_all_branches(struct call *c) { static void call_destroy(struct call *c) { struct callstream *s; + if(c->next) + c->next->prev = c->prev; + if(c->prev) c->prev->next = c->next; + else if(c->next) + /* we delete first element in list, so update callid hash */ + g_hash_table_replace(c->callmaster->callhash, c->callid, c->next); #ifndef NO_REDIS /* TODO: take into account the viabranch list */ @@ -1456,15 +1462,15 @@ char *call_delete_udp(const char **out, struct callmaster *m) { c->callid, VIA2STR(c->viabranch)); call_destroy_all_branches(c); } else { + /* TODO: XXX: if "c" was first element, then update callhash table, because + we delete "c" here! */ 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; } else { - DBG("passed viabranch '%s' doesn't match stored viabranch '%s', don't remove call", + DBG("passed viabranch '%s' doesn't match stored viabranch '%s'", VIA2STR(out[RE_UDP_D_VIABRANCH]), VIA2STR(c->viabranch)); } c = next;