[sr-dev] git:master: usrloc(k): avoid re-initialization of db handler

Daniel-Constantin Mierla miconda at gmail.com
Thu Jul 1 19:21:39 CEST 2010


Module: sip-router
Branch: master
Commit: 8948fe654b83217979b2d2154934a973aefa9ae3
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=8948fe654b83217979b2d2154934a973aefa9ae3

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Thu Jul  1 18:43:54 2010 +0200

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

- can happen if mi commands are used over rpc interface via xmlrpc
  module

---

 modules_k/usrloc/ul_mod.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/modules_k/usrloc/ul_mod.c b/modules_k/usrloc/ul_mod.c
index 3c74008..7a1cdbd 100644
--- a/modules_k/usrloc/ul_mod.c
+++ b/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");




More information about the sr-dev mailing list