diff options
author | sam <sam@FreeBSD.org> | 2009-07-21 15:06:10 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2009-07-21 15:06:10 +0000 |
commit | 681dc8671b95f2964bc521648c150df9254f9e41 (patch) | |
tree | dc05916a69e7fe4d38e201bfa759129943f6f0bd /sbin/dhclient | |
parent | 19ec97d913abda4af6d9d2b97ca3e0203b73dfec (diff) | |
download | FreeBSD-src-681dc8671b95f2964bc521648c150df9254f9e41.zip FreeBSD-src-681dc8671b95f2964bc521648c150df9254f9e41.tar.gz |
Fix the logic to count the number of "live interfaces". With this change
dhclient now terminates when the underlying ifnet is destroyed (e.g.
on card eject).
Reviewed by: brooks
Approved by: re (kib)
Diffstat (limited to 'sbin/dhclient')
-rw-r--r-- | sbin/dhclient/dispatch.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c index 02766e0..3ee0cf6 100644 --- a/sbin/dhclient/dispatch.c +++ b/sbin/dhclient/dispatch.c @@ -144,7 +144,7 @@ reinitialize_interfaces(void) void dispatch(void) { - int count, i, to_msec, nfds = 0; + int count, live_interfaces, i, to_msec, nfds = 0; struct protocol *l; struct pollfd *fds; time_t howlong; @@ -188,18 +188,20 @@ another: to_msec = -1; /* Set up the descriptors to be polled. */ + live_interfaces = 0; for (i = 0, l = protocols; l; l = l->next) { struct interface_info *ip = l->local; - if (ip && (l->handler != got_one || !ip->dead)) { - fds[i].fd = l->fd; - fds[i].events = POLLIN; - fds[i].revents = 0; - i++; - } + if (ip == NULL || ip->dead) + continue; + fds[i].fd = l->fd; + fds[i].events = POLLIN; + fds[i].revents = 0; + i++; + if (l->handler == got_one) + live_interfaces++; } - - if (i == 0) + if (live_interfaces == 0) error("No live interfaces to poll on - exiting."); /* Wait for a packet or a timeout... XXX */ |