Browse Source

dialog Make sure statistics are updated when initializing from database

Issue #424
Olle E. Johansson 9 years ago
parent
commit
b0cd09d2b4

+ 3 - 0
modules/dialog/dlg_db_handler.c

@@ -37,6 +37,7 @@
 #include "../../lib/srdb1/db.h"
 #include "../../str.h"
 #include "../../socket_info.h"
+#include "../../lib/kcore/statistics.h"
 #include "dlg_hash.h"
 #include "dlg_var.h"
 #include "dlg_profile.h"
@@ -377,8 +378,10 @@ static int load_dialog_info_from_db(int dlg_hash_size, int fetch_num_rows)
 			if (dlg->state==DLG_STATE_CONFIRMED_NA ||
 			dlg->state==DLG_STATE_CONFIRMED) {
 				active_dlgs_cnt++;
+				if_update_stat(dlg_enable_stats, active_dlgs, 1);
 			} else if (dlg->state==DLG_STATE_EARLY) {
 				early_dlgs_cnt++;
+				if_update_stat(dlg_enable_stats, early_dlgs, 1);
 			}
 
 			dlg->tl.timeout = (unsigned int)(VAL_INT(values+9));

+ 0 - 5
modules/dialog/dlg_handlers.c

@@ -70,11 +70,6 @@ int              spiral_detected = -1;
 
 extern struct rr_binds d_rrb;		/*!< binding to record-routing module */
 
-/* statistic variables */
-extern stat_var *early_dlgs; 		/*!< number of early dialogs */
-extern stat_var *processed_dlgs;	/*!< number of processed dialogs */
-extern stat_var *expired_dlgs;		/*!< number of expired dialogs */
-extern stat_var *failed_dlgs;		/*!< number of failed dialogs */
 
 extern pv_elem_t *ruri_param_model;	/*!< pv-string to get r-uri */
 

+ 1 - 0
modules/dialog/dlg_hash.c

@@ -35,6 +35,7 @@
 #include "../../ut.h"
 #include "../../hashes.h"
 #include "../../lib/kmi/mi.h"
+#include "../../lib/kcore/statistics.h"
 #include "dlg_timer.h"
 #include "dlg_var.h"
 #include "dlg_hash.h"

+ 1 - 0
modules/dialog/dlg_var.c

@@ -29,6 +29,7 @@
 #include "../../route.h"
 #include "../../script_cb.h"
 #include "../../pvapi.h"
+#include "../../lib/kcore/statistics.h"
 
 #include "dlg_var.h"
 #include "dlg_hash.h"

+ 7 - 0
modules/dialog/dlg_var.h

@@ -76,6 +76,13 @@ int set_dlg_variable_unsafe(dlg_cell_t *dlg, str *key, str *val);
 
 extern dlg_ctx_t _dlg_ctx;
 
+/* statistic variables */
+extern stat_var *active_dlgs;		/*!< number of active dialogs */
+extern stat_var *early_dlgs; 		/*!< number of early dialogs */
+extern stat_var *processed_dlgs;	/*!< number of processed dialogs */
+extern stat_var *expired_dlgs;		/*!< number of expired dialogs */
+extern stat_var *failed_dlgs;		/*!< number of failed dialogs */
+
 int pv_get_dlg_ctx(sip_msg_t *msg,  pv_param_t *param,
 		pv_value_t *res);
 int pv_set_dlg_ctx(sip_msg_t *msg, pv_param_t *param,