Module: sip-router
Branch: master
Commit: 3f2ca85f4254746240177830e85a87b81d8cfd85
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=3f2ca85…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Thu Jul 1 18:57:09 2010 +0200
userblacklist: avoid double child initialization
- safety check for cases when xmlrpc module is used to run mi commands
---
modules_k/userblacklist/userblacklist.c | 17 +++++++----------
1 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/modules_k/userblacklist/userblacklist.c
b/modules_k/userblacklist/userblacklist.c
index 51cb4db..531aed2 100644
--- a/modules_k/userblacklist/userblacklist.c
+++ b/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;
}