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

Function new_stat_series

modules/statistics/statistics.c:1003–1038  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1001}
1002
1003static struct stat_series *new_stat_series(struct stat_series_profile *profile, str *name)
1004{
1005 struct stat_series *ss;
1006
1007 /* we should first check whether there is an overlapping statistic with
1008 * this name, since we are not allowed to have that
1009 */
1010 if (get_stat(name)) {
1011 LM_DBG("%.*s stat already exists!\n", name->len, name->s);
1012 return NULL;
1013 }
1014
1015 ss = shm_malloc(sizeof *ss + name->len + 1 +
1016 profile->slots * sizeof (*ss->slots));
1017 if (!ss) {
1018 LM_ERR("could not allocate new stat series!\n");
1019 return NULL;
1020 }
1021 memset(ss, 0, sizeof (*ss));
1022 lock_init(&ss->lock);
1023 ss->profile = profile;
1024 ss->name = (char *)(ss + 1);
1025 memcpy(ss->name, name->s, name->len);
1026 ss->name[name->len] = 0;
1027 ss->slots = (union stat_series_slot *)(ss->name + name->len + 1);
1028 memset(ss->slots, 0, profile->slots * sizeof (*ss->slots));
1029
1030 /* all good - register the stat now */
1031 if (register_stat2(profile->group.s, ss->name, (stat_var **)get_stat_series,
1032 STAT_NO_RESET|STAT_IS_FUNC, ss, 0) != 0) {
1033 LM_ERR("could not add dynamic statistic\n");
1034 stat_series_free(ss);
1035 return NULL;
1036 }
1037 return ss;
1038}
1039
1040static int update_stat_series(struct stat_series *ss, int value)
1041{

Callers 1

w_update_stat_seriesFunction · 0.85

Calls 5

get_statFunction · 0.85
shm_mallocFunction · 0.85
lock_initFunction · 0.85
register_stat2Function · 0.85
stat_series_freeFunction · 0.85

Tested by

no test coverage detected