diff --git a/daemon/aux.h b/daemon/aux.h index b5092526d..6b748bae1 100644 --- a/daemon/aux.h +++ b/daemon/aux.h @@ -516,42 +516,42 @@ int in6_addr_eq(const void *a, const void *b); typedef struct { void *p; -} atomic_uint64; +} atomic64; -INLINE u_int64_t atomic_uint64_get(const atomic_uint64 *u) { +INLINE u_int64_t atomic64_get(const atomic64 *u) { return (u_int64_t) g_atomic_pointer_get(&u->p); } -INLINE u_int64_t atomic_uint64_get_na(const atomic_uint64 *u) { +INLINE u_int64_t atomic64_get_na(const atomic64 *u) { return (u_int64_t) u->p; } -INLINE void atomic_uint64_set(atomic_uint64 *u, u_int64_t a) { +INLINE void atomic64_set(atomic64 *u, u_int64_t a) { g_atomic_pointer_set(&u->p, (void *) a); } -INLINE void atomic_uint64_set_na(atomic_uint64 *u, u_int64_t a) { +INLINE void atomic64_set_na(atomic64 *u, u_int64_t a) { u->p = (void *) a; } -INLINE void atomic_uint64_inc(atomic_uint64 *u) { +INLINE void atomic64_inc(atomic64 *u) { g_atomic_pointer_add(&u->p, 1); } -INLINE void atomic_uint64_add(atomic_uint64 *u, u_int64_t a) { +INLINE void atomic64_add(atomic64 *u, u_int64_t a) { g_atomic_pointer_add(&u->p, a); } -INLINE void atomic_uint64_add_na(atomic_uint64 *u, u_int64_t a) { +INLINE void atomic64_add_na(atomic64 *u, u_int64_t a) { u->p = (void *) (((u_int64_t) u->p) + a); } -INLINE u_int64_t atomic_uint64_get_set(atomic_uint64 *u, u_int64_t a) { +INLINE u_int64_t atomic64_get_set(atomic64 *u, u_int64_t a) { u_int64_t old; do { - old = atomic_uint64_get(u); + old = atomic64_get(u); if (g_atomic_pointer_compare_and_exchange(&u->p, (void *) old, (void *) a)) return old; } while (1); } -INLINE void atomic_uint64_local_copy_zero(atomic_uint64 *dst, atomic_uint64 *src) { - atomic_uint64_set_na(dst, atomic_uint64_get_set(src, 0)); +INLINE void atomic64_local_copy_zero(atomic64 *dst, atomic64 *src) { + atomic64_set_na(dst, atomic64_get_set(src, 0)); } -#define atomic_uint64_local_copy_zero_struct(d, s, member) \ - atomic_uint64_local_copy_zero(&((d)->member), &((s)->member)) +#define atomic64_local_copy_zero_struct(d, s, member) \ + atomic64_local_copy_zero(&((d)->member), &((s)->member)) #endif diff --git a/daemon/call.c b/daemon/call.c index b81755b88..9a31e08f2 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -687,8 +687,8 @@ loop_ok: if (!sink || !sink->sfd || !out_srtp->sfd || !in_srtp->sfd) { ilog(LOG_WARNING, "RTP packet from %s discarded", addr); - atomic_uint64_inc(&stream->stats.errors); - atomic_uint64_inc(&cm->statsps.errors); + atomic64_inc(&stream->stats.errors); + atomic64_inc(&cm->statsps.errors); goto unlock_out; } @@ -752,7 +752,7 @@ use_cand: mutex_unlock(&stream->out_lock); if (tmp && PS_ISSET(stream, STRICT_SOURCE)) { - atomic_uint64_inc(&stream->stats.errors); + atomic64_inc(&stream->stats.errors); goto drop; } } @@ -841,8 +841,8 @@ forward: if (ret == -1) { ret = -errno; ilog(LOG_DEBUG,"Error when sending message. Error: %s",strerror(errno)); - atomic_uint64_inc(&stream->stats.errors); - atomic_uint64_inc(&cm->statsps.errors); + atomic64_inc(&stream->stats.errors); + atomic64_inc(&cm->statsps.errors); goto out; } @@ -852,11 +852,11 @@ drop: if (sink) mutex_unlock(&sink->out_lock); ret = 0; - atomic_uint64_inc(&stream->stats.packets); - atomic_uint64_add(&stream->stats.bytes, s->len); - atomic_uint64_set(&stream->last_packet, poller_now); - atomic_uint64_inc(&cm->statsps.packets); - atomic_uint64_add(&cm->statsps.bytes, s->len); + atomic64_inc(&stream->stats.packets); + atomic64_add(&stream->stats.bytes, s->len); + atomic64_set(&stream->last_packet, poller_now); + atomic64_inc(&cm->statsps.packets); + atomic64_add(&cm->statsps.bytes, s->len); out: if (ret == 0 && update) @@ -1071,7 +1071,7 @@ no_sfd: tmp_t_reason = 2; } - if (poller_now - atomic_uint64_get(&ps->last_packet) < check) + if (poller_now - atomic64_get(&ps->last_packet) < check) good = 1; next: @@ -1281,13 +1281,13 @@ destroy: #define DS(x) do { \ u_int64_t ks_val, d; \ - ks_val = atomic_uint64_get(&ps->kernel_stats.x); \ + ks_val = atomic64_get(&ps->kernel_stats.x); \ if (ke->stats.x < ks_val) \ d = 0; \ else \ d = ke->stats.x - ks_val; \ - atomic_uint64_add(&ps->stats.x, d); \ - atomic_uint64_add(&m->statsps.x, d); \ + atomic64_add(&ps->stats.x, d); \ + atomic64_add(&m->statsps.x, d); \ } while (0) static void callmaster_timer(void *ptr) { struct callmaster *m = ptr; @@ -1305,13 +1305,13 @@ static void callmaster_timer(void *ptr) { g_hash_table_foreach(m->callhash, call_timer_iterator, &hlp); rwlock_unlock_r(&m->hashlock); - atomic_uint64_local_copy_zero_struct(&tmpstats, &m->statsps, bytes); - atomic_uint64_local_copy_zero_struct(&tmpstats, &m->statsps, packets); - atomic_uint64_local_copy_zero_struct(&tmpstats, &m->statsps, errors); + atomic64_local_copy_zero_struct(&tmpstats, &m->statsps, bytes); + atomic64_local_copy_zero_struct(&tmpstats, &m->statsps, packets); + atomic64_local_copy_zero_struct(&tmpstats, &m->statsps, errors); - atomic_uint64_set(&m->stats.bytes, atomic_uint64_get_na(&tmpstats.bytes)); - atomic_uint64_set(&m->stats.packets, atomic_uint64_get_na(&tmpstats.packets)); - atomic_uint64_set(&m->stats.errors, atomic_uint64_get_na(&tmpstats.errors)); + atomic64_set(&m->stats.bytes, atomic64_get_na(&tmpstats.bytes)); + atomic64_set(&m->stats.packets, atomic64_get_na(&tmpstats.packets)); + atomic64_set(&m->stats.errors, atomic64_get_na(&tmpstats.errors)); i = (m->conf.kernelid >= 0) ? kernel_list(m->conf.kernelid) : NULL; while (i) { @@ -1335,12 +1335,12 @@ static void callmaster_timer(void *ptr) { mutex_lock(&ps->in_lock); - if (ke->stats.packets != atomic_uint64_get(&ps->kernel_stats.packets)) - atomic_uint64_set(&ps->last_packet, poller_now); + if (ke->stats.packets != atomic64_get(&ps->kernel_stats.packets)) + atomic64_set(&ps->last_packet, poller_now); - atomic_uint64_set(&ps->kernel_stats.bytes, ke->stats.bytes); - atomic_uint64_set(&ps->kernel_stats.packets, ke->stats.packets); - atomic_uint64_set(&ps->kernel_stats.errors, ke->stats.errors); + atomic64_set(&ps->kernel_stats.bytes, ke->stats.bytes); + atomic64_set(&ps->kernel_stats.packets, ke->stats.packets); + atomic64_set(&ps->kernel_stats.errors, ke->stats.errors); update = 0; @@ -1754,7 +1754,7 @@ struct packet_stream *__packet_stream_new(struct call *call) { mutex_init(&stream->in_lock); mutex_init(&stream->out_lock); stream->call = call; - atomic_uint64_set_na(&stream->last_packet, poller_now); + atomic64_set_na(&stream->last_packet, poller_now); call->streams = g_slist_prepend(call->streams, stream); return stream; @@ -2508,39 +2508,39 @@ void call_destroy(struct call *c) { "ml%i_midx%u_%s_relayed_packets="UINT64F", " "ml%i_midx%u_%s_relayed_bytes="UINT64F", " "ml%i_midx%u_%s_relayed_errors="UINT64F", " - "ml%i_midx%u_%s_last_packet=%llu, ", + "ml%i_midx%u_%s_last_packet="UINT64F", ", cdrlinecnt, md->index, protocol, addr, cdrlinecnt, md->index, protocol, ps->endpoint.port, cdrlinecnt, md->index, protocol, (unsigned int) (ps->sfd ? ps->sfd->fd.localport : 0), cdrlinecnt, md->index, protocol, - atomic_uint64_get(&ps->stats.packets), + atomic64_get(&ps->stats.packets), cdrlinecnt, md->index, protocol, - atomic_uint64_get(&ps->stats.bytes), + atomic64_get(&ps->stats.bytes), cdrlinecnt, md->index, protocol, - atomic_uint64_get(&ps->stats.errors), + atomic64_get(&ps->stats.errors), cdrlinecnt, md->index, protocol, - (unsigned long long) atomic_uint64_get(&ps->last_packet)); + atomic64_get(&ps->last_packet)); } ilog(LOG_INFO, "------ Media #%u, port %5u <> %15s:%-5hu%s, " - ""UINT64F" p, "UINT64F" b, "UINT64F" e, %llu last_packet", + ""UINT64F" p, "UINT64F" b, "UINT64F" e, "UINT64F" last_packet", md->index, (unsigned int) (ps->sfd ? ps->sfd->fd.localport : 0), addr, ps->endpoint.port, (!PS_ISSET(ps, RTP) && PS_ISSET(ps, RTCP)) ? " (RTCP)" : "", - atomic_uint64_get(&ps->stats.packets), - atomic_uint64_get(&ps->stats.bytes), - atomic_uint64_get(&ps->stats.errors), - (unsigned long long) atomic_uint64_get(&ps->last_packet)); - - atomic_uint64_add(&m->totalstats.total_relayed_packets, - atomic_uint64_get(&ps->stats.packets)); - atomic_uint64_add(&m->totalstats_interval.total_relayed_packets, - atomic_uint64_get(&ps->stats.packets)); - atomic_uint64_add(&m->totalstats.total_relayed_errors, - atomic_uint64_get(&ps->stats.errors)); - atomic_uint64_add(&m->totalstats_interval.total_relayed_errors, - atomic_uint64_get(&ps->stats.errors)); + atomic64_get(&ps->stats.packets), + atomic64_get(&ps->stats.bytes), + atomic64_get(&ps->stats.errors), + atomic64_get(&ps->last_packet)); + + atomic64_add(&m->totalstats.total_relayed_packets, + atomic64_get(&ps->stats.packets)); + atomic64_add(&m->totalstats_interval.total_relayed_packets, + atomic64_get(&ps->stats.packets)); + atomic64_add(&m->totalstats.total_relayed_errors, + atomic64_get(&ps->stats.errors)); + atomic64_add(&m->totalstats_interval.total_relayed_errors, + atomic64_get(&ps->stats.errors)); } } if (_log_facility_cdr) @@ -2586,10 +2586,10 @@ void call_destroy(struct call *c) { } } - if (ps && ps2 && atomic_uint64_get(&ps2->stats.packets)==0) { - if (atomic_uint64_get(&ps->stats.packets)!=0) { - atomic_uint64_inc(&m->totalstats.total_oneway_stream_sess); - atomic_uint64_inc(&m->totalstats_interval.total_oneway_stream_sess); + if (ps && ps2 && atomic64_get(&ps2->stats.packets)==0) { + if (atomic64_get(&ps->stats.packets)!=0) { + atomic64_inc(&m->totalstats.total_oneway_stream_sess); + atomic64_inc(&m->totalstats_interval.total_oneway_stream_sess); } else { total_nopacket_relayed_sess++; @@ -2598,22 +2598,22 @@ void call_destroy(struct call *c) { } - atomic_uint64_add(&m->totalstats.total_nopacket_relayed_sess, total_nopacket_relayed_sess / 2); - atomic_uint64_add(&m->totalstats_interval.total_nopacket_relayed_sess, total_nopacket_relayed_sess / 2); + atomic64_add(&m->totalstats.total_nopacket_relayed_sess, total_nopacket_relayed_sess / 2); + atomic64_add(&m->totalstats_interval.total_nopacket_relayed_sess, total_nopacket_relayed_sess / 2); ml = c->monologues->data; if (ml->term_reason==TIMEOUT) { - atomic_uint64_inc(&m->totalstats.total_timeout_sess); - atomic_uint64_inc(&m->totalstats_interval.total_timeout_sess); + atomic64_inc(&m->totalstats.total_timeout_sess); + atomic64_inc(&m->totalstats_interval.total_timeout_sess); } else if (ml->term_reason==SILENT_TIMEOUT) { - atomic_uint64_inc(&m->totalstats.total_silent_timeout_sess); - atomic_uint64_inc(&m->totalstats_interval.total_silent_timeout_sess); + atomic64_inc(&m->totalstats.total_silent_timeout_sess); + atomic64_inc(&m->totalstats_interval.total_silent_timeout_sess); } else if (ml->term_reason==REGULAR) { - atomic_uint64_inc(&m->totalstats.total_regular_term_sess); - atomic_uint64_inc(&m->totalstats_interval.total_regular_term_sess); + atomic64_inc(&m->totalstats.total_regular_term_sess); + atomic64_inc(&m->totalstats_interval.total_regular_term_sess); } else if (ml->term_reason==FORCED) { - atomic_uint64_inc(&m->totalstats.total_forced_term_sess); - atomic_uint64_inc(&m->totalstats_interval.total_forced_term_sess); + atomic64_inc(&m->totalstats.total_forced_term_sess); + atomic64_inc(&m->totalstats_interval.total_forced_term_sess); } timeval_totalstats_average_add(&m->totalstats, &tim_result_duration); diff --git a/daemon/call.h b/daemon/call.h index 731d80abf..67572d0de 100644 --- a/daemon/call.h +++ b/daemon/call.h @@ -188,21 +188,21 @@ extern const struct transport_protocol transport_protocols[]; struct stats { - atomic_uint64 packets; - atomic_uint64 bytes; - atomic_uint64 errors; + atomic64 packets; + atomic64 bytes; + atomic64 errors; }; struct totalstats { time_t started; - atomic_uint64 total_timeout_sess; - atomic_uint64 total_silent_timeout_sess; - atomic_uint64 total_regular_term_sess; - atomic_uint64 total_forced_term_sess; - atomic_uint64 total_relayed_packets; - atomic_uint64 total_relayed_errors; - atomic_uint64 total_nopacket_relayed_sess; - atomic_uint64 total_oneway_stream_sess; + atomic64 total_timeout_sess; + atomic64 total_silent_timeout_sess; + atomic64 total_regular_term_sess; + atomic64 total_forced_term_sess; + atomic64 total_relayed_packets; + atomic64 total_relayed_errors; + atomic64 total_nopacket_relayed_sess; + atomic64 total_oneway_stream_sess; mutex_t total_average_lock; /* for these two below */ u_int64_t total_managed_sess; @@ -273,7 +273,7 @@ struct packet_stream { struct stats stats; struct stats kernel_stats; - atomic_uint64 last_packet; + atomic64 last_packet; #if RTP_LOOP_PROTECT /* LOCK: in_lock: */ diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index 651b80a71..fa6af5243 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -386,8 +386,8 @@ str *call_query_udp(char **out, struct callmaster *m) { ret = str_sprintf("%s %lld "UINT64F" "UINT64F" "UINT64F" "UINT64F"\n", out[RE_UDP_COOKIE], (long long int) m->conf.silent_timeout - (poller_now - stats.last_packet), - atomic_uint64_get_na(&stats.totals[0].packets), atomic_uint64_get_na(&stats.totals[1].packets), - atomic_uint64_get_na(&stats.totals[2].packets), atomic_uint64_get_na(&stats.totals[3].packets)); + atomic64_get_na(&stats.totals[0].packets), atomic64_get_na(&stats.totals[1].packets), + atomic64_get_na(&stats.totals[2].packets), atomic64_get_na(&stats.totals[3].packets)); goto out; err: @@ -438,7 +438,7 @@ void calls_status_tcp(struct callmaster *m, struct control_stream *s) { control_stream_printf(s, "proxy %u "UINT64F"/%i/%i\n", g_queue_get_length(&q), - atomic_uint64_get(&m->stats.bytes), 0, 0); + atomic64_get(&m->stats.bytes), 0, 0); while (q.head) { c = g_queue_pop_head(&q); @@ -720,14 +720,14 @@ const char *call_delete_ng(bencode_item_t *input, struct callmaster *m, bencode_ } static void ng_stats(bencode_item_t *d, const struct stats *s, struct stats *totals) { - bencode_dictionary_add_integer(d, "packets", atomic_uint64_get(&s->packets)); - bencode_dictionary_add_integer(d, "bytes", atomic_uint64_get(&s->bytes)); - bencode_dictionary_add_integer(d, "errors", atomic_uint64_get(&s->errors)); + 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)); if (!totals) return; - atomic_uint64_add_na(&totals->packets, atomic_uint64_get(&s->packets)); - atomic_uint64_add_na(&totals->bytes, atomic_uint64_get(&s->bytes)); - atomic_uint64_add_na(&totals->errors, atomic_uint64_get(&s->errors)); + atomic64_add_na(&totals->packets, atomic64_get(&s->packets)); + atomic64_add_na(&totals->bytes, atomic64_get(&s->bytes)); + atomic64_add_na(&totals->errors, atomic64_get(&s->errors)); } static void ng_stats_endpoint(bencode_item_t *dict, const struct endpoint *ep) { @@ -766,7 +766,7 @@ static void ng_stats_stream(bencode_item_t *list, const struct packet_stream *ps if (ps->crypto.params.crypto_suite) bencode_dictionary_add_string(dict, "crypto suite", ps->crypto.params.crypto_suite->name); - bencode_dictionary_add_integer(dict, "last packet", atomic_uint64_get(&ps->last_packet)); + bencode_dictionary_add_integer(dict, "last packet", atomic64_get(&ps->last_packet)); flags = bencode_dictionary_add_list(dict, "flags"); @@ -782,8 +782,8 @@ static void ng_stats_stream(bencode_item_t *list, const struct packet_stream *ps BF_PS("media handover", MEDIA_HANDOVER); stats: - if (totals->last_packet < atomic_uint64_get(&ps->last_packet)) - totals->last_packet = atomic_uint64_get(&ps->last_packet); + if (totals->last_packet < atomic64_get(&ps->last_packet)) + totals->last_packet = atomic64_get(&ps->last_packet); /* XXX distinguish between input and output */ s = &totals->totals[0]; diff --git a/daemon/cli.c b/daemon/cli.c index ca5ad72e9..9dc774898 100644 --- a/daemon/cli.c +++ b/daemon/cli.c @@ -39,21 +39,21 @@ static void cli_incoming_list_totals(char* buffer, int len, struct callmaster* m ADJUSTLEN(printlen,outbufend,replybuffer); printlen = snprintf(replybuffer,(outbufend-replybuffer), " Total managed sessions :"UINT64F"\n", num_sessions); ADJUSTLEN(printlen,outbufend,replybuffer); - printlen = snprintf(replybuffer,(outbufend-replybuffer), " Total timed-out sessions via TIMEOUT :"UINT64F"\n",atomic_uint64_get(&m->totalstats.total_timeout_sess)); + printlen = snprintf(replybuffer,(outbufend-replybuffer), " Total timed-out sessions via TIMEOUT :"UINT64F"\n",atomic64_get(&m->totalstats.total_timeout_sess)); ADJUSTLEN(printlen,outbufend,replybuffer); - printlen = snprintf(replybuffer,(outbufend-replybuffer), " Total timed-out sessions via SILENT_TIMEOUT :"UINT64F"\n",atomic_uint64_get(&m->totalstats.total_silent_timeout_sess)); + printlen = snprintf(replybuffer,(outbufend-replybuffer), " Total timed-out sessions via SILENT_TIMEOUT :"UINT64F"\n",atomic64_get(&m->totalstats.total_silent_timeout_sess)); ADJUSTLEN(printlen,outbufend,replybuffer); - printlen = snprintf(replybuffer,(outbufend-replybuffer), " Total regular terminated sessions :"UINT64F"\n",atomic_uint64_get(&m->totalstats.total_regular_term_sess)); + printlen = snprintf(replybuffer,(outbufend-replybuffer), " Total regular terminated sessions :"UINT64F"\n",atomic64_get(&m->totalstats.total_regular_term_sess)); ADJUSTLEN(printlen,outbufend,replybuffer); - printlen = snprintf(replybuffer,(outbufend-replybuffer), " Total forced terminated sessions :"UINT64F"\n",atomic_uint64_get(&m->totalstats.total_forced_term_sess)); + printlen = snprintf(replybuffer,(outbufend-replybuffer), " Total forced terminated sessions :"UINT64F"\n",atomic64_get(&m->totalstats.total_forced_term_sess)); ADJUSTLEN(printlen,outbufend,replybuffer); - printlen = snprintf(replybuffer,(outbufend-replybuffer), " Total relayed packets :"UINT64F"\n",atomic_uint64_get(&m->totalstats.total_relayed_packets)); + printlen = snprintf(replybuffer,(outbufend-replybuffer), " Total relayed packets :"UINT64F"\n",atomic64_get(&m->totalstats.total_relayed_packets)); ADJUSTLEN(printlen,outbufend,replybuffer); - printlen = snprintf(replybuffer,(outbufend-replybuffer), " Total relayed packet errors :"UINT64F"\n",atomic_uint64_get(&m->totalstats.total_relayed_errors)); + printlen = snprintf(replybuffer,(outbufend-replybuffer), " Total relayed packet errors :"UINT64F"\n",atomic64_get(&m->totalstats.total_relayed_errors)); ADJUSTLEN(printlen,outbufend,replybuffer); - printlen = snprintf(replybuffer,(outbufend-replybuffer), " Total number of streams with no relayed packets :"UINT64F"\n", atomic_uint64_get(&m->totalstats.total_nopacket_relayed_sess)); + printlen = snprintf(replybuffer,(outbufend-replybuffer), " Total number of streams with no relayed packets :"UINT64F"\n", atomic64_get(&m->totalstats.total_nopacket_relayed_sess)); ADJUSTLEN(printlen,outbufend,replybuffer); - printlen = snprintf(replybuffer,(outbufend-replybuffer), " Total number of 1-way streams :"UINT64F"\n",atomic_uint64_get(&m->totalstats.total_oneway_stream_sess)); + printlen = snprintf(replybuffer,(outbufend-replybuffer), " Total number of 1-way streams :"UINT64F"\n",atomic64_get(&m->totalstats.total_oneway_stream_sess)); ADJUSTLEN(printlen,outbufend,replybuffer); printlen = snprintf(replybuffer,(outbufend-replybuffer), " Average call duration :%ld.%06ld\n\n",avg.tv_sec,avg.tv_usec); ADJUSTLEN(printlen,outbufend,replybuffer); @@ -151,15 +151,15 @@ static void cli_incoming_list_callid(char* buffer, int len, struct callmaster* m continue; printlen = snprintf(replybuffer,(outbufend-replybuffer), "------ Media #%u, port %5u <> %15s:%-5hu%s, " - ""UINT64F" p, "UINT64F" b, "UINT64F" e, %llu last_packet\n", + ""UINT64F" p, "UINT64F" b, "UINT64F" e, "UINT64F" last_packet\n", md->index, (unsigned int) (ps->sfd ? ps->sfd->fd.localport : 0), smart_ntop_p_buf(&ps->endpoint.ip46), ps->endpoint.port, (!PS_ISSET(ps, RTP) && PS_ISSET(ps, RTCP)) ? " (RTCP)" : "", - atomic_uint64_get(&ps->stats.packets), - atomic_uint64_get(&ps->stats.bytes), - atomic_uint64_get(&ps->stats.errors), - (unsigned long long) atomic_uint64_get(&ps->last_packet)); + atomic64_get(&ps->stats.packets), + atomic64_get(&ps->stats.bytes), + atomic64_get(&ps->stats.errors), + atomic64_get(&ps->last_packet)); ADJUSTLEN(printlen,outbufend,replybuffer); } } diff --git a/daemon/graphite.c b/daemon/graphite.c index 1c76ccfbb..ba96e2e6a 100644 --- a/daemon/graphite.c +++ b/daemon/graphite.c @@ -90,14 +90,14 @@ int send_graphite_data() { struct totalstats ts; /* atomically copy values to stack and reset to zero */ - atomic_uint64_local_copy_zero_struct(&ts, &cm->totalstats_interval, total_timeout_sess); - atomic_uint64_local_copy_zero_struct(&ts, &cm->totalstats_interval, total_silent_timeout_sess); - atomic_uint64_local_copy_zero_struct(&ts, &cm->totalstats_interval, total_regular_term_sess); - atomic_uint64_local_copy_zero_struct(&ts, &cm->totalstats_interval, total_forced_term_sess); - atomic_uint64_local_copy_zero_struct(&ts, &cm->totalstats_interval, total_relayed_packets); - atomic_uint64_local_copy_zero_struct(&ts, &cm->totalstats_interval, total_relayed_errors); - atomic_uint64_local_copy_zero_struct(&ts, &cm->totalstats_interval, total_nopacket_relayed_sess); - atomic_uint64_local_copy_zero_struct(&ts, &cm->totalstats_interval, total_oneway_stream_sess); + atomic64_local_copy_zero_struct(&ts, &cm->totalstats_interval, total_timeout_sess); + atomic64_local_copy_zero_struct(&ts, &cm->totalstats_interval, total_silent_timeout_sess); + atomic64_local_copy_zero_struct(&ts, &cm->totalstats_interval, total_regular_term_sess); + atomic64_local_copy_zero_struct(&ts, &cm->totalstats_interval, total_forced_term_sess); + atomic64_local_copy_zero_struct(&ts, &cm->totalstats_interval, total_relayed_packets); + atomic64_local_copy_zero_struct(&ts, &cm->totalstats_interval, total_relayed_errors); + atomic64_local_copy_zero_struct(&ts, &cm->totalstats_interval, total_nopacket_relayed_sess); + atomic64_local_copy_zero_struct(&ts, &cm->totalstats_interval, total_oneway_stream_sess); mutex_lock(&cm->totalstats_interval.total_average_lock); ts.total_average_call_dur = cm->totalstats_interval.total_average_call_dur; @@ -107,16 +107,16 @@ int send_graphite_data() { mutex_unlock(&cm->totalstats_interval.total_average_lock); rc = sprintf(ptr,"%s.totals.average_call_dur.tv_sec %llu %llu\n",hostname, (unsigned long long) ts.total_average_call_dur.tv_sec,(unsigned long long)g_now); ptr += rc; - rc = sprintf(ptr,"%s.totals.average_call_dur.tv_usec %llu %llu\n",hostname, (unsigned long long) ts.total_average_call_dur.tv_usec,(unsigned long long)g_now); ptr += rc; - rc = sprintf(ptr,"%s.totals.forced_term_sess "UINT64F" %llu\n",hostname, atomic_uint64_get_na(&ts.total_forced_term_sess),(unsigned long long)g_now); ptr += rc; + rc = sprintf(ptr,"%s.totals.average_call_dur.tv_usec %lu %llu\n",hostname, ts.total_average_call_dur.tv_usec,(unsigned long long)g_now); ptr += rc; + rc = sprintf(ptr,"%s.totals.forced_term_sess "UINT64F" %llu\n",hostname, atomic64_get_na(&ts.total_forced_term_sess),(unsigned long long)g_now); ptr += rc; rc = sprintf(ptr,"%s.totals.managed_sess "UINT64F" %llu\n",hostname, ts.total_managed_sess,(unsigned long long)g_now); ptr += rc; - rc = sprintf(ptr,"%s.totals.nopacket_relayed_sess "UINT64F" %llu\n",hostname, atomic_uint64_get_na(&ts.total_nopacket_relayed_sess),(unsigned long long)g_now); ptr += rc; - rc = sprintf(ptr,"%s.totals.oneway_stream_sess "UINT64F" %llu\n",hostname, atomic_uint64_get_na(&ts.total_oneway_stream_sess),(unsigned long long)g_now); ptr += rc; - rc = sprintf(ptr,"%s.totals.regular_term_sess "UINT64F" %llu\n",hostname, atomic_uint64_get_na(&ts.total_regular_term_sess),(unsigned long long)g_now); ptr += rc; - rc = sprintf(ptr,"%s.totals.relayed_errors "UINT64F" %llu\n",hostname, atomic_uint64_get_na(&ts.total_relayed_errors),(unsigned long long)g_now); ptr += rc; - rc = sprintf(ptr,"%s.totals.relayed_packets "UINT64F" %llu\n",hostname, atomic_uint64_get_na(&ts.total_relayed_packets),(unsigned long long)g_now); ptr += rc; - rc = sprintf(ptr,"%s.totals.silent_timeout_sess "UINT64F" %llu\n",hostname, atomic_uint64_get_na(&ts.total_silent_timeout_sess),(unsigned long long)g_now); ptr += rc; - rc = sprintf(ptr,"%s.totals.timeout_sess "UINT64F" %llu\n",hostname, atomic_uint64_get_na(&ts.total_timeout_sess),(unsigned long long)g_now); ptr += rc; + rc = sprintf(ptr,"%s.totals.nopacket_relayed_sess "UINT64F" %llu\n",hostname, atomic64_get_na(&ts.total_nopacket_relayed_sess),(unsigned long long)g_now); ptr += rc; + rc = sprintf(ptr,"%s.totals.oneway_stream_sess "UINT64F" %llu\n",hostname, atomic64_get_na(&ts.total_oneway_stream_sess),(unsigned long long)g_now); ptr += rc; + rc = sprintf(ptr,"%s.totals.regular_term_sess "UINT64F" %llu\n",hostname, atomic64_get_na(&ts.total_regular_term_sess),(unsigned long long)g_now); ptr += rc; + rc = sprintf(ptr,"%s.totals.relayed_errors "UINT64F" %llu\n",hostname, atomic64_get_na(&ts.total_relayed_errors),(unsigned long long)g_now); ptr += rc; + rc = sprintf(ptr,"%s.totals.relayed_packets "UINT64F" %llu\n",hostname, atomic64_get_na(&ts.total_relayed_packets),(unsigned long long)g_now); ptr += rc; + rc = sprintf(ptr,"%s.totals.silent_timeout_sess "UINT64F" %llu\n",hostname, atomic64_get_na(&ts.total_silent_timeout_sess),(unsigned long long)g_now); ptr += rc; + rc = sprintf(ptr,"%s.totals.timeout_sess "UINT64F" %llu\n",hostname, atomic64_get_na(&ts.total_timeout_sess),(unsigned long long)g_now); ptr += rc; rc = write(graphite_sock, data_to_send, strlen(data_to_send)); if (rc<0) {