Преглед на файлове

userblacklist: avoid double child initialization

- safety check for cases when xmlrpc module is used to run mi commands
(cherry picked from commit 3f2ca85f4254746240177830e85a87b81d8cfd85)
Daniel-Constantin Mierla преди 15 години
родител
ревизия
a01e7edab7
променени са 1 файла, в които са добавени 7 реда и са изтрити 10 реда
  1. 7 10
      modules_k/userblacklist/userblacklist.c

+ 7 - 10
modules_k/userblacklist/userblacklist.c

@@ -620,21 +620,16 @@ static int child_init(int rank)
 	if (rank==PROC_INIT || rank==PROC_MAIN || rank==PROC_TCP_MAIN)
 		return 0; /* do nothing for the main process */
 
-	if (userblacklist_db_open() != 0) return -1;
-	dtrie_root=dtrie_init(10);
-	if (dtrie_root == NULL) {
-		LM_ERR("could not initialize data");
-		return -1;
-	}
-	/* because we've added new sources during the fixup */
-	if (reload_sources() != 0) return -1;
-
-	return 0;
+	return mi_child_init();
 }
 
 
+static int userblacklist_child_initialized = 0;
+
 static int mi_child_init(void)
 {
+	if(userblacklist_child_initialized)
+		return 0;
 	if (userblacklist_db_open() != 0) return -1;
 	dtrie_root=dtrie_init(10);
 	if (dtrie_root == NULL) {
@@ -644,6 +639,8 @@ static int mi_child_init(void)
 	/* because we've added new sources during the fixup */
 	if (reload_sources() != 0) return -1;
 
+	userblacklist_child_initialized = 1;
+
 	return 0;
 }