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;