From owner-svn-src-head@FreeBSD.ORG Tue Jul 21 15:06:10 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B7174106564A; Tue, 21 Jul 2009 15:06:10 +0000 (UTC) (envelope-from sam@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A5ACA8FC17; Tue, 21 Jul 2009 15:06:10 +0000 (UTC) (envelope-from sam@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n6LF6A88014638; Tue, 21 Jul 2009 15:06:10 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n6LF6A7h014636; Tue, 21 Jul 2009 15:06:10 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200907211506.n6LF6A7h014636@svn.freebsd.org> From: Sam Leffler Date: Tue, 21 Jul 2009 15:06:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r195805 - head/sbin/dhclient X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jul 2009 15:06:11 -0000 Author: sam Date: Tue Jul 21 15:06:10 2009 New Revision: 195805 URL: http://svn.freebsd.org/changeset/base/195805 Log: 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) Modified: head/sbin/dhclient/dispatch.c Modified: head/sbin/dhclient/dispatch.c ============================================================================== --- head/sbin/dhclient/dispatch.c Tue Jul 21 14:23:05 2009 (r195804) +++ head/sbin/dhclient/dispatch.c Tue Jul 21 15:06:10 2009 (r195805) @@ -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 */