From a1f3530292f50eae9515736c0aa573031694c342 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Thu, 12 Aug 2021 10:49:16 -0400 Subject: [PATCH] TT#101150 separate out `struct stream_stats` Change-Id: I709060d9e805175bd99173df03e581b593506e15 --- daemon/call.c | 8 ++++---- daemon/call_interfaces.c | 4 ++-- daemon/cdr.c | 2 +- daemon/redis.c | 2 +- include/call.h | 10 +++++----- include/statistics.h | 13 +++++++++++-- 6 files changed, 24 insertions(+), 15 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index 90673c046..c12fde265 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -64,9 +64,9 @@ struct xmlrpc_helper { /* XXX rework these */ -struct stats rtpe_statsps; -struct stats rtpe_stats; -struct stats rtpe_stats_cumulative; +struct global_stats rtpe_statsps; +struct global_stats rtpe_stats; +struct global_stats rtpe_stats_cumulative; rwlock_t rtpe_callhash_lock; GHashTable *rtpe_callhash; @@ -533,7 +533,7 @@ void call_timer(void *ptr) { GList *i, *l; struct rtpengine_list_entry *ke; struct packet_stream *ps; - struct stats tmpstats; + struct global_stats tmpstats; int j, update; struct stream_fd *sfd; struct rtp_stats *rs; diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index 54c58213b..29452c3e7 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -1612,7 +1612,7 @@ const char *call_delete_ng(bencode_item_t *input, bencode_item_t *output) { return NULL; } -static void ng_stats(bencode_item_t *d, const struct stats *s, struct stats *totals) { +static void ng_stats(bencode_item_t *d, const struct stream_stats *s, struct stream_stats *totals) { bencode_dictionary_add_integer(d, "packets", atomic64_get(&s->packets)); bencode_dictionary_add_integer(d, "bytes", atomic64_get(&s->bytes)); bencode_dictionary_add_integer(d, "errors", atomic64_get(&s->errors)); @@ -1637,7 +1637,7 @@ static void ng_stats_stream(bencode_item_t *list, const struct packet_stream *ps struct call_stats *totals) { bencode_item_t *dict = NULL, *flags; - struct stats *s; + struct stream_stats *s; if (!list) goto stats; diff --git a/daemon/cdr.c b/daemon/cdr.c index 8dd5574dd..b16dccdbe 100644 --- a/daemon/cdr.c +++ b/daemon/cdr.c @@ -158,7 +158,7 @@ void cdr_update_entry(struct call* c) { cdrlinecnt, md->index, protocol, addr, cdrlinecnt, md->index, protocol, ps->endpoint.port, cdrlinecnt, md->index, protocol, local_addr, - cdrlinecnt, md->index, protocol, (unsigned int) (ps->sfd ? ps->sfd->fd.localport : 0), + cdrlinecnt, md->index, protocol, (unsigned int) (ps->selected_sfd ? ps->selected_sfd->socket.local.port : 0), cdrlinecnt, md->index, protocol, atomic64_get(&ps->stats.packets), cdrlinecnt, md->index, protocol, diff --git a/daemon/redis.c b/daemon/redis.c index f5f67e135..e06450f25 100644 --- a/daemon/redis.c +++ b/daemon/redis.c @@ -1129,7 +1129,7 @@ static int redis_hash_get_endpoint(struct endpoint *out, const struct redis_hash return 0; } -static int redis_hash_get_stats(struct stats *out, const struct redis_hash *h, const char *k) { +static int redis_hash_get_stats(struct stream_stats *out, const struct redis_hash *h, const char *k) { if (redis_hash_get_a64_f(&out->packets, h, "%s-packets", k)) return -1; if (redis_hash_get_a64_f(&out->bytes, h, "%s-bytes", k)) diff --git a/include/call.h b/include/call.h index 309c7f6cd..404810ef5 100644 --- a/include/call.h +++ b/include/call.h @@ -312,8 +312,8 @@ struct packet_stream { struct send_timer *send_timer; /* RO */ struct jitter_buffer *jb; /* RO */ - struct stats stats; - struct stats kernel_stats; + struct stream_stats stats; + struct stream_stats kernel_stats; unsigned char in_tos_tclass; atomic64 last_packet; GHashTable *rtp_stats; /* LOCK: call->master_lock */ @@ -541,9 +541,9 @@ extern rwlock_t rtpe_callhash_lock; extern GHashTable *rtpe_callhash; extern struct call_iterator_list rtpe_call_iterators[NUM_CALL_ITERATORS]; -extern struct stats rtpe_statsps; /* per second stats, running timer */ -extern struct stats rtpe_stats_cumulative; // total, cumulative -extern struct stats rtpe_stats; /* copied from statsps once a second */ +extern struct global_stats rtpe_statsps; /* per second stats, running timer */ +extern struct global_stats rtpe_stats_cumulative; // total, cumulative +extern struct global_stats rtpe_stats; /* copied from statsps once a second */ #define RTPE_STATS_ADD(field, num) \ do { \ diff --git a/include/statistics.h b/include/statistics.h index 917cb4576..2d34d482a 100644 --- a/include/statistics.h +++ b/include/statistics.h @@ -3,17 +3,26 @@ #include "aux.h" #include "bencode.h" +#include "rtpengine_config.h" struct call; struct packet_stream; -struct stats { +struct stream_stats { atomic64 packets; atomic64 bytes; atomic64 errors; +#if RE_HAS_MEASUREDELAY uint64_t delay_min; uint64_t delay_avg; uint64_t delay_max; +#endif +}; + +struct global_stats { + atomic64 packets; + atomic64 bytes; + atomic64 errors; atomic64 foreign_sessions; // unresponsible via redis notification atomic64 offers; atomic64 answers; @@ -114,7 +123,7 @@ struct stats_metric { struct call_stats { time_t last_packet; - struct stats totals[4]; /* rtp in, rtcp in, rtp out, rtcp out */ + struct stream_stats totals[4]; /* rtp in, rtcp in, rtp out, rtcp out */ }; extern struct totalstats rtpe_totalstats;