diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index 90b945091..f659b6834 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -419,8 +419,8 @@ str call_query_udp(char **out) { rwlock_unlock_w(&c->master_lock); - ret = str_sprintf("%s %lld %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 "\n", out[RE_UDP_COOKIE], - (long long int) atomic_get_na(&rtpe_config.silent_timeout) - (timeval_from_us(rtpe_now).tv_sec - timeval_from_us(stats.last_packet_us).tv_sec), + ret = str_sprintf("%s %" PRId64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 "\n", out[RE_UDP_COOKIE], + atomic_get_na(&rtpe_config.silent_timeout) * 1000000L - (rtpe_now - stats.last_packet_us), // XXX scale to micro 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; diff --git a/daemon/cli.c b/daemon/cli.c index 8fbceae54..9a4f0aa64 100644 --- a/daemon/cli.c +++ b/daemon/cli.c @@ -1826,7 +1826,7 @@ static void cli_incoming_list_transcoders(str *instr, struct cli_writer *cw, con if (t_hash_table_size(rtpe_codec_stats) == 0) cw->cw_printf(cw, "No stats entries\n"); else { - int last_tv_sec = timeval_from_us(rtpe_now).tv_sec - 1; + int last_tv_sec = rtpe_now / 1000000L - 1; unsigned int idx = last_tv_sec & 1; codec_stats_ht_iter iter; diff --git a/daemon/codec.c b/daemon/codec.c index 0990f9c5a..f94cf8c42 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -4615,7 +4615,7 @@ static int packet_decoded_common(decoder_t *decoder, AVFrame *frame, void *u1, v struct codec_handler *h = ch->handler; if (h->stats_entry) { - int idx = timeval_from_us(rtpe_now).tv_sec & 1; + int idx = (rtpe_now / 1000000) & 1; atomic64_add(&h->stats_entry->pcm_samples[idx], frame->nb_samples); atomic64_add(&h->stats_entry->pcm_samples[2], frame->nb_samples); } @@ -4928,11 +4928,12 @@ static int handler_func_transcode(struct codec_handler *h, struct media_packet * mp->tv); if (h->stats_entry) { - unsigned int idx = timeval_from_us(rtpe_now).tv_sec & 1; + int now_sec = rtpe_now / 1000000; + unsigned int idx = now_sec & 1; int last_tv_sec = atomic_get_na(&h->stats_entry->last_tv_sec[idx]); - if (last_tv_sec != (int) timeval_from_us(rtpe_now).tv_sec) { + if (last_tv_sec != now_sec) { if (g_atomic_int_compare_and_exchange(&h->stats_entry->last_tv_sec[idx], - last_tv_sec, timeval_from_us(rtpe_now).tv_sec)) + last_tv_sec, now_sec)) { // new second - zero out stats. slight race condition here atomic64_set(&h->stats_entry->packets_input[idx], 0); diff --git a/daemon/cookie_cache.c b/daemon/cookie_cache.c index 69b874e11..0af4fe955 100644 --- a/daemon/cookie_cache.c +++ b/daemon/cookie_cache.c @@ -29,7 +29,7 @@ void cookie_cache_init(struct cookie_cache *c) { /* lock must be held */ static void __cookie_cache_check_swap(struct cookie_cache *c) { - if (timeval_from_us(rtpe_now).tv_sec - timeval_from_us(c->swap_time_us).tv_sec >= 30) { + if (rtpe_now - c->swap_time_us >= 30000000LL) { g_hash_table_remove_all(c->old.cookies); bencode_buffer_free(&c->old.buffer); swap_ptrs(&c->old.cookies, &c->current.cookies); diff --git a/daemon/dtmf.c b/daemon/dtmf.c index 459977aa2..f04c4af48 100644 --- a/daemon/dtmf.c +++ b/daemon/dtmf.c @@ -131,7 +131,7 @@ static void dtmf_bencode_and_notify(struct call_media *media, unsigned int event bencode_dictionary_add_string(data, "type", "DTMF"); bencode_dictionary_add_string(data, "source_ip", sockaddr_print_buf(&fsin->address)); - bencode_dictionary_add_integer(data, "timestamp", timeval_from_us(rtpe_now).tv_sec); + bencode_dictionary_add_integer(data, "timestamp", rtpe_now / 1000000); bencode_dictionary_add_integer(data, "event", event); bencode_dictionary_add_integer(data, "duration", ((long long) duration * (1000000LL / clockrate)) / 1000LL); bencode_dictionary_add_integer(data, "volume", volume); @@ -177,7 +177,7 @@ static GString *dtmf_json_print(struct call_media *media, unsigned int event, un g_string_append_printf(buf, "]," "\"type\":\"DTMF\",\"timestamp\":%lu,\"source_ip\":\"%s\"," "\"event\":%u,\"duration\":%u,\"volume\":%u}", - (unsigned long) timeval_from_us(rtpe_now).tv_sec, + (unsigned long) rtpe_now / 1000000, sockaddr_print_buf(&fsin->address), (unsigned int) event, (duration * (1000000 / clockrate)) / 1000, diff --git a/daemon/graphite.c b/daemon/graphite.c index b6030114c..50fd737ac 100644 --- a/daemon/graphite.c +++ b/daemon/graphite.c @@ -109,7 +109,7 @@ GString *print_graphite_data(void) { #define GPF(fmt, ...) \ if (graphite_prefix) \ g_string_append(graph_str, graphite_prefix); \ - g_string_append_printf(graph_str, fmt " %llu\n", ##__VA_ARGS__, (unsigned long long)timeval_from_us(rtpe_now).tv_sec) + g_string_append_printf(graph_str, fmt " %" PRId64 "\n", ##__VA_ARGS__, rtpe_now / 1000000L) for (int i = 0; i < OP_COUNT; i++) { GPF("%s_time_min %.6f", ng_command_strings_esc[i], @@ -188,7 +188,7 @@ GString *print_graphite_data(void) { mutex_lock(&rtpe_codec_stats_lock); - int last_tv_sec = timeval_from_us(rtpe_now).tv_sec - 1; + int last_tv_sec = rtpe_now / 1000000 - 1; unsigned int idx = last_tv_sec & 1; codec_stats_ht_iter iter; @@ -211,11 +211,11 @@ GString *print_graphite_data(void) { mutex_unlock(&rtpe_codec_stats_lock); - ilog(LOG_DEBUG, "min_sessions:%llu max_sessions:%llu, call_dur_per_interval:%.6f at time %llu\n", + ilog(LOG_DEBUG, "min_sessions:%llu max_sessions:%llu, call_dur_per_interval:%.6f at time %" PRId64 "\n", (unsigned long long) atomic64_get_na(&rtpe_gauge_graphite_min_max_sampled.min.total_sessions), (unsigned long long) atomic64_get_na(&rtpe_gauge_graphite_min_max_sampled.max.total_sessions), (double) atomic64_get_na(&rtpe_stats_graphite_diff.total_calls_duration_intv) / 1000000.0, - (unsigned long long ) timeval_from_us(rtpe_now).tv_sec); + rtpe_now / 1000000); return graph_str; } diff --git a/daemon/mqtt.c b/daemon/mqtt.c index 76512b3ce..44e64e014 100644 --- a/daemon/mqtt.c +++ b/daemon/mqtt.c @@ -533,7 +533,7 @@ INLINE JsonBuilder *__mqtt_timer_intro(void) { json_builder_begin_object(json); json_builder_set_member_name(json, "timestamp"); - json_builder_add_double_value(json, (double) timeval_from_us(rtpe_now).tv_sec + (double) timeval_from_us(rtpe_now).tv_usec / 1000000.0); // XXX + json_builder_add_double_value(json, (double) rtpe_now / 1000000.); return json; } diff --git a/daemon/statistics.c b/daemon/statistics.c index ae7155998..7c759b2f4 100644 --- a/daemon/statistics.c +++ b/daemon/statistics.c @@ -879,7 +879,7 @@ stats_metric_q *statistics_gather_metrics(struct interface_sampled_rate_stats *i HEADER("transcoders", NULL); HEADER("[", ""); - int last_tv_sec = timeval_from_us(rtpe_now).tv_sec - 1; + int last_tv_sec = rtpe_now / 1000000 - 1; unsigned int idx = last_tv_sec & 1; codec_stats_ht_iter iter;