Skip to content

Commit

Permalink
dialog: access dialog table entry by reference for dmq_send_all_dlgs
Browse files Browse the repository at this point in the history
- avoid race conditions to get and release the lock when entry structure
is copied in local variable
- GH #2570, GH #2547
  • Loading branch information
patrick-wakano authored and miconda committed Dec 2, 2020
1 parent 04dc5d6 commit 4183b86
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/modules/dialog/dlg_dmq.c
Expand Up @@ -646,22 +646,22 @@ int dlg_dmq_replicate_action(dlg_dmq_action_t action, dlg_cell_t* dlg,

int dmq_send_all_dlgs(dmq_node_t* dmq_node) {
int index;
dlg_entry_t entry;
dlg_entry_t *entry;
dlg_cell_t *dlg;

LM_DBG("sending all dialogs \n");

for(index = 0; index< d_table->size; index++){
/* lock the whole entry */
entry = (d_table->entries)[index];
dlg_lock( d_table, &entry);
entry = &d_table->entries[index];
dlg_lock( d_table, entry);

for(dlg = entry.first; dlg != NULL; dlg = dlg->next){
for(dlg = entry->first; dlg != NULL; dlg = dlg->next){
dlg->dflags |= DLG_FLAG_CHANGED_PROF;
dlg_dmq_replicate_action(DLG_DMQ_UPDATE, dlg, 0, dmq_node);
}

dlg_unlock( d_table, &entry);
dlg_unlock( d_table, entry);
}

return 0;
Expand Down

0 comments on commit 4183b86

Please sign in to comment.