From 4f48d31444d11516026d729923160ddd00b5a239 Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Wed, 20 Nov 2024 15:15:05 +0100 Subject: [PATCH] MT#56465 Improve "this" side lookup by subs During the monologues lookup in `call_get_dialogue()`, instead of relying on the very first available other side subscription, when doing a lookup of this side, try to look into all of them to find available media with existing subs. Change-Id: If232cd25f26a2bc56eb1f401ba5c2c8a13e3e463 --- daemon/call.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index d87affbdd..776f6a0f8 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -4747,13 +4747,21 @@ static int call_get_dialogue(struct call_monologue *monologues[2], call_t *call, */ if (viabranch) ft = t_hash_table_lookup(call->viabranches, viabranch); - /* top most subscription of tt */ + /* first possible subscription of tt (other side) */ if (!ft) { - struct call_media *media = tt->medias->len ? tt->medias->pdata[0] : NULL; - if (media && media->media_subscriptions.head) { + /* find by any other's side subscriptions (expected one-monologue to one-monologue talk) */ + for (int i = 0; i < tt->medias->len; i++) + { + struct call_media *media = tt->medias->pdata[i]; + if (!media || !media->media_subscriptions.head) + continue; struct media_subscription * ms = media->media_subscriptions.head->data; - if (ms->monologue) + if (ms->monologue) { ft = ms->monologue; + __C_DBG("Found existing monologue '" STR_FORMAT "' for this side, by lookup of other side subscriptions", + STR_FMT(&ft->tag)); + break; + } } } /* otherwise create a brand-new one.