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

Function w_reset_stat

modules/statistics/statistics.c:652–693  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

650
651
652static int w_reset_stat(struct sip_msg *msg, struct stat_param* sp)
653{
654 stat_var *stat;
655 str group, name;
656 int grp_idx __attribute__((unused));
657
658 if (sp->type==STAT_PARAM_TYPE_STAT) {
659 /* we have the statistic */
660 reset_stat( sp->u.stat);
661 return 1;
662 }
663
664 LM_DBG("needed statistic is <%.*s>\n", sp->u.name->len, sp->u.name->s);
665
666 if (resolve_stat(sp->u.name, &group, &name, &grp_idx) != 0) {
667 return E_CFG;
668 }
669
670 stat = __get_stat(&name, grp_idx);
671 if ( stat==NULL ) {
672 /* stats not found -> create it */
673 LM_DBG("creating statistic <%.*s>\n", sp->u.name->len, sp->u.name->s);
674
675 if (grp_idx > 0) {
676 if (__register_dynamic_stat(&group, &name, &stat) != 0) {
677 LM_ERR("failed to create statistic <%.*s:%.*s>\n",
678 group.len, group.s, name.len, name.s);
679 return -1;
680 }
681 } else {
682 if (register_dynamic_stat( &name, &stat )!=0) {
683 LM_ERR("failed to create statistic <%.*s>\n",
684 name.len, name.s);
685 return -1;
686 }
687 }
688 }
689
690 /* statistic exists ! */
691 reset_stat( stat );
692 return 1;
693}
694
695
696int pv_parse_name(pv_spec_p sp, const str *in)

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