diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2013-01-18 06:05:55 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2013-01-18 06:05:55 +0000 |
commit | 91f2ec6e0320d7c82c9f68df096d1f1304914a81 (patch) | |
tree | c5d0753569621733660d75060c103497de823ebb | |
parent | 6d5e6800c9d483f813e31c19054627f83924736f (diff) |
Change a bunch of error()'s to warning()'s in the dispatch loop.
Set 'quit' to exit the loop in those situations, allowing more
cleanup() attempts in those error situations.
-rw-r--r-- | sbin/dhclient/dispatch.c | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c index fd5cf90e742..263dcc5f578 100644 --- a/sbin/dhclient/dispatch.c +++ b/sbin/dhclient/dispatch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dispatch.c,v 1.69 2012/12/29 14:40:00 krw Exp $ */ +/* $OpenBSD: dispatch.c,v 1.70 2013/01/18 06:05:54 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -120,13 +120,19 @@ dispatch(void) * a timeout registered, time out the select call then. */ another: - if (!ifi) - error("No interfaces available"); + if (!ifi) { + warning("No interfaces available"); + quit = SIGTERM; + continue; + } - if (ifi->rdomain != get_rdomain(ifi->name)) - error("Interface %s:" + if (ifi->rdomain != get_rdomain(ifi->name)) { + warning("Interface %s:" " rdomain changed out from under us", ifi->name); + quit = SIGTERM; + continue; + } if (timeout.func) { time(&cur_time); @@ -150,8 +156,11 @@ another: to_msec = -1; /* Set up the descriptors to be polled. */ - if (!ifi || ifi->rfdesc == -1) - error("No live interface to poll on"); + if (!ifi || ifi->rfdesc == -1) { + warning("No live interface to poll on"); + quit = SIGTERM; + continue; + } fds[0].fd = ifi->rfdesc; fds[1].fd = routefd; /* Could be -1, which will be ignored. */ @@ -168,8 +177,11 @@ another: if (count == -1) { if (errno == EAGAIN || errno == EINTR) { continue; - } else - error("poll: %s", strerror(errno)); + } else { + warning("poll: %s", strerror(errno)); + quit = SIGTERM; + continue; + } } if ((fds[0].revents & (POLLIN | POLLHUP))) { @@ -181,18 +193,25 @@ another: routehandler(); } if (fds[2].revents & POLLOUT) { - if (msgbuf_write(&unpriv_ibuf->w) == -1) - error("pipe write error to [priv]"); + if (msgbuf_write(&unpriv_ibuf->w) == -1) { + warning("pipe write error to [priv]"); + quit = SIGTERM; + continue; + } } if ((fds[2].revents & (POLLIN | POLLHUP))) { - error("lost connection to [priv]"); + warning("lost connection to [priv]"); + quit = SIGTERM; + continue; } } - if (quit == SIGHUP) { + if (client->active) cleanup(client->active); + + if (quit == SIGHUP) exit(0); - } + exit(1); } |