From owner-svn-src-all@FreeBSD.ORG Mon Mar 21 08:31:35 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 98BE3106566B; Mon, 21 Mar 2011 08:31:35 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8756A8FC0C; Mon, 21 Mar 2011 08:31:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2L8VZ5B004703; Mon, 21 Mar 2011 08:31:35 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2L8VZ6P004701; Mon, 21 Mar 2011 08:31:35 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201103210831.p2L8VZ6P004701@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Mon, 21 Mar 2011 08:31:35 +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: r219813 - head/sbin/hastd X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Mar 2011 08:31:35 -0000 Author: pjd Date: Mon Mar 21 08:31:35 2011 New Revision: 219813 URL: http://svn.freebsd.org/changeset/base/219813 Log: If there is any traffic on one of out descriptors, we were not checking for long running hooks. Fix it by not using select(2) timeout to decide if we want to check hooks or not. MFC after: 1 week Modified: head/sbin/hastd/hastd.c Modified: head/sbin/hastd/hastd.c ============================================================================== --- head/sbin/hastd/hastd.c Mon Mar 21 06:18:26 2011 (r219812) +++ head/sbin/hastd/hastd.c Mon Mar 21 08:31:35 2011 (r219813) @@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -877,9 +878,11 @@ main_loop(void) struct timeval seltimeout; struct timespec sigtimeout; int fd, maxfd, ret, signo; + time_t lastcheck, now; sigset_t mask; fd_set rfds; + lastcheck = time(NULL); seltimeout.tv_sec = REPORT_INTERVAL; seltimeout.tv_usec = 0; sigtimeout.tv_sec = 0; @@ -943,9 +946,18 @@ main_loop(void) PJDLOG_ASSERT(maxfd + 1 <= (int)FD_SETSIZE); ret = select(maxfd + 1, &rfds, NULL, NULL, &seltimeout); - if (ret == 0) + now = time(NULL); + if (lastcheck + REPORT_INTERVAL <= now) { hook_check(); - else if (ret == -1) { + lastcheck = now; + } + if (ret == 0) { + /* + * select(2) timed out, so there should be no + * descriptors to check. + */ + continue; + } else if (ret == -1) { if (errno == EINTR) continue; KEEP_ERRNO((void)pidfile_remove(pfh));