فهرست منبع

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)
 	if (rank==PROC_INIT || rank==PROC_MAIN || rank==PROC_TCP_MAIN)
 		return 0; /* do nothing for the main process */
 		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)
 static int mi_child_init(void)
 {
 {
+	if(userblacklist_child_initialized)
+		return 0;
 	if (userblacklist_db_open() != 0) return -1;
 	if (userblacklist_db_open() != 0) return -1;
 	dtrie_root=dtrie_init(10);
 	dtrie_root=dtrie_init(10);
 	if (dtrie_root == NULL) {
 	if (dtrie_root == NULL) {
@@ -644,6 +639,8 @@ static int mi_child_init(void)
 	/* because we've added new sources during the fixup */
 	/* because we've added new sources during the fixup */
 	if (reload_sources() != 0) return -1;
 	if (reload_sources() != 0) return -1;
 
 
+	userblacklist_child_initialized = 1;
+
 	return 0;
 	return 0;
 }
 }