dhclient - Set state to S_REBOOTING when calling state_reboot().
authorAntonio Huete Jimenez <tuxillo@quantumachine.net>
Sat, 4 Aug 2012 19:05:11 +0000 (21:05 +0200)
committerAntonio Huete Jimenez <tuxillo@quantumachine.net>
Sun, 19 Aug 2012 14:30:54 +0000 (16:30 +0200)
- Also set state inside state_reboot() to S_INIT when calling
  state_init(). Rather than the other way around.
  Makes for more consistant idiom and might reduce state confusion.

Taken-from: OpenBSD

sbin/dhclient/dhclient.c

index e956f5e..3df23ea 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: src/sbin/dhclient/dhclient.c,v 1.143 2012/06/20 21:53:51 kettenis Exp $       */
+/*     $OpenBSD: src/sbin/dhclient/dhclient.c,v 1.144 2012/06/22 00:08:43 krw Exp $    */
 
 /*
  * Copyright 2004 Henning Brauer <henning@openbsd.org>
 
 /*
  * Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -242,7 +242,7 @@ routehandler(void)
 #endif
                        ifi->linkstat = interface_link_status(ifi->name);
                        if (ifi->linkstat) {
 #endif
                        ifi->linkstat = interface_link_status(ifi->name);
                        if (ifi->linkstat) {
-                               client->state = S_INIT;
+                               client->state = S_REBOOTING;
                                state_reboot();
                        }
                }
                                state_reboot();
                        }
                }
@@ -401,7 +401,7 @@ main(int argc, char *argv[])
        setproctitle("%s", ifi->name);
 
        if (ifi->linkstat) {
        setproctitle("%s", ifi->name);
 
        if (ifi->linkstat) {
-               client->state = S_INIT;
+               client->state = S_REBOOTING;
                state_reboot();
        } else
                go_daemon();
                state_reboot();
        } else
                go_daemon();
@@ -462,13 +462,11 @@ state_reboot(void)
 
        /* If we don't remember an active lease, go straight to INIT. */
        if (!client->active || client->active->is_bootp) {
 
        /* If we don't remember an active lease, go straight to INIT. */
        if (!client->active || client->active->is_bootp) {
+               client->state = S_INIT;
                state_init();
                return;
        }
 
                state_init();
                return;
        }
 
-       /* We are in the rebooting state. */
-       client->state = S_REBOOTING;
-
        /* make_request doesn't initialize xid because it normally comes
           from the DHCPDISCOVER, but we haven't sent a DHCPDISCOVER,
           so pick an xid now. */
        /* make_request doesn't initialize xid because it normally comes
           from the DHCPDISCOVER, but we haven't sent a DHCPDISCOVER,
           so pick an xid now. */