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);
}
/*
- * 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;
}
-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)
}
}
-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);
rs_time_print(timestr, sizeof(timestr), wake);
}
}
+
+ return 0;
}
/** Compare requests using packet info and lists of attributes