From e0dd6747eadb82bf93a3b3eab60f83f506e4156b Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Fri, 15 Nov 2019 09:58:21 -0500 Subject: [PATCH] TT#71050 fix branch deletion from via-branch Untagged branches (only known by via-branch) don't appear in the `tags` hash and don't have any `other_tags`. The logic to determine whether the call is completely finished therefore must take these into account separately. We take care to remove destroyed monologues from the `viabranches` hash to keep the count up to date, and determine whether a call is terminated when there is no more than 1 tagged monologue left and no untagged monologues. Closes #875 Change-Id: I6b9618d598f4a95970cd2a452f06574423932b09 --- daemon/call.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index 71b7d69ef..de3d95f28 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -2544,6 +2544,8 @@ static void __monologue_destroy(struct call_monologue *monologue) { call = monologue->call; g_hash_table_remove(call->tags, &monologue->tag); + if (monologue->viabranch.s) + g_hash_table_remove(call->viabranches, &monologue->viabranch); l = g_hash_table_get_values(monologue->other_tags); @@ -2564,7 +2566,7 @@ static int monologue_destroy(struct call_monologue *ml) { __monologue_destroy(ml); - if (!g_hash_table_size(c->tags)) { + if (g_hash_table_size(c->tags) < 2 && g_hash_table_size(c->viabranches) == 0) { ilog(LOG_INFO, "Call branch '" STR_FORMAT_M "' (%s" STR_FORMAT "%svia-branch '" STR_FORMAT_M "') " "deleted, no more branches remaining", STR_FMT_M(&ml->tag), @@ -2754,7 +2756,7 @@ int call_delete_branch(const str *callid, const str *branch, if ((!totag || !totag->len) && branch && branch->len) { // try a via-branch match ml = g_hash_table_lookup(c->viabranches, branch); - if (ml && ml->tag.len) // ignore wildcard/unknown monologues + if (ml) goto do_delete; }