]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
event_status now can return 1 for "check events, but don't wait"
authorAlan T. DeKok <aland@freeradius.org>
Mon, 21 Nov 2016 19:46:04 +0000 (14:46 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 21 Nov 2016 21:49:22 +0000 (16:49 -0500)
src/include/event.h
src/lib/event.c
src/main/process.c
src/main/radsniff.c

index 39dcaacdc6a5dd5e7110b20266b9f6f07aebc558..6f33aac12c290e026e43617602b389a150004a9a 100644 (file)
@@ -35,7 +35,7 @@ typedef struct fr_event_list_t fr_event_list_t;
 typedef struct fr_event_timer_t fr_event_timer_t;
 
 typedef        void (*fr_event_callback_t)(void *, struct timeval *now);
-typedef        void (*fr_event_status_t)(void *status_ctx, struct timeval *);
+typedef        int (*fr_event_status_t)(void *status_ctx, struct timeval *);
 typedef void (*fr_event_fd_handler_t)(fr_event_list_t *el, int sock, void *ctx);
 
 int            fr_event_list_num_fds(fr_event_list_t *el);
index 7024d2cc873c0eda14f9bb34305b500fc1babf5d..d71a650a767d1aa40e4770efa058d1c740044e66 100644 (file)
@@ -516,9 +516,17 @@ int fr_event_corral(fr_event_list_t *el, bool wait)
        }
 
        /*
-        *      Run the status callback
+        *      Run the status callback.  It may tell us that the
+        *      application has more work to do, in which case we
+        *      re-set the timeout to be instant.
         */
-       if (el->status) el->status(el->status_ctx, wake);
+       if (el->status) {
+               if (el->status(el->status_ctx, wake) > 0) {
+                       wake = &when;
+                       when.tv_sec = 0;
+                       when.tv_usec = 0;
+               }
+       }
 
        if (wake) {
                ts_wake = &ts_when;
index caf9ac6cfc6d161c9ec5e43f6189a3ccb63b44da..a641b70af3dc4fc3f5c9a34aae1e14cfef1fed2f 100644 (file)
@@ -4773,24 +4773,26 @@ static void event_socket_handler(NDEBUG_UNUSED fr_event_list_t *xel, UNUSED int
 }
 
 
-static void event_status(UNUSED void *ctx, struct timeval *wake)
+static int event_status(UNUSED void *ctx, struct timeval *wake)
 {
        if (rad_debug_lvl == 0) {
                if (just_started) {
                        INFO("Ready to process requests");
                        just_started = false;
                }
-               return;
+               return 0;
        }
 
        if (!wake) {
-               if (main_config.drop_requests) return;
+               if (main_config.drop_requests) return 0;
                INFO("Ready to process requests");
        } else if ((wake->tv_sec != 0) ||
                   (wake->tv_usec >= 100000)) {
                DEBUG("Waking up in %d.%01u seconds.",
                      (int) wake->tv_sec, (unsigned int) wake->tv_usec / 100000);
        }
+
+       return 0;
 }
 
 static int event_new_fd(rad_listen_t *this)
index 5ac74d44950c952b19e73b064cd9459a13fd62a4..0260aab9ac43f05446b138730d058730764b7dbb 100644 (file)
@@ -1840,7 +1840,7 @@ static void rs_got_packet(fr_event_list_t *el, int fd, void *ctx)
        }
 }
 
-static void _rs_event_status(UNUSED void *ctx, struct timeval *wake)
+static int  _rs_event_status(UNUSED void *ctx, struct timeval *wake)
 {
        if (wake && ((wake->tv_sec != 0) || (wake->tv_usec >= 100000))) {
                DEBUG2("Waking up in %d.%01u seconds.", (int) wake->tv_sec, (unsigned int) wake->tv_usec / 100000);
@@ -1849,6 +1849,8 @@ static void _rs_event_status(UNUSED void *ctx, struct timeval *wake)
                        rs_time_print(timestr, sizeof(timestr), wake);
                }
        }
+
+       return 0;
 }
 
 /** Compare requests using packet info and lists of attributes