]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
For infinite timeout, we now resent the last request at +TIMEOUT_MINI
authorRoy Marples <roy@marples.name>
Thu, 18 Jan 2007 14:02:40 +0000 (14:02 +0000)
committerRoy Marples <roy@marples.name>
Thu, 18 Jan 2007 14:02:40 +0000 (14:02 +0000)
intervals until TIMEOUT_MINI_INF is reached, thanks to Steve.

ChangeLog
client.c

index 893ad31e75ee0d856eea605f20b8611b8056eaae..83e80e358746797fa5bf3f0fa2cde714dcdfb932 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,5 @@
-For infinite timeout, we now resent the last request at TIMEOUT_MINI
-intervals like we do otherwise.
+For infinite timeout, we now resent the last request at +TIMEOUT_MINI
+intervals until TIMEOUT_MINI_INF is reached, thanks to Steve.
 We now return a non zero exit code on SIGTERM and SIGINT if we have not
 forked into the background.
 When NIS and/or NTP servers are updated, we restart the service for them
index e611cee3f76f5643025a153b033beb23bc9935e0..0ec43e7b7181a0353d564e48d2b82a15c1726144 100644 (file)
--- a/client.c
+++ b/client.c
@@ -52,6 +52,9 @@
 /* This is out mini timeout.
    Basically we resend the last request every TIMEOUT_MINI seconds. */
 #define TIMEOUT_MINI           3
+/* Except for an infinite timeout. We keep adding TIMEOUT_MINI to
+   ourself until TIMEOUT_MINI_INF is reached. */
+#define TIMEOUT_MINI_INF       60
 
 #define STATE_INIT             0
 #define STATE_REQUESTING       1
@@ -171,11 +174,18 @@ int dhcp_run (const options_t *options)
        {
          if (options->timeout == 0 || dhcp->leasetime == (unsigned) -1)
            {
+             int retry = 0;
              logger (LOG_DEBUG, "waiting on select for infinity");
              retval = 0;
              while (retval == 0)
                {
-                 tv.tv_sec = TIMEOUT_MINI;
+                 /* Slow down our requests */
+                 if (retry < TIMEOUT_MINI_INF)
+                   retry += TIMEOUT_MINI;
+                 else if (retry > TIMEOUT_MINI_INF)
+                   retry = TIMEOUT_MINI_INF;
+
+                 tv.tv_sec = retry;
                  tv.tv_usec = 0;
                  maxfd = signal_fd_set (&rset, iface->fd);
                  retval = select (maxfd + 1, &rset, NULL, NULL, &tv);