From e097ee37013334257793e708c25d987661c5b7de Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 15 Apr 2025 08:55:20 -0400 Subject: [PATCH] MT#55283 convert time_t to int64_t Change-Id: If77ae4a1cbc15442b3da786d5cc8268f88400707 --- daemon/codec.c | 10 +++++----- daemon/graphite.c | 6 +++--- daemon/homer.c | 8 ++++---- daemon/janus.c | 12 ++++++------ daemon/redis.c | 6 +++--- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/daemon/codec.c b/daemon/codec.c index c168a2e09..e4e44ee35 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -131,7 +131,7 @@ struct dtx_buffer { struct media_packet last_mp; unsigned long head_ts; uint32_t ssrc; - time_t start; + int64_t start_us; }; struct dtx_packet { struct transcode_packet *packet; @@ -3315,7 +3315,7 @@ static bool __buffer_dtx(struct dtx_buffer *dtxb, struct codec_ssrc_handler *dec mutex_lock(&dtxb->lock); - dtxb->start = timeval_from_us(rtpe_now).tv_sec; + dtxb->start_us = rtpe_now; t_queue_push_tail(&dtxb->packets, dtxp); ilogs(dtx, LOG_DEBUG, "Adding packet (TS %lu) to DTX buffer; now %i packets in DTX queue", ts, dtxb->packets.length); @@ -3897,7 +3897,7 @@ static void __dtx_send_later(struct codec_timer *ct) { } int ptime = dtxb->ptime; - time_t dtxb_start = dtxb->start; + int64_t dtxb_start_us = dtxb->start_us; mutex_unlock(&dtxb->lock); @@ -3921,9 +3921,9 @@ static void __dtx_send_later(struct codec_timer *ct) { "Decoder error while processing buffered RTP packet"); } else { - int diff = timeval_from_us(rtpe_now).tv_sec - dtxb_start; + int64_t diff = rtpe_now - dtxb_start_us; - if (rtpe_config.max_dtx <= 0 || diff < rtpe_config.max_dtx) { + if (rtpe_config.max_dtx <= 0 || diff < rtpe_config.max_dtx * 1000000L) { // XXX scale to micro ilogs(dtx, LOG_DEBUG, "RTP media for TS %lu missing, triggering DTX", ts); // synthetic packet diff --git a/daemon/graphite.c b/daemon/graphite.c index 5c76b611f..b6030114c 100644 --- a/daemon/graphite.c +++ b/daemon/graphite.c @@ -23,7 +23,7 @@ int64_t rtpe_latest_graphite_interval_start; static socket_t graphite_sock; static int connection_state = STATE_DISCONNECTED; //struct totalstats totalstats_prev; -static time_t next_run; +static int64_t next_run; // HEAD: static time_t rtpe_now, next_run; static char* graphite_prefix = NULL; static int64_t graphite_interval_tv; @@ -305,12 +305,12 @@ static void graphite_loop_run(endpoint_t *graphite_ep, int seconds) { } rtpe_now = now_us(); - if (timeval_from_us(rtpe_now).tv_sec < next_run) { + if (rtpe_now < next_run) { usleep(100000); return; } - next_run = timeval_from_us(rtpe_now).tv_sec + seconds; + next_run = rtpe_now + seconds * 1000000LL; // XXX scale to micro if (graphite_sock.fd < 0 && connection_state == STATE_DISCONNECTED) { connect_to_graphite_server(graphite_ep); diff --git a/daemon/homer.c b/daemon/homer.c index 8da1eb25c..18c323f9c 100644 --- a/daemon/homer.c +++ b/daemon/homer.c @@ -25,7 +25,7 @@ struct homer_sender { int protocol; int capture_id; socket_t socket; - time_t retry; + int64_t retry; gstring_q send_queue; GString *partial; @@ -54,7 +54,7 @@ static int __no_socket(struct homer_sender *hs); static void __reset(struct homer_sender *hs) { close_socket(&hs->socket); hs->state = __no_socket; - hs->retry = time(NULL) + 30; + hs->retry = now_us() + 30 * 1000000LL; // discard partially written packet if (hs->partial) @@ -169,7 +169,7 @@ static int __in_progress(struct homer_sender *hs) { static int __no_socket(struct homer_sender *hs) { int ret; - if (hs->retry > time(NULL)) + if (hs->retry > now_us()) return 0; ilog(LOG_INFO, "Connecting to Homer at %s", endpoint_print_buf(&hs->endpoint)); @@ -192,7 +192,7 @@ void homer_sender_init(const endpoint_t *ep, int protocol, int capture_id) { ret->endpoint = *ep; ret->protocol = protocol; ret->capture_id = capture_id; - ret->retry = time(NULL); + ret->retry = now_us(); ret->state = __no_socket; diff --git a/daemon/janus.c b/daemon/janus.c index 661ca6ff3..09949fc15 100644 --- a/daemon/janus.c +++ b/daemon/janus.c @@ -23,7 +23,7 @@ struct janus_session { // "login" session struct obj obj; uint64_t id; mutex_t lock; - time_t last_act; + int64_t last_act; janus_websockets_ht websockets; // controlling transports, websocket_conn -> websocket_conn janus_handles_set handles; // handle ID -> 0x1. handle ID owned by janus_handles }; @@ -55,7 +55,7 @@ struct janus_room { TYPED_GHASHTABLE(janus_rooms_ht, uint64_t, struct janus_room, int64_hash, int64_eq, NULL, NULL) -TYPED_GHASHTABLE(janus_tokens_ht, char, time_t, c_str_hash, c_str_equal, g_free, g_free) +TYPED_GHASHTABLE(janus_tokens_ht, char, int64_t, c_str_hash, c_str_equal, g_free, g_free) static mutex_t janus_lock = MUTEX_STATIC_INIT; @@ -86,7 +86,7 @@ static struct janus_session *janus_get_session(uint64_t id) { if (!ret) return NULL; mutex_lock(&ret->lock); - ret->last_act = timeval_from_us(rtpe_now).tv_sec; + ret->last_act = rtpe_now; mutex_unlock(&ret->lock); return ret; } @@ -1150,8 +1150,8 @@ static const char *janus_add_token(JsonReader *reader, JsonBuilder *builder, boo if (!token) return "JSON object does not contain 'token' key"; - time_t *now = g_malloc(sizeof(*now)); - *now = timeval_from_us(rtpe_now).tv_sec; + int64_t *now = g_malloc(sizeof(*now)); + *now = rtpe_now; mutex_lock(&janus_lock); t_hash_table_replace(janus_tokens, g_strdup(token), now); mutex_unlock(&janus_lock); @@ -1180,7 +1180,7 @@ static const char *janus_create(JsonReader *reader, JsonBuilder *builder, struct __auto_type session = obj_alloc0(struct janus_session, __janus_session_free); mutex_init(&session->lock); mutex_lock(&session->lock); // not really necessary but Coverity complains - session->last_act = timeval_from_us(rtpe_now).tv_sec; + session->last_act = rtpe_now; session->websockets = janus_websockets_ht_new(); session->handles = janus_handles_set_new(); diff --git a/daemon/redis.c b/daemon/redis.c index 655ab54b7..d615d095a 100644 --- a/daemon/redis.c +++ b/daemon/redis.c @@ -824,7 +824,7 @@ void redis_delete_async_loop(void *d) { void redis_notify_loop(void *d) { int seconds = 1, redis_notify_return = 0; - time_t next_run = timeval_from_us(rtpe_now).tv_sec; + int64_t next_run = rtpe_now; struct redis *r; r = rtpe_redis_notify; @@ -857,12 +857,12 @@ void redis_notify_loop(void *d) { // loop redis_notify => in case of lost connection while (!rtpe_shutdown) { rtpe_now = now_us(); - if (timeval_from_us(rtpe_now).tv_sec < next_run) { + if (rtpe_now < next_run) { usleep(100000); continue; } - next_run = timeval_from_us(rtpe_now).tv_sec + seconds; + next_run = rtpe_now + seconds * 1000000L; // XXX scale to micro if (redis_check_conn(r) == REDIS_STATE_CONNECTED || redis_notify_return < 0) { r->async_ctx = NULL;