diff --git a/daemon/call.c b/daemon/call.c index 004d5e43d..5dd79de1f 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -64,6 +64,7 @@ struct xmlrpc_helper { /* XXX rework these */ struct stats rtpe_statsps; struct stats rtpe_stats; +struct stats rtpe_stats_cumulative; rwlock_t rtpe_callhash_lock; GHashTable *rtpe_callhash; @@ -494,8 +495,7 @@ destroy: diff_ ## x = 0; \ else \ diff_ ## x = ke->stats.x - ks_val; \ - atomic64_add(&ps->stats.x, diff_ ## x); \ - atomic64_add(&rtpe_statsps.x, diff_ ## x); \ + RTPE_STATS_INC(x, diff_ ## x); \ } while (0) static void update_requests_per_second_stats(struct requests_ps *request, uint64_t new_val) { diff --git a/daemon/media_socket.c b/daemon/media_socket.c index 08f1c493b..46ea24954 100644 --- a/daemon/media_socket.c +++ b/daemon/media_socket.c @@ -1636,7 +1636,7 @@ static void media_packet_rtp(struct packet_handler_ctx *phc) phc->payload_type, FMT_M(endpoint_print_buf(&phc->mp.fsin))); atomic64_inc(&phc->mp.stream->stats.errors); - atomic64_inc(&rtpe_statsps.errors); + RTPE_STATS_INC(errors, 1); } else { atomic64_inc(&rtp_s->packets); @@ -2071,7 +2071,7 @@ static int stream_packet(struct packet_handler_ctx *phc) { ilog(LOG_WARNING | LOG_FLAG_LIMIT, "Media packet from %s%s%s discarded due to lack of sink", FMT_M(endpoint_print_buf(&phc->mp.fsin))); atomic64_inc(&phc->mp.stream->stats.errors); - atomic64_inc(&rtpe_statsps.errors); + RTPE_STATS_INC(errors, 1); goto out; } @@ -2132,7 +2132,7 @@ static int stream_packet(struct packet_handler_ctx *phc) { ret = -errno; ilog(LOG_DEBUG,"Error when sending message. Error: %s",strerror(errno)); atomic64_inc(&phc->mp.stream->stats.errors); - atomic64_inc(&rtpe_statsps.errors); + RTPE_STATS_INC(errors, 1); goto out; } @@ -2142,8 +2142,8 @@ drop: atomic64_inc(&phc->mp.stream->stats.packets); atomic64_add(&phc->mp.stream->stats.bytes, phc->s.len); atomic64_set(&phc->mp.stream->last_packet, rtpe_now.tv_sec); - atomic64_inc(&rtpe_statsps.packets); - atomic64_add(&rtpe_statsps.bytes, phc->s.len); + RTPE_STATS_INC(packets, 1); + RTPE_STATS_INC(bytes, phc->s.len); out: if (phc->unkernelize) { diff --git a/include/call.h b/include/call.h index 8afc54c91..9792f95d8 100644 --- a/include/call.h +++ b/include/call.h @@ -493,8 +493,15 @@ 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 */ +#define RTPE_STATS_INC(field, num) \ + do { \ + atomic64_add(&rtpe_statsps.field, num); \ + atomic64_add(&rtpe_stats_cumulative.field, num); \ + } while (0) + int call_init(void); void call_free(void);