Browse Source

MT#61371 support tag aliases

If a monologue is determined to get a new to-tag, don't just overwrite
the previous to-tag, but also save the old one as an alias. Leave the
old one in the hash table as well so that future lookups can use either
to-tag.

Change-Id: I5d2d5cc17c85ec4ca2d8a20c501d2cdb6d793b61
pull/1876/head
Richard Fuchs 1 year ago
parent
commit
84350cb850
2 changed files with 27 additions and 7 deletions
  1. +26
    -7
      daemon/call.c
  2. +1
    -0
      include/call.h

+ 26
- 7
daemon/call.c View File

@ -4054,6 +4054,7 @@ void __monologue_free(struct call_monologue *m) {
sdp_orig_free(m->session_last_sdp_orig);
t_queue_clear_full(&m->generic_attributes, sdp_attr_free);
t_queue_clear_full(&m->all_attributes, sdp_attr_free);
t_queue_clear(&m->tag_aliases);
sdp_streams_clear(&m->last_in_sdp_streams);
g_slice_free1(sizeof(*m), m);
}
@ -4286,11 +4287,30 @@ struct call_monologue *__monologue_create(call_t *call) {
void __monologue_tag(struct call_monologue *ml, const str *tag) {
call_t *call = ml->call;
__C_DBG("tagging monologue with '"STR_FORMAT"'", STR_FMT(tag));
if (ml->tag.s)
t_hash_table_remove(call->tags, &ml->tag); /* remove tag from tags of the call object */
if (!ml->tag.s) {
__C_DBG("tagging monologue with '" STR_FORMAT "'", STR_FMT(tag));
ml->tag = call_str_cpy(tag);
t_hash_table_insert(call->tags, &ml->tag, ml);
return;
}
if (!str_cmp_str(&ml->tag, tag))
return; // no change
// to-tag has changed, save previous as alias
__C_DBG("tagging monologue with '" STR_FORMAT "', saving previous '" STR_FORMAT "' as alias",
STR_FMT(tag), STR_FMT(&ml->tag));
// remove old entry first, as `ml->tag` will be changed
t_hash_table_remove(call->tags, &ml->tag);
// duplicate string and save as alias
str *old_tag = call_str_dup(&ml->tag);
t_queue_push_tail(&ml->tag_aliases, old_tag);
// add duplicated old tag into hash table
t_hash_table_insert(call->tags, old_tag, ml);
// update tag to new one
ml->tag = call_str_cpy(tag);
t_hash_table_insert(call->tags, &ml->tag, ml); /* and insert a new one */
// and add new one to hash table
t_hash_table_insert(call->tags, &ml->tag, ml);
}
void __monologue_viabranch(struct call_monologue *ml, const str *viabranch) {
@ -4621,7 +4641,7 @@ have_dialogue:
continue;
if (!os)
os = ms->monologue;
if (totag && totag->s && !ms->monologue->tag.s)
if (totag && totag->s)
__monologue_tag(ms->monologue, totag);
/* There should be only one monologue?
* TODO: check if there's more than one-to-one mapping */
@ -4718,8 +4738,7 @@ tag_setup:
/* the fromtag monologue may be newly created, or half-complete from the totag, or
* derived from the viabranch. */
if (!ft->tag.s || str_cmp_str(&ft->tag, fromtag))
__monologue_tag(ft, fromtag);
__monologue_tag(ft, fromtag);
dialogue_unconfirm(ft, "dialogue signalling event");
dialogue_unconfirm(tt, "dialogue signalling event");


+ 1
- 0
include/call.h View File

@ -575,6 +575,7 @@ struct call_monologue {
str tag;
str viabranch;
str_q tag_aliases;
enum tag_type tagtype;
str label;
time_t created; /* RO */


Loading…
Cancel
Save