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

Function w_update_stat

modules/statistics/statistics.c:590–635  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

588}
589
590static int w_update_stat(struct sip_msg *msg, struct stat_param *sp, int *n)
591{
592 stat_var *stat;
593 str name, group;
594 int grp_idx __attribute__((unused));
595
596 /* update with 0 value makes no sense */
597 if (*n==0)
598 return 1;
599
600 if (sp->type==STAT_PARAM_TYPE_STAT) {
601 /* we have the statistic */
602 update_stat( sp->u.stat, (long)*n);
603 return 1;
604 }
605
606 LM_DBG("needed statistic is <%.*s>\n", sp->u.name->len, sp->u.name->s);
607
608 if (resolve_stat(sp->u.name, &group, &name, &grp_idx) != 0) {
609 return E_CFG;
610 }
611
612 stat = __get_stat(&name, grp_idx);
613 if ( stat==NULL ) {
614 /* stats not found -> create it */
615 LM_DBG("creating statistic <%.*s>\n", sp->u.name->len, sp->u.name->s);
616
617 if (grp_idx > 0) {
618 if (__register_dynamic_stat(&group, &name, &stat) != 0) {
619 LM_ERR("failed to create statistic <%.*s:%.*s>\n",
620 group.len, group.s, name.len, name.s);
621 return -1;
622 }
623 } else {
624 if (register_dynamic_stat(&name, &stat)!=0) {
625 LM_ERR("failed to create statistic <%.*s>\n",
626 name.len, name.s);
627 return -1;
628 }
629 }
630 }
631
632 /* statistic exists ! */
633 update_stat( stat, (long)*n);
634 return 1;
635}
636
637static int fixup_update_stat_series(void** param)
638{

Callers

nothing calls this directly

Calls 4

resolve_statFunction · 0.85
__get_statFunction · 0.85
__register_dynamic_statFunction · 0.85
register_dynamic_statFunction · 0.85

Tested by

no test coverage detected