From: Alan T. DeKok Date: Thu, 23 May 2019 15:17:39 +0000 (-0400) Subject: move to using fr_time_delta_t X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a7c696436f8a3cdef67bf65b8fa0635ce014a10;p=thirdparty%2Ffreeradius-server.git move to using fr_time_delta_t --- diff --git a/src/modules/proto_detail/proto_detail.h b/src/modules/proto_detail/proto_detail.h index e68828ac288..2350237e2f5 100644 --- a/src/modules/proto_detail/proto_detail.h +++ b/src/modules/proto_detail/proto_detail.h @@ -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 diff --git a/src/modules/proto_detail/proto_detail_file.c b/src/modules/proto_detail/proto_detail_file.c index a21496ec326..b6ce90653e9 100644 --- a/src/modules/proto_detail/proto_detail_file.c +++ b/src/modules/proto_detail/proto_detail_file.c @@ -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!