Explorar o código

userblacklist: avoid double child initialization

- safety check for cases when xmlrpc module is used to run mi commands
Daniel-Constantin Mierla %!s(int64=15) %!d(string=hai) anos
pai
achega
3f2ca85f42
Modificáronse 1 ficheiros con 7 adicións e 10 borrados
  1. 7 10
      modules_k/userblacklist/userblacklist.c

+ 7 - 10
modules_k/userblacklist/userblacklist.c

@@ -662,21 +662,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) {
@@ -686,6 +681,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;
 }