Browse code

userblacklist: avoid double child initialization

- safety check for cases when xmlrpc module is used to run mi commands

Daniel-Constantin Mierla authored on 01/07/2010 16:57:09
Showing 1 changed files
... ...
@@ -662,21 +662,16 @@ static int child_init(int rank)
662 662
 	if (rank==PROC_INIT || rank==PROC_MAIN || rank==PROC_TCP_MAIN)
663 663
 		return 0; /* do nothing for the main process */
664 664
 
665
-	if (userblacklist_db_open() != 0) return -1;
666
-	dtrie_root=dtrie_init(10);
667
-	if (dtrie_root == NULL) {
668
-		LM_ERR("could not initialize data");
669
-		return -1;
670
-	}
671
-	/* because we've added new sources during the fixup */
672
-	if (reload_sources() != 0) return -1;
673
-
674
-	return 0;
665
+	return mi_child_init();
675 666
 }
676 667
 
677 668
 
669
+static int userblacklist_child_initialized = 0;
670
+
678 671
 static int mi_child_init(void)
679 672
 {
673
+	if(userblacklist_child_initialized)
674
+		return 0;
680 675
 	if (userblacklist_db_open() != 0) return -1;
681 676
 	dtrie_root=dtrie_init(10);
682 677
 	if (dtrie_root == NULL) {
... ...
@@ -686,6 +681,8 @@ static int mi_child_init(void)
686 681
 	/* because we've added new sources during the fixup */
687 682
 	if (reload_sources() != 0) return -1;
688 683
 
684
+	userblacklist_child_initialized = 1;
685
+
689 686
 	return 0;
690 687
 }
691 688