From: Roy Marples Date: Mon, 21 Jul 2008 14:05:35 +0000 (+0000) Subject: OK, the loop was caused by the initial carrier timeout. Also, always log carrier... X-Git-Tag: v4.0.2~149 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e7503fec222f8244de607f216cf7abe5000d13fc;p=thirdparty%2Fdhcpcd.git OK, the loop was caused by the initial carrier timeout. Also, always log carrier waiting, but don't spam the console when backgrounding. --- diff --git a/client.c b/client.c index 9a7930c5..59d50459 100644 --- a/client.c +++ b/client.c @@ -600,14 +600,11 @@ client_setup(struct if_state *state, const struct options *options) } } #endif + if (state->options & DHCPCD_LINK) { open_link_socket(iface); - if (carrier_status(iface->name) == 0) { - if (state->options & DHCPCD_DAEMONISE && - !(state->options & DHCPCD_BACKGROUND)) - logger(LOG_INFO, "waiting for carrier"); + if (carrier_status(iface->name) == 0) state->carrier = LINK_DOWN; - } } if (options->timeout > 0 && @@ -1026,7 +1023,8 @@ handle_timeout_fail(struct if_state *state, const struct options *options) if (iface->addr.s_addr != 0 && !(state->options & DHCPCD_INFORM)) logger(LOG_ERR, "lost lease"); - else + else if (state->carrier != LINK_DOWN || + !(state->options & DHCPCD_DAEMONISED)) logger(LOG_ERR, "timed out"); } do_socket(state, SOCKET_CLOSED); @@ -1224,7 +1222,13 @@ handle_timeout(struct if_state *state, const struct options *options) } #endif + if (timerisset(&state->stop)) { + get_time(&tv); + if (timercmp(&tv, &state->stop, >)) + return handle_timeout_fail(state, options); + } timerclear(&tv); + switch (state->state) { case STATE_BOUND: /* FALLTHROUGH */ case STATE_RENEW_REQUESTED: @@ -1237,13 +1241,6 @@ handle_timeout(struct if_state *state, const struct options *options) state->nakoff = 1; iface->start_uptime = uptime(); break; - default: - if (!timerisset(&state->stop)) - break; - get_time(&tv); - if (timercmp(&tv, &state->stop, >)) - return handle_timeout_fail(state, options); - break; } switch(state->state) { @@ -1710,6 +1707,9 @@ dhcp_run(const struct options *options, int *pid_fd) if (daemonise(state, options) == -1) goto eexit; + if (state->carrier == LINK_DOWN) + logger(LOG_INFO, "waiting for carrier"); + for (;;) { /* We should always handle our signals first */ if ((sig = (signal_read(state->signal_fd))) != -1) {