]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
do exponential backoff for trying to lock the detail.work file
authorAlan T. DeKok <aland@freeradius.org>
Fri, 10 Nov 2017 14:51:02 +0000 (09:51 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 10 Nov 2017 14:51:02 +0000 (09:51 -0500)
src/modules/proto_detail/proto_detail.h
src/modules/proto_detail/proto_detail_file.c

index 7a81e901d13760fc6c619bf566dbccbc3d208960..5c1b93e0afbb911f562735178503e16b451ecce7 100644 (file)
@@ -83,6 +83,8 @@ typedef struct proto_detail_work_t {
 
        uint32_t                        poll_interval;          //!< interval between polling
 
+       uint32_t                        lock_interval;          //!< interval between trying the locks.
+
        uint32_t                        irt;
        uint32_t                        mrt;
        uint32_t                        mrc;
index 5612a87d86ae39e0ce61a60f00d1de721cc4cb59..ad1d5c6bfaf299affe43e2a294a5834407c60bda 100644 (file)
@@ -242,8 +242,14 @@ static void work_exists(proto_detail_file_t *inst, int fd)
 
                close(fd);
 
-               when.tv_sec = 0;
-               when.tv_usec = USEC / 10;
+               when.tv_usec = inst->lock_interval % USEC;
+               when.tv_sec = inst->lock_interval / USEC;
+
+               /*
+                *      Ensure that we don't do massive busy-polling.
+                */
+               inst->lock_interval += inst->lock_interval / 2;
+               if (inst->lock_interval > (30 * USEC)) inst->lock_interval = 30 * USEC;
 
                DEBUG3("Waiting %d.%06ds for lock on file %s",
                       (int) when.tv_sec, (int) when.tv_usec, inst->filename_work);
@@ -448,6 +454,8 @@ redo:
                return;
        }
 
+       inst->lock_interval = USEC / 10;
+
        /*
         *      It exists, go process it!
         *