From: Jorge Pereira Date: Wed, 22 May 2019 22:54:16 +0000 (-0300) Subject: src/lib: Move to fr_time_t X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=33c0fc5ca31d0bb8564c2ed1c2859ca93128ddfd;p=thirdparty%2Ffreeradius-server.git src/lib: Move to fr_time_t --- diff --git a/src/lib/redis/cluster.c b/src/lib/redis/cluster.c index f7ac78b5ade..2cf71c0a540 100644 --- a/src/lib/redis/cluster.c +++ b/src/lib/redis/cluster.c @@ -1344,7 +1344,7 @@ static int cluster_node_find_live(fr_redis_cluster_node_t **live_node, fr_redis_ rad_assert(live->next); /* There should be at least one */ if (live->next == 1) goto no_alts; /* Weird, but conceivable */ - gettimeofday(&now, NULL); + fr_time_to_timeval(&now, fr_time()); /* * Weighted random selection diff --git a/src/lib/server/exec.c b/src/lib/server/exec.c index 70d848e9269..b80519217ab 100644 --- a/src/lib/server/exec.c +++ b/src/lib/server/exec.c @@ -471,7 +471,7 @@ int radius_readfrom_program(int fd, pid_t pid, int timeout, * Read from the pipe until we doesn't get any more or * until the message is full. */ - gettimeofday(&start, NULL); + fr_time_to_timeval(&start, fr_time()); while (1) { int rcode; fd_set fds; @@ -480,7 +480,7 @@ int radius_readfrom_program(int fd, pid_t pid, int timeout, FD_ZERO(&fds); FD_SET(fd, &fds); - gettimeofday(&when, NULL); + fr_time_to_timeval(&when, fr_time()); fr_timeval_subtract(&elapsed, &when, &start); if (elapsed.tv_sec >= timeout) goto too_long; diff --git a/src/lib/server/pool.c b/src/lib/server/pool.c index fa76259225a..648029ad211 100644 --- a/src/lib/server/pool.c +++ b/src/lib/server/pool.c @@ -482,7 +482,7 @@ static fr_pool_connection_t *connection_spawn(fr_pool_t *pool, REQUEST *request, this->in_use = in_use; this->number = number; - gettimeofday(&this->last_reserved, NULL); + fr_time_to_timeval(&this->last_reserved, fr_time()); this->last_released = this->last_reserved; /* @@ -883,7 +883,7 @@ static void *connection_get_internal(fr_pool_t *pool, REQUEST *request, bool spa do_return: pool->state.active++; this->num_uses++; - gettimeofday(&this->last_reserved, NULL); + fr_time_to_timeval(&this->last_reserved, fr_time()); this->in_use = true; #ifdef PTHREAD_DEBUG @@ -1393,7 +1393,7 @@ void fr_pool_connection_release(fr_pool_t *pool, REQUEST *request, void *conn) /* * Record when the connection was last released */ - gettimeofday(&this->last_released, NULL); + fr_time_to_timeval(&this->last_reserved, fr_time()); pool->state.last_released = this->last_released; /* @@ -1520,7 +1520,7 @@ int fr_pool_connection_close(fr_pool_t *pool, REQUEST *request, void *conn) /* * Record the last time a connection was closed */ - gettimeofday(&pool->state.last_closed, NULL); + fr_time_to_timeval(&pool->state.last_closed, fr_time()); ROPTIONAL(RINFO, INFO, "Deleting connection (%" PRIu64 ")", this->number); diff --git a/src/lib/server/snmp.c b/src/lib/server/snmp.c index a47313aa6a8..1285b047f8e 100644 --- a/src/lib/server/snmp.c +++ b/src/lib/server/snmp.c @@ -118,7 +118,7 @@ static int snmp_value_uptime_get(UNUSED TALLOC_CTX *ctx, fr_value_box_t *out, ND rad_assert(map->da->type == FR_TYPE_UINT32); - gettimeofday(&now, NULL); + fr_time_to_timeval(&now, fr_time()); fr_timeval_subtract(&diff, &now, &uptime); out->vb_uint32 = diff.tv_sec * 100; @@ -135,7 +135,7 @@ static int snmp_config_reset_time_get(UNUSED TALLOC_CTX *ctx, fr_value_box_t *ou rad_assert(map->da->type == FR_TYPE_UINT32); - gettimeofday(&now, NULL); + fr_time_to_timeval(&now, fr_time()); fr_timeval_subtract(&diff, &now, &reset_time); out->vb_uint32 = diff.tv_sec * 100; @@ -161,7 +161,7 @@ static int snmp_config_reset_set(NDEBUG_UNUSED fr_snmp_map_t const *map, UNUSED switch (in->vb_uint32) { case FR_RADIUS_AUTH_SERV_CONFIG_RESET_VALUE_RESET: main_loop_signal_self(RADIUS_SIGNAL_SELF_HUP); - gettimeofday(&reset_time, NULL); + fr_time_to_timeval(&reset_time, fr_time()); return 0; default: @@ -1110,7 +1110,7 @@ static int _fr_snmp_init(fr_snmp_map_t map[]) */ int fr_snmp_init(void) { - gettimeofday(&uptime, NULL); + fr_time_to_timeval(&uptime, fr_time()); reset_time = uptime; if (fr_dict_autoload(snmp_dict) < 0) { diff --git a/src/lib/tls/ocsp.c b/src/lib/tls/ocsp.c index ab715c1ce38..107fe31177f 100644 --- a/src/lib/tls/ocsp.c +++ b/src/lib/tls/ocsp.c @@ -438,13 +438,13 @@ int tls_ocsp_check(REQUEST *request, SSL *ssl, goto finish; } - gettimeofday(&when, NULL); + fr_time_to_timeval(&when, fr_time()); when.tv_sec += conf->timeout; do { rc = OCSP_sendreq_nbio(&resp, ctx); if (conf->timeout) { - gettimeofday(&now, NULL); + fr_time_to_timeval(&now, fr_time()); if (fr_timeval_cmp(&now, &when) >= 0) break; } } while ((rc == -1) && BIO_should_retry(conn)); @@ -536,7 +536,7 @@ int tls_ocsp_check(REQUEST *request, SSL *ssl, * Sometimes we already know what 'now' is depending * on the code path, other times we don't. */ - if (now.tv_sec == 0) gettimeofday(&now, NULL); + if (now.tv_sec == 0) fr_time_to_timeval(&now, fr_time()); if (tls_utils_asn1time_to_epoch(&next, next_update) < 0) { RPEDEBUG("Failed parsing next_update time"); ocsp_status = OCSP_STATUS_SKIPPED;