Skip to content

Commit 25d37b6

Browse files
dialog: fix a replicated profiles counting issue
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)
1 parent d75def4 commit 25d37b6

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

modules/dialog/dlg_replication.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,16 @@ int dlg_replicated_create(bin_packet_t *packet, struct dlg_cell *cell,
246246
NULL, DLG_DIR_NONE, NULL, 1, 0);
247247
}
248248

249+
dlg->locked_by = process_no;
250+
251+
if ((rc = fetch_dlg_value(dlg, &shtag_dlg_val, &tag_name, 0)) == 0) {
252+
if (shm_str_dup(&dlg->shtag, &tag_name) < 0)
253+
LM_ERR("No more shm memory\n");
254+
} else if (rc == -1)
255+
LM_ERR("Failed to get dlg value for sharing tag\n");
256+
257+
dlg->locked_by = 0;
258+
249259
if (dlg_db_mode == DB_MODE_DELAYED) {
250260
/* to be later removed by timer */
251261
ref_dlg_unsafe(dlg, 1);
@@ -270,12 +280,6 @@ int dlg_replicated_create(bin_packet_t *packet, struct dlg_cell *cell,
270280
}
271281
}
272282

273-
if ((rc = fetch_dlg_value(dlg, &shtag_dlg_val, &tag_name, 0)) == 0) {
274-
if (shm_str_dup(&dlg->shtag, &tag_name) < 0)
275-
LM_ERR("No more shm memory\n");
276-
} else if (rc == -1)
277-
LM_ERR("Failed to get dlg value for sharing tag\n");
278-
279283
if (profiles.s && profiles.len != 0)
280284
read_dialog_profiles(profiles.s, profiles.len, dlg, 0, 1);
281285

0 commit comments

Comments
 (0)