Browse code

siptrace: support for using async-insert to store records to database

- new parameter trace_db_mode to control what type of db insert
operation is done

Daniel-Constantin Mierla authored on 10/04/2020 08:17:27
Showing 1 changed files
... ...
@@ -158,7 +158,8 @@ int *trace_on_flag = NULL;
158 158
 int trace_sl_acks = 1;
159 159
 
160 160
 int trace_to_database = 1;
161
-int trace_delayed = 0;
161
+int trace_db_delayed = 0;
162
+int trace_db_mode = 0;
162 163
 
163 164
 int hep_mode_on = 0;
164 165
 int hep_version = 1;
... ...
@@ -249,7 +250,8 @@ static param_export_t params[] = {
249 250
 	{"send_sock_name", PARAM_STR, &trace_send_sock_name_str},
250 251
 	{"hep_version", INT_PARAM, &hep_version},
251 252
 	{"hep_capture_id", INT_PARAM, &hep_capture_id},
252
-	{"trace_delayed", INT_PARAM, &trace_delayed},
253
+	{"trace_delayed", INT_PARAM, &trace_db_delayed},
254
+	{"trace_db_mode", INT_PARAM, &trace_db_mode},
253 255
 	{"trace_init_mode", PARAM_INT, &_siptrace_init_mode},
254 256
 	{"trace_mode", PARAM_INT, &_siptrace_mode},
255 257
 	{0, 0, 0}
... ...
@@ -300,6 +302,10 @@ static int mod_init(void)
300 302
 	}
301 303
 #endif
302 304
 
305
+	if(trace_db_delayed!=0) {
306
+		trace_db_mode = 1;
307
+	}
308
+
303 309
 	if(siptrace_init_rpc() != 0) {
304 310
 		LM_ERR("failed to register RPC commands\n");
305 311
 		return -1;
... ...
@@ -571,9 +577,14 @@ static int sip_trace_insert_db(db_key_t *db_keys, db_val_t *db_vals,
571 577
 		int db_nkeys, char *dtext)
572 578
 {
573 579
 	LM_DBG("storing info - %s\n", dtext);
574
-	if(trace_delayed != 0 && db_funcs.insert_delayed != NULL) {
580
+	if(trace_db_mode = 2 && db_funcs.insert_async != NULL) {
581
+		if(db_funcs.insert_async(db_con, db_keys, db_vals, db_nkeys) < 0) {
582
+			LM_ERR("error storing trace - async - %s\n", dtext);
583
+			return -1;
584
+		}
585
+	} else if(trace_db_mode != 1 && db_funcs.insert_delayed != NULL) {
575 586
 		if(db_funcs.insert_delayed(db_con, db_keys, db_vals, db_nkeys) < 0) {
576
-			LM_ERR("error storing trace - %s\n", dtext);
587
+			LM_ERR("error storing trace - delayed - %s\n", dtext);
577 588
 			return -1;
578 589
 		}
579 590
 	} else {