Browse code

dialog: access dialog table entry by reference for dmq_send_all_dlgs

- avoid race conditions to get and release the lock when entry structure
is copied in local variable
- GH #2570, GH #2547

Patrick Wakano authored on 02/12/2020 12:58:18 • Daniel-Constantin Mierla committed on 02/12/2020 12:58:18
Showing 1 changed files
... ...
@@ -646,22 +646,22 @@ error:
646 646
 
647 647
 int dmq_send_all_dlgs(dmq_node_t* dmq_node) {
648 648
 	int index;
649
-	dlg_entry_t entry;
649
+	dlg_entry_t *entry;
650 650
 	dlg_cell_t *dlg;
651 651
 
652 652
 	LM_DBG("sending all dialogs \n");
653 653
 
654 654
 	for(index = 0; index< d_table->size; index++){
655 655
 		/* lock the whole entry */
656
-		entry = (d_table->entries)[index];
657
-		dlg_lock( d_table, &entry);
656
+		entry = &d_table->entries[index];
657
+		dlg_lock( d_table, entry);
658 658
 
659
-		for(dlg = entry.first; dlg != NULL; dlg = dlg->next){
659
+		for(dlg = entry->first; dlg != NULL; dlg = dlg->next){
660 660
 			dlg->dflags |= DLG_FLAG_CHANGED_PROF;
661 661
 			dlg_dmq_replicate_action(DLG_DMQ_UPDATE, dlg, 0, dmq_node);
662 662
 		}
663 663
 
664
-		dlg_unlock( d_table, &entry);
664
+		dlg_unlock( d_table, entry);
665 665
 	}
666 666
 
667 667
 	return 0;