changeset 50:3f2ea979ac17 draft

For infinite timeout, we now resent the last request at +TIMEOUT_MINI intervals until TIMEOUT_MINI_INF is reached, thanks to Steve.
author Roy Marples <roy@marples.name>
date Thu, 18 Jan 2007 14:02:40 +0000
parents 945de31c6944
children 037d27d470b2
files ChangeLog client.c
diffstat 2 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Jan 17 18:24:18 2007 +0000
+++ b/ChangeLog	Thu Jan 18 14:02:40 2007 +0000
@@ -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
--- a/client.c	Wed Jan 17 18:24:18 2007 +0000
+++ b/client.c	Thu Jan 18 14:02:40 2007 +0000
@@ -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 @@
 	{
 	  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);