Browse code

dialog: open db connection in POSTCHILDINIT callback for DB_MODE_SHUTDOWN

(cherry picked from commit 1ff86ffceede46c7a67fec92c8319c34c916a545)

Daniel-Constantin Mierla authored on 09/05/2022 07:16:49
Showing 1 changed files
... ...
@@ -738,6 +738,10 @@ static int mod_init(void)
738 738
 		return -1;
739 739
 	}
740 740
 
741
+	if(dlg_db_mode==DB_MODE_SHUTDOWN) {
742
+		ksr_module_set_flag(KSRMOD_FLAG_POSTCHILDINIT);
743
+	}
744
+
741 745
 	return 0;
742 746
 }
743 747
 
... ...
@@ -777,9 +781,9 @@ static int child_init(int rank)
777 781
 		}
778 782
 	}
779 783
 
780
-	if ( ((dlg_db_mode==DB_MODE_REALTIME || dlg_db_mode==DB_MODE_DELAYED) &&
781
-	(rank>0 || rank==PROC_TIMER || rank==PROC_RPC)) ||
782
-	(dlg_db_mode==DB_MODE_SHUTDOWN && (rank==PROC_MAIN)) ) {
784
+	if ( ((dlg_db_mode==DB_MODE_REALTIME || dlg_db_mode==DB_MODE_DELAYED)
785
+				&& (rank>0 || rank==PROC_TIMER || rank==PROC_RPC))
786
+			|| (dlg_db_mode==DB_MODE_SHUTDOWN && (rank==PROC_POSTCHILDINIT)) ) {
783 787
 		if ( dlg_connect_db(&db_url) ) {
784 788
 			LM_ERR("failed to connect to database (rank=%d)\n",rank);
785 789
 			return -1;