瀏覽代碼

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

- can happen if mi commands are used over rpc interface via xmlrpc
  module
Daniel-Constantin Mierla 15 年之前
父節點
當前提交
8948fe654b
共有 1 個文件被更改,包括 6 次插入1 次删除
  1. 6 1
      modules_k/usrloc/ul_mod.c

+ 6 - 1
modules_k/usrloc/ul_mod.c

@@ -340,7 +340,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;
@@ -370,6 +371,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");