From 75810c5549b856dc22b09e024c1859188694b83c Mon Sep 17 00:00:00 2001 From: Razvan Crainea Date: Fri, 8 Mar 2024 16:52:57 +0200 Subject: [PATCH] dialog: call DLGCB_PROCESS_VARS under dlg lock Avoid taking the var logs, as this might lead to a deadlock if one of the callbacks are setting the variable. Credits go to Norman Brandinger (@NormB on GitHub) for reporting it! --- modules/dialog/dlg_replication.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/dialog/dlg_replication.c b/modules/dialog/dlg_replication.c index 9c78221cb42..d8eb248ace2 100644 --- a/modules/dialog/dlg_replication.c +++ b/modules/dialog/dlg_replication.c @@ -741,7 +741,7 @@ int dlg_replicated_value(bin_packet_t *packet) str call_id, name; struct dlg_cell *dlg; unsigned int h_id; - int h_entry, type; + int h_entry, type, ret; struct dlg_entry *d_entry; int_str val; @@ -774,12 +774,13 @@ int dlg_replicated_value(bin_packet_t *packet) return -1; } lock_start_write(dlg->vals_lock); - if (store_dlg_value_unsafe(dlg, &name, &val, type) < 0) + ret = store_dlg_value_unsafe(dlg, &name, &val, type); + lock_stop_write(dlg->vals_lock); + if (ret < 0) LM_ERR("cannot store dlg value\n"); else run_dlg_callbacks(DLGCB_PROCESS_VARS, dlg, NULL, DLG_DIR_NONE, -1, &name, 1, 0); - lock_stop_write(dlg->vals_lock); dlg_unlock(d_table, d_entry);