Skip to content

Commit

Permalink
dialog: call DLGCB_PROCESS_VARS under dlg lock
Browse files Browse the repository at this point in the history
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!
  • Loading branch information
razvancrainea authored and bogdan-iancu committed Apr 18, 2024
1 parent 99d853b commit 52f3cdf
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions modules/dialog/dlg_replication.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 52f3cdf

Please sign in to comment.