[SR-Dev] git:master: dialog(k): port db setup to different child_init behaviour on sr

Henning Westerholt henning.westerholt at 1und1.de
Thu May 7 15:28:36 CEST 2009


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

Author: Henning Westerholt <henning.westerholt at 1und1.de>
Committer: Henning Westerholt <henning.westerholt at 1und1.de>
Date:   Thu May  7 15:09:09 2009 +0200

dialog(k): port db setup to different child_init behaviour on sr

- port db setup to different child_init behaviour on sr, here child_init
  is called two times for PROC_MAIN
- don't open a DB connection in PROC_MAIN in DB_MODE_DELAYED
- don't close the connection during mod_destroy if nothing was opened

---

 modules_k/dialog/dialog.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/modules_k/dialog/dialog.c b/modules_k/dialog/dialog.c
index 1e6c5de..caae794 100644
--- a/modules_k/dialog/dialog.c
+++ b/modules_k/dialog/dialog.c
@@ -570,10 +570,9 @@ static int child_init(int rank)
 		if_update_stat(dlg_enable_stats, early_dlgs, early_dlgs_cnt);
 	}
 
-	if ( (dlg_db_mode==DB_MODE_REALTIME && (rank>0 || rank==PROC_TIMER)) ||
-	(dlg_db_mode==DB_MODE_SHUTDOWN && (rank==PROC_MAIN)) ||
-	(dlg_db_mode==DB_MODE_DELAYED && (rank==PROC_MAIN || rank==PROC_TIMER ||
-	rank>0) )){
+	if ( ((dlg_db_mode==DB_MODE_REALTIME || DB_MODE_DELAYED) &&
+	(rank>0 || rank==PROC_TIMER)) ||
+	(dlg_db_mode==DB_MODE_SHUTDOWN && (rank==PROC_MAIN)) ) {
 		if ( dlg_connect_db(&db_url) ) {
 			LM_ERR("failed to connect to database (rank=%d)\n",rank);
 			return -1;
@@ -584,6 +583,11 @@ static int child_init(int rank)
 	 * for the rest of the processes will be the same as DB_MODE_NONE */
 	if (dlg_db_mode==DB_MODE_SHUTDOWN && rank!=PROC_MAIN)
 		dlg_db_mode = DB_MODE_NONE;
+	/* in DB_MODE_REALTIME and DB_MODE_DELAYED the PROC_MAIN or the ones
+	 * with negative rank will have no db connection */
+	if ( (dlg_db_mode==DB_MODE_REALTIME || dlg_db_mode==DB_MODE_DELAYED) &&
+			(rank<0 || rank==PROC_MAIN))
+		dlg_db_mode = DB_MODE_NONE;
 
 	return 0;
 }




More information about the sr-dev mailing list