]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Try and stop a flapping timeout.
authorRoy Marples <roy@marples.name>
Fri, 18 Jul 2008 13:43:25 +0000 (13:43 +0000)
committerRoy Marples <roy@marples.name>
Fri, 18 Jul 2008 13:43:25 +0000 (13:43 +0000)
client.c

index 0f0994f287588a66c2d058717eab77599747b936..2a1f1d2ea34d947caa36dc076afb3445620753f4 100644 (file)
--- a/client.c
+++ b/client.c
@@ -740,17 +740,24 @@ wait_for_packet(struct if_state *state)
        }
 
        ref = NULL;
-       if (timerisset(&state->exit) &&
-           timercmp(&state->exit, &now, >))
-               ref = &state->exit;
-       if (timerisset(&state->stop) &&
-           timercmp(&state->stop, &now, >) &&
-           (!ref || timercmp(&state->stop, ref, <)))
-               ref = &state->stop;
-       if (timerisset(&state->timeout) &&
-           timercmp(&state->timeout, &now, >) &&
-           (!ref || timercmp(&state->timeout, ref, <)))
-               ref = &state->timeout;
+       if (timerisset(&state->exit)) {
+               if (timercmp(&state->exit, &now, <=))
+                       return 0;
+               else
+                       ref = &state->exit;
+       }
+       if (timerisset(&state->stop)) {
+               if (timercmp(&state->stop, &now, <=))
+                       return 0;
+               else if (!ref || timercmp(&state->stop, ref, <))
+                       ref = &state->stop;
+       }
+       if (timerisset(&state->timeout)) {
+               if (timercmp(&state->timeout, &now, <=))
+                       return 0;
+               else if (!ref || timercmp(&state->timeout, ref, <))
+                       ref = &state->timeout;
+       }
 
        if (state->lease.leasetime == ~0U &&
            state->state == STATE_BOUND)
@@ -807,11 +814,6 @@ wait_again:
        }
 
        retval = poll(fds, nfds, timeout);
-       if (timeout != INFTIM) {
-               get_time(&now);
-               if (timercmp(&now, &state->timeout, >))
-                       timerclear(&state->timeout);
-       }
        if (retval == -1) {
                if (errno == EINTR)
                        return 0;
@@ -1113,6 +1115,7 @@ handle_timeout(struct if_state *state, const struct options *options)
 #ifdef ENABLE_ARP
        struct in_addr addr;
 
+       timerclear(&state->timeout);
        timerclear(&tv);
        switch (state->state) {
 #ifdef ENABLE_IPV4LL
@@ -1733,7 +1736,7 @@ dhcp_run(const struct options *options, int *pid_fd)
                                if (retval == 0 &&
                                    (state->state == STATE_REQUESTING ||
                                     state->state == STATE_INIT ||
-                                    state->state == STATE_PROBING)
+                                    state->state == STATE_PROBING))
                                        /* Fallthrough to handle_timeout */
                                        continue;
 #ifdef ENABLE_ARP