Skip to content

Commit

Permalink
dialog: load from DB call looping dialogs
Browse files Browse the repository at this point in the history
When loading a dialog from DB that has the same coordinates (same
callid+to-tag+from-tag pair) with a different dialog in memory, we
should not ignore it if it comes with a different `hash_id`, as it might
be a completely different dialog, resulted from a call looping scenario
(call that passes through the same OpenSIPS instance twice), which
legitimately creates a new dialog with a new `hash_id`.

Thanks go to @perwx3 (GitHub) for reporting it in ticket #2311.

Complements commit b26d59e.
Fix #2311.

(cherry picked from commit b1ce111)
  • Loading branch information
razvancrainea committed Jan 6, 2021
1 parent c4d965d commit 30fad68
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions modules/dialog/dlg_db_handler.c
Expand Up @@ -599,10 +599,24 @@ static int load_dialog_info_from_db(int dlg_hash_size)

if (get_dlg_unsafe(d_entry, &callid, &from_tag, &to_tag,
&dlg) == 0) {
dlg_unlock(d_table, d_entry);
LM_DBG("dialog already exists, skipping (ci: %.*s)\n",
callid.len, callid.s);
continue;
/*
* there are two cases that could lead here:
* 1) a race condition between the loading from DB and events
* received over a replicated channel - in this case we
* double check if the dialog has the same callid, and if
* we do, we drop the loaded dialog, as it has already been
* learned through replication
* 2) a call looping scenario - a call that passes more than
* once through the same OpenSIPS instance, basically
* creating different dialogs with different hash IDs - in
* this case we shall learn the new dialog (Ticket #2311)
*/
if (dlg->h_id == hash_id) {
dlg_unlock(d_table, d_entry);
LM_DBG("dialog already exists, skipping (ci: %.*s, did: %u.%u)\n",
callid.len, callid.s, hash_entry, hash_id);
continue;
}
}

GET_STR_VALUE(from_uri, values, 2, 1, 0);
Expand Down

0 comments on commit 30fad68

Please sign in to comment.