From: Roy Marples Date: Wed, 25 Feb 2009 07:52:07 +0000 (+0000) Subject: Don't timeout if we're daemonised. X-Git-Tag: v5.0.0~59 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e59105abf07540504b49d54ffbb547b907cc0e44;p=thirdparty%2Fdhcpcd.git Don't timeout if we're daemonised. --- diff --git a/dhcp.c b/dhcp.c index 2689b734..e836211a 100644 --- a/dhcp.c +++ b/dhcp.c @@ -816,7 +816,7 @@ make_message(struct dhcp_message **message, } dhcp->xid = iface->state->xid; dhcp->cookie = htonl(MAGIC_COOKIE); - +#if 0 *p++ = DHO_MESSAGETYPE; *p++ = 1; *p++ = type; @@ -952,7 +952,7 @@ make_message(struct dhcp_message **message, *n_params = p - n_params - 1; } *p++ = DHO_END; - +#endif #ifdef BOOTP_MESSAGE_LENTH_MIN /* Some crappy DHCP servers think they have to obey the BOOTP minimum * message length. diff --git a/dhcpcd.c b/dhcpcd.c index 64372c6b..95d7b2ce 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -1446,7 +1446,15 @@ main(int argc, char **argv) add_event(linkfd, handle_link, NULL); } - if (options & DHCPCD_DAEMONISE && !(options & DHCPCD_BACKGROUND)) { + ifc = argc - optind; + ifv = argv + optind; + if (options & DHCPCD_BACKGROUND || + (ifc == 0 && + options & DHCPCD_LINK && + options & DHCPCD_DAEMONISE)) + { + daemonise(); + } else if (options & DHCPCD_DAEMONISE) { oi = ifo->timeout; if (ifo->options & DHCPCD_IPV4LL) oi += 10; @@ -1454,11 +1462,6 @@ main(int argc, char **argv) } free_options(ifo); - ifc = argc - optind; - ifv = argv + optind; - if (ifc == 0 && options & (DHCPCD_LINK | DHCPCD_DAEMONISE)) - daemonise(); - ifaces = discover_interfaces(ifc, ifv); for (i = 0; i < ifc; i++) { for (iface = ifaces; iface; iface = iface->next) @@ -1471,17 +1474,13 @@ main(int argc, char **argv) if (!ifaces) { if (ifc == 0) syslog(LOG_ERR, "no valid interfaces found"); - if (!(options & DHCPCD_BACKGROUND) || - !(options & DHCPCD_LINK)) - { + if (!(options & DHCPCD_LINK)) { syslog(LOG_ERR, "aborting as we're not backgrounding" " with link detection"); exit(EXIT_FAILURE); } } - if (options & DHCPCD_BACKGROUND) - daemonise(); for (iface = ifaces; iface; iface = iface->next) init_state(iface, argc, argv); sort_interfaces();