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

Function __get_stat

statistics.c:617–648  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

615
616
617stat_var* __get_stat( const str *name, int mod_idx )
618{
619 stat_var *stat;
620 int hash;
621
622 if (collector==NULL || name==0 || name->s==0 || name->len==0)
623 return 0;
624
625 /* compute the hash by name */
626 hash = stat_hash( name );
627
628 /* and look for it , first in the hash for static stats */
629 for( stat=collector->hstats[hash] ; stat ; stat=stat->hnext ) {
630 if ( !stat_is_hidden(stat) && (stat->name.len==name->len) &&
631 (strncasecmp( stat->name.s, name->s, name->len)==0) &&
632 (mod_idx < 0 || stat->mod_idx == mod_idx))
633 return stat;
634 }
635 /* and then in the hash for dynamic stats */
636 lock_start_read((rw_lock_t *)collector->rwl);
637 for( stat=collector->dy_hstats[hash] ; stat ; stat=stat->hnext ) {
638 if ( !stat_is_hidden(stat) && (stat->name.len==name->len) &&
639 (strncasecmp( stat->name.s, name->s, name->len)==0) &&
640 (mod_idx < 0 || stat->mod_idx == mod_idx)) {
641 lock_stop_read((rw_lock_t *)collector->rwl);
642 return stat;
643 }
644 }
645 lock_stop_read((rw_lock_t *)collector->rwl);
646
647 return 0;
648}
649
650stat_var* get_stat( const str *name )
651{

Callers 5

get_statFunction · 0.85
fixup_statFunction · 0.85
w_update_statFunction · 0.85
w_reset_statFunction · 0.85
get_stat_nameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected