Browse Source

MT#55283 replace g_atomic with atomic_*

Change-Id: Ia0729df4449e8bd4a2028d0373089e0fc9e1e042
pull/2018/head
Richard Fuchs 2 months ago
parent
commit
b0d2b82199
4 changed files with 11 additions and 11 deletions
  1. +2
    -2
      daemon/cli.c
  2. +5
    -5
      daemon/codec.c
  3. +2
    -2
      daemon/graphite.c
  4. +2
    -2
      daemon/statistics.c

+ 2
- 2
daemon/cli.c View File

@ -1836,8 +1836,8 @@ static void cli_incoming_list_transcoders(str *instr, struct cli_writer *cw, con
char *chain;
struct codec_stats *stats_entry;
while (t_hash_table_iter_next(&iter, &chain, &stats_entry)) {
cw->cw_printf(cw, "%s: %i transcoders\n", chain, g_atomic_int_get(&stats_entry->num_transcoders));
if (g_atomic_int_get(&stats_entry->last_tv_sec[idx]) != last_tv_sec)
cw->cw_printf(cw, "%s: %i transcoders\n", chain, atomic_get_na(&stats_entry->num_transcoders));
if (atomic_get(&stats_entry->last_tv_sec[idx]) != last_tv_sec)
continue;
cw->cw_printf(cw, " %" PRIu64 " packets/s\n", atomic64_get(&stats_entry->packets_input[idx]));
cw->cw_printf(cw, " %" PRIu64 " bytes/s\n", atomic64_get(&stats_entry->bytes_input[idx]));


+ 5
- 5
daemon/codec.c View File

@ -464,7 +464,7 @@ static void __handler_shutdown(struct codec_handler *handler) {
codec_handler_free(&handler->dtmf_injector);
if (handler->stats_entry) {
__atomic_fetch_add(&handler->stats_entry->num_transcoders, -1, __ATOMIC_RELAXED);
atomic_add_na(&handler->stats_entry->num_transcoders, -1);
handler->stats_entry = NULL;
g_free(handler->stats_chain);
handler->stats_chain = NULL;
@ -556,7 +556,7 @@ static void __handler_stats_entry(struct codec_handler *handler) {
__auto_type stats_entry = handler->stats_entry;
if (stats_entry)
__atomic_fetch_add(&stats_entry->num_transcoders, -1, __ATOMIC_RELAXED);
atomic_add_na(&stats_entry->num_transcoders, -1);
{
LOCK(&rtpe_codec_stats_lock);
@ -573,7 +573,7 @@ static void __handler_stats_entry(struct codec_handler *handler) {
handler->stats_entry = stats_entry;
}
__atomic_fetch_add(&stats_entry->num_transcoders, 1, __ATOMIC_RELAXED);
atomic_inc_na(&stats_entry->num_transcoders);
}
static int handler_func_blackhole(struct codec_handler *h, struct media_packet *mp) {
@ -5072,8 +5072,8 @@ static int handler_func_transcode(struct codec_handler *h, struct media_packet *
unsigned int idx = now_sec & 1;
int last_tv_sec = atomic_get_na(&h->stats_entry->last_tv_sec[idx]);
if (last_tv_sec != now_sec) {
if (g_atomic_int_compare_and_exchange(&h->stats_entry->last_tv_sec[idx],
last_tv_sec, now_sec))
if (atomic_compare_exchange(&h->stats_entry->last_tv_sec[idx],
&last_tv_sec, now_sec))
{
// new second - zero out stats. slight race condition here
atomic64_set(&h->stats_entry->packets_input[idx], 0);


+ 2
- 2
daemon/graphite.c View File

@ -197,8 +197,8 @@ GString *print_graphite_data(void) {
struct codec_stats *stats_entry;
while (t_hash_table_iter_next(&iter, &chain, &stats_entry)) {
GPF("transcoder_%s %i", stats_entry->chain_brief,
g_atomic_int_get(&stats_entry->num_transcoders));
if (g_atomic_int_get(&stats_entry->last_tv_sec[idx]) != last_tv_sec)
atomic_get_na(&stats_entry->num_transcoders));
if (atomic_get(&stats_entry->last_tv_sec[idx]) != last_tv_sec)
continue;
GPF("transcoder_%s_packets %llu", stats_entry->chain_brief,
(unsigned long long) atomic64_get(&stats_entry->packets_input[idx]));


+ 2
- 2
daemon/statistics.c View File

@ -889,10 +889,10 @@ stats_metric_q *statistics_gather_metrics(struct interface_sampled_rate_stats *i
while (t_hash_table_iter_next(&iter, &chain, &stats_entry)) {
HEADER("{", "");
METRICsva("chain", "\"%s\"", chain);
METRICs("num", "%i", g_atomic_int_get(&stats_entry->num_transcoders));
METRICs("num", "%i", atomic_get_na(&stats_entry->num_transcoders));
PROM("transcoders", "gauge");
PROMLAB("chain=\"%s\"", chain);
if (g_atomic_int_get(&stats_entry->last_tv_sec[idx]) == last_tv_sec) {
if (atomic_get(&stats_entry->last_tv_sec[idx]) == last_tv_sec) {
METRICs("packetrate", "%" PRIu64, atomic64_get(&stats_entry->packets_input[idx]));
METRICs("byterate", "%" PRIu64, atomic64_get(&stats_entry->bytes_input[idx]));
METRICs("samplerate", "%" PRIu64, atomic64_get(&stats_entry->pcm_samples[idx]));


Loading…
Cancel
Save