]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
move to using fr_time_delta_t
authorAlan T. DeKok <aland@freeradius.org>
Thu, 23 May 2019 15:17:39 +0000 (11:17 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 23 May 2019 15:27:51 +0000 (11:27 -0400)
src/modules/proto_detail/proto_detail.h
src/modules/proto_detail/proto_detail_file.c

index e68828ac288c6a294f2b7a85ee954a0e4c8c1881..2350237e2f565d3f1c16d02db99a637a98b5fd3d 100644 (file)
@@ -121,7 +121,7 @@ struct proto_detail_work_thread_s {
        fr_dlist_head_t                 list;                   //!< for retransmissions
 
        uint32_t                        outstanding;            //!< number of currently outstanding records;
-       uint32_t                        lock_interval;          //!< interval between trying the locks.
+       fr_time_delta_t                 lock_interval;          //!< interval between trying the locks.
 
        bool                            eof;                    //!< are we at EOF on reading?
        bool                            closing;                //!< we should be closing the file
index a21496ec326d590cab8f1d5290e3af11b5f02a5c..b6ce90653e978ffe1134f11ce7f7083df4ab16c3 100644 (file)
@@ -252,28 +252,27 @@ static int work_exists(proto_detail_file_thread_t *thread, int fd)
         *      "detail.work" exists, try to lock it.
         */
        if (rad_lockfd_nonblock(fd, 0) < 0) {
-               fr_time_t       in;
-               struct timeval  in_tv;
+               fr_time_t delay;
 
                DEBUG3("proto_detail (%s): Failed locking %s: %s",
                       thread->name, inst->filename_work, fr_syserror(errno));
 
                close(fd);
 
-               in = fr_time_delta_from_usec(thread->lock_interval);
-               fr_timeval_from_nsec(&in_tv, in);
+               delay = thread->lock_interval;
 
                /*
-                *      Ensure that we don't do massive busy-polling.
+                *      Set the next interval, and ensure that we
+                *      don't do massive busy-polling.
                 */
                thread->lock_interval += thread->lock_interval / 2;
-               if (thread->lock_interval > (30 * USEC)) thread->lock_interval = 30 * USEC;
+               if (thread->lock_interval > ((fr_time_delta_t) 30) * NSEC) thread->lock_interval = ((fr_time_delta_t) 30) * NSEC;
 
                DEBUG3("proto_detail (%s): Waiting %d.%06ds for lock on file %s",
-                      thread->name, (int) in_tv.tv_sec, (int) in_tv.tv_usec, inst->filename_work);
+                      thread->name, (int) (delay / NSEC), (int) ((delay % NSEC) / 1000), inst->filename_work);
 
                if (fr_event_timer_in(thread, thread->el, &thread->ev,
-                                     in, work_retry_timer, thread) < 0) {
+                                     delay, work_retry_timer, thread) < 0) {
                        ERROR("Failed inserting retry timer for %s", inst->filename_work);
                }
                return 0;
@@ -525,7 +524,7 @@ delay:
                return;
        }
 
-       thread->lock_interval = USEC / 10;
+       thread->lock_interval = NSEC / 10;
 
        /*
         *      It exists, go process it!