Skip to content

Commit

Permalink
siptrace: support for using async-insert to store records to database
Browse files Browse the repository at this point in the history
- new parameter trace_db_mode to control what type of db insert
operation is done
  • Loading branch information
miconda committed Apr 10, 2020
1 parent bb2894a commit e3a298e
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/modules/siptrace/siptrace.c
Expand Up @@ -158,7 +158,8 @@ int *trace_on_flag = NULL;
int trace_sl_acks = 1;

int trace_to_database = 1;
int trace_delayed = 0;
int trace_db_delayed = 0;
int trace_db_mode = 0;

int hep_mode_on = 0;
int hep_version = 1;
Expand Down Expand Up @@ -249,7 +250,8 @@ static param_export_t params[] = {
{"send_sock_name", PARAM_STR, &trace_send_sock_name_str},
{"hep_version", INT_PARAM, &hep_version},
{"hep_capture_id", INT_PARAM, &hep_capture_id},
{"trace_delayed", INT_PARAM, &trace_delayed},
{"trace_delayed", INT_PARAM, &trace_db_delayed},
{"trace_db_mode", INT_PARAM, &trace_db_mode},
{"trace_init_mode", PARAM_INT, &_siptrace_init_mode},
{"trace_mode", PARAM_INT, &_siptrace_mode},
{0, 0, 0}
Expand Down Expand Up @@ -300,6 +302,10 @@ static int mod_init(void)
}
#endif

if(trace_db_delayed!=0) {
trace_db_mode = 1;
}

if(siptrace_init_rpc() != 0) {
LM_ERR("failed to register RPC commands\n");
return -1;
Expand Down Expand Up @@ -571,9 +577,14 @@ static int sip_trace_insert_db(db_key_t *db_keys, db_val_t *db_vals,
int db_nkeys, char *dtext)
{
LM_DBG("storing info - %s\n", dtext);
if(trace_delayed != 0 && db_funcs.insert_delayed != NULL) {
if(trace_db_mode = 2 && db_funcs.insert_async != NULL) {
if(db_funcs.insert_async(db_con, db_keys, db_vals, db_nkeys) < 0) {
LM_ERR("error storing trace - async - %s\n", dtext);
return -1;
}
} else if(trace_db_mode != 1 && db_funcs.insert_delayed != NULL) {
if(db_funcs.insert_delayed(db_con, db_keys, db_vals, db_nkeys) < 0) {
LM_ERR("error storing trace - %s\n", dtext);
LM_ERR("error storing trace - delayed - %s\n", dtext);
return -1;
}
} else {
Expand Down

0 comments on commit e3a298e

Please sign in to comment.