Browse Source

usrloc(k): avoid re-initialization of db handler

- can happen if mi commands are used over rpc interface via xmlrpc
  module
(cherry picked from commit 8948fe654b83217979b2d2154934a973aefa9ae3)
Daniel-Constantin Mierla 15 years ago
parent
commit
705a61b1b9
1 changed files with 6 additions and 1 deletions
  1. 6 1
      modules_k/usrloc/ul_mod.c

+ 6 - 1
modules_k/usrloc/ul_mod.c

@@ -339,7 +339,8 @@ static int child_init(int _rank)
 			break;
 	}
 
-	ul_dbh = ul_dbf.init(&db_url); /* Get a new database connection */
+	if (!ul_dbh)
+		ul_dbh = ul_dbf.init(&db_url); /* Get a new database connection */
 	if (!ul_dbh) {
 		LM_ERR("child(%d): failed to connect to database\n", _rank);
 		return -1;
@@ -369,6 +370,10 @@ static int mi_child_init(void)
 		return 0;
 
 	if (db_mode != NO_DB) {
+		if (ul_dbh) {
+			done = 1;
+			return 0;
+		}
 		ul_dbh = ul_dbf.init(&db_url);
 		if (!ul_dbh) {
 			LM_ERR("failed to connect to database\n");