diff options
author | 2014-11-13 00:33:35 +0000 | |
---|---|---|
committer | 2014-11-13 00:33:35 +0000 | |
commit | a3da2285e0505f5d0b8f8ff2039b3df1260471e8 (patch) | |
tree | aa6689bea8caacd3f43c1b6d32e664e441fe75e7 | |
parent | Restore change in r1.17 but add checks to prevent the line length (diff) | |
download | wireguard-openbsd-a3da2285e0505f5d0b8f8ff2039b3df1260471e8.tar.xz wireguard-openbsd-a3da2285e0505f5d0b8f8ff2039b3df1260471e8.zip |
Tweak some comments and error messages. Put all "I can't handle
this" tests at the top of the dispatch loop. Use a 'continue' instead
of 'goto <label just after the while>'. No intended functional change.
-rw-r--r-- | sbin/dhclient/dispatch.c | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c index f0380cf54d0..8f8f96e08cb 100644 --- a/sbin/dhclient/dispatch.c +++ b/sbin/dhclient/dispatch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dispatch.c,v 1.90 2014/05/05 18:02:49 krw Exp $ */ +/* $OpenBSD: dispatch.c,v 1.91 2014/11/13 00:33:35 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -137,21 +137,18 @@ dispatch(void) void (*func)(void); while (quit == 0) { - /* - * Call expired timeout, and then if there's still - * a timeout registered, time out the select call then. - */ -another: if (!ifi) { - warning("No interfaces available"); + warning("No interface!"); quit = INTERNALSIG; continue; } - if (ifi->rdomain != get_rdomain(ifi->name)) { - warning("Interface %s:" - " rdomain changed out from under us", - ifi->name); + warning("%s rdomain changed; exiting", ifi->name); + quit = INTERNALSIG; + continue; + } + if (ifi->rfdesc == -1) { + warning("%s bpf socket gone; exiting"); quit = INTERNALSIG; continue; } @@ -162,7 +159,7 @@ another: func = timeout.func; cancel_timeout(); (*(func))(); - goto another; + continue; } /* * Figure timeout in milliseconds, and check for @@ -177,25 +174,22 @@ another: } else to_msec = -1; - /* Set up the descriptors to be polled. */ - if (!ifi || ifi->rfdesc == -1) { - warning("No live interface to poll on"); - quit = INTERNALSIG; - continue; - } - + /* + * Set up the descriptors to be polled. + * + * fds[0] == bpf socket for incoming packets + * fds[1] == routing socket for incoming RTM messages + * fds[2] == imsg socket to privileged process + */ fds[0].fd = ifi->rfdesc; - fds[1].fd = routefd; /* Could be -1, which will be ignored. */ + fds[1].fd = routefd; fds[2].fd = unpriv_ibuf->fd; fds[0].events = fds[1].events = fds[2].events = POLLIN; if (unpriv_ibuf->w.queued) fds[2].events |= POLLOUT; - /* Wait for a packet or a timeout or unpriv_ibuf->fd. XXX */ count = poll(fds, 3, to_msec); - - /* Not likely to be transitory. */ if (count == -1) { if (errno == EAGAIN || errno == EINTR) { continue; |