MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / acc_db_request

Function acc_db_request

modules/acc/acc.c:514–648  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

512
513
514int acc_db_request( struct sip_msg *rq, struct sip_msg *rpl,
515 query_list_t **ins_list, int missed)
516{
517 /**
518 * The list of people which have bugfixed these PS:
519 * d837ed865d - 2016, Bogdan. Fix crash.
520 * a250191728 - 2017, Razvan. Fix crash.
521 * latest - 2020, Liviu. Fix crash.
522 */
523 static db_ps_t my_ps_ins = NULL;
524 static db_ps_t my_ps_ins2 = NULL;
525 static db_ps_t my_ps_ins3 = NULL;
526 static db_ps_t my_ps = NULL;
527 static db_ps_t my_ps2 = NULL;
528 static db_ps_t my_ps3 = NULL;
529 db_ps_t *ps;
530 int m;
531 int n = 0;
532 int i, j;
533 unsigned int _setup_time=0;
534 unsigned int extra_start;
535
536 struct acc_extra* extra;
537 acc_ctx_t* ctx = try_fetch_ctx();
538
539 if (!acc_dbf.use_table || !acc_dbf.insert) {
540 LM_ERR("database not loaded! Probably database url not defined!\n");
541 return -1;
542 }
543
544 /* formatted database columns */
545 m = core2strar( rq, val_arr );
546
547 for(i = 0; i < m; i++)
548 VAL_STR(db_vals+i) = val_arr[i];
549
550 /* time value */
551 VAL_TIME(db_vals+(m++)) = acc_env.ts.tv_sec;
552
553 /* just count the values to do other ops inside lock */
554 if (ctx) {
555 _setup_time = time(NULL) - ctx->created;
556
557 extra_start=m;
558 for (extra=db_extra_tags; extra; extra=extra->next, ++m);
559 for( extra=db_leg_tags, n=m; extra; extra=extra->next, n++);
560
561 VAL_INT(db_vals+n) = _setup_time;
562
563 VAL_NULL(db_vals+n+1) = 0;
564 VAL_TIME(db_vals+n+1) = ctx->created;
565
566 n+=2;
567
568 if (!missed) {
569 /* duration and ms_duration */
570 VAL_INT(db_vals+n) = 0;
571 VAL_INT(db_vals+n+1) = 0;

Callers 3

w_acc_db_requestFunction · 0.85
on_missedFunction · 0.85
acc_onreplyFunction · 0.85

Calls 3

try_fetch_ctxFunction · 0.85
core2strarFunction · 0.85
con_set_inslistFunction · 0.85

Tested by

no test coverage detected