]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
src/lib: Move to fr_time_t
authorJorge Pereira <jpereiran@gmail.com>
Wed, 22 May 2019 22:54:16 +0000 (19:54 -0300)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 23 May 2019 04:05:58 +0000 (00:05 -0400)
src/lib/redis/cluster.c
src/lib/server/exec.c
src/lib/server/pool.c
src/lib/server/snmp.c
src/lib/tls/ocsp.c

index f7ac78b5adec0b06332923be5d04db376f0e51f7..2cf71c0a540a11aa0a16fb1a52fa2efd1616593e 100644 (file)
@@ -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
index 70d848e9269aa4ec21c0e3327ae03ac19fec703b..b80519217ab74e8b095388c85f36cfb14348eb53 100644 (file)
@@ -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;
 
index fa76259225af5137138ebaba1ba93cb52bacea7d..648029ad2116e1023fd8c9836759adb1e516268c 100644 (file)
@@ -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);
 
index a47313aa6a8b18dec9041c4efb112b8967596428..1285b047f8e8ca60ad5353f44f778b38b1b234c2 100644 (file)
@@ -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) {
index ab715c1ce38f5a2d325d29f777ffff645dc32f35..107fe31177f7a2c1e9e78fd9ed10a7b0e6248492 100644 (file)
@@ -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;