From: Roy Marples Date: Thu, 18 Jan 2007 14:02:40 +0000 (+0000) Subject: For infinite timeout, we now resent the last request at +TIMEOUT_MINI X-Git-Tag: v3.2.3~324 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=09212ea7595883887de9feeb1062e4d30d42266d;p=thirdparty%2Fdhcpcd.git For infinite timeout, we now resent the last request at +TIMEOUT_MINI intervals until TIMEOUT_MINI_INF is reached, thanks to Steve. --- diff --git a/ChangeLog b/ChangeLog index 893ad31e..83e80e35 100644 --- 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 diff --git a/client.c b/client.c index e611cee3..0ec43e7b 100644 --- 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);