Skip to content

Commit

Permalink
dialog: fix a replicated profiles counting issue
Browse files Browse the repository at this point in the history
The incorrect profile counting was caused by a race between the processing of
the replicated dialog create/update packets. While processing the create
packet, the lock was released before linking the dialog into a profile and
setting the sharing tag. As such, the process that handled the update packet
could insert the dialog into a profile itself, but with an improper sharing tag.

Thanks to 46Labs for reporting and help with troubleshooting this!

(cherry picked from commit 7e623b3)
  • Loading branch information
rvlad-patrascu committed Mar 25, 2020
1 parent d75def4 commit 25d37b6
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions modules/dialog/dlg_replication.c
Expand Up @@ -246,6 +246,16 @@ int dlg_replicated_create(bin_packet_t *packet, struct dlg_cell *cell,
NULL, DLG_DIR_NONE, NULL, 1, 0);
}

dlg->locked_by = process_no;

if ((rc = fetch_dlg_value(dlg, &shtag_dlg_val, &tag_name, 0)) == 0) {
if (shm_str_dup(&dlg->shtag, &tag_name) < 0)
LM_ERR("No more shm memory\n");
} else if (rc == -1)
LM_ERR("Failed to get dlg value for sharing tag\n");

dlg->locked_by = 0;

if (dlg_db_mode == DB_MODE_DELAYED) {
/* to be later removed by timer */
ref_dlg_unsafe(dlg, 1);
Expand All @@ -270,12 +280,6 @@ int dlg_replicated_create(bin_packet_t *packet, struct dlg_cell *cell,
}
}

if ((rc = fetch_dlg_value(dlg, &shtag_dlg_val, &tag_name, 0)) == 0) {
if (shm_str_dup(&dlg->shtag, &tag_name) < 0)
LM_ERR("No more shm memory\n");
} else if (rc == -1)
LM_ERR("Failed to get dlg value for sharing tag\n");

if (profiles.s && profiles.len != 0)
read_dialog_profiles(profiles.s, profiles.len, dlg, 0, 1);

Expand Down

0 comments on commit 25d37b6

Please sign in to comment.