Allow the detail poll interval to be configurable
authorAlan T. DeKok <aland@freeradius.org>
Sun, 15 Feb 2009 08:29:45 +0000 (09:29 +0100)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 15 Feb 2009 08:29:45 +0000 (09:29 +0100)
raddb/sites-available/buffered-sql
src/include/detail.h
src/main/detail.c
src/main/event.c

index 9904da2..5d9f39c 100644 (file)
@@ -71,6 +71,14 @@ server buffered-sql {
                #  causing databases to go into overload.
                #  
                load_factor = 10
+
+               #
+               #  Set the interval for polling the detail file.
+               #  If the detail file doesn't exist, the server will
+               #  wake up, and poll for it every N seconds.
+               #
+               #  Useful range of values: 1 to 60
+               poll_interval = 1
        }
 
        #
index 67c668f..0ee4cb1 100644 (file)
@@ -19,5 +19,6 @@ int detail_encode(UNUSED rad_listen_t *this, UNUSED REQUEST *request);
 int detail_decode(UNUSED rad_listen_t *this, UNUSED REQUEST *request);
 int detail_parse(CONF_SECTION *cs, rad_listen_t *this);
 int detail_delay(rad_listen_t *this);
+int detail_poll_interval(rad_listen_t *listener);
 
 #endif /* DETAIL_H */
index 36d41ab..f582817 100644 (file)
@@ -54,6 +54,7 @@ typedef struct listen_detail_t {
        fr_ipaddr_t     client_ip;
        int             load_factor; /* 1..100 */
        int             signal;
+       int             poll_interval;
 
        int             has_rtt;
        int             srtt;
@@ -749,6 +750,8 @@ static const CONF_PARSER detail_config[] = {
          offsetof(listen_detail_t, filename), NULL,  NULL },
        { "load_factor",   PW_TYPE_INTEGER,
          offsetof(listen_detail_t, load_factor), NULL, Stringify(10)},
+       { "poll_interval",   PW_TYPE_INTEGER,
+         offsetof(listen_detail_t, poll_interval), NULL, Stringify(1)},
 
        { NULL, -1, 0, NULL, NULL }             /* end the list */
 };
@@ -788,6 +791,11 @@ int detail_parse(CONF_SECTION *cs, rad_listen_t *this)
                return -1;
        }
 
+       if ((data->poll_interval < 1) || (data->poll_interval > 3600)) {
+               cf_log_err(cf_sectiontoitem(cs), "poll_interval must be between 1 and 3600");
+               return -1;
+       }
+
        /*
         *      If the filename is a glob, use "detail.work" as the
         *      work file name.
@@ -834,4 +842,12 @@ int detail_parse(CONF_SECTION *cs, rad_listen_t *this)
 
        return 0;
 }
+
+int detail_poll_interval(rad_listen_t *listener)
+{
+       listen_detail_t *data = listener->data;
+
+       return data->poll_interval;
+}
+
 #endif
index ead4069..ccfd584 100644 (file)
@@ -3191,15 +3191,15 @@ static void event_poll_detail(void *ctx)
        fr_event_now(el, &now);
        when = now;
 
+       rad_assert(this->type == RAD_LISTEN_DETAIL);
+
        /*
-        *      Set the next poll time to be 10.0s to 10.5s, to help
+        *      Set the next poll time to be X +/- 0.5s, to help
         *      spread the load a bit over time.
         */
-       when.tv_sec += 10;
+       when.tv_sec += detail_poll_interval(this);
        when.tv_usec += fr_rand() % (USEC / 2);
 
-       rad_assert(this->type == RAD_LISTEN_DETAIL);
-
        /*
         *      Try to read something.
         *