From owner-svn-src-stable@FreeBSD.ORG Sat Mar 7 19:45:08 2015 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id AF21834D; Sat, 7 Mar 2015 19:45:08 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7EFE8C21; Sat, 7 Mar 2015 19:45:08 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t27Jj8L1026687; Sat, 7 Mar 2015 19:45:08 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t27Jj81b026686; Sat, 7 Mar 2015 19:45:08 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201503071945.t27Jj81b026686@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sat, 7 Mar 2015 19:45:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r279745 - stable/10/usr.sbin/autofs X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Mar 2015 19:45:08 -0000 Author: trasz Date: Sat Mar 7 19:45:07 2015 New Revision: 279745 URL: https://svnweb.freebsd.org/changeset/base/279745 Log: MFC r277834: When there are no automounted filesystems, autounmountd(8) should wait for filesystem event, instead of looping on a timeout. Sponsored by: The FreeBSD Foundation Modified: stable/10/usr.sbin/autofs/autounmountd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/autofs/autounmountd.c ============================================================================== --- stable/10/usr.sbin/autofs/autounmountd.c Sat Mar 7 19:41:58 2015 (r279744) +++ stable/10/usr.sbin/autofs/autounmountd.c Sat Mar 7 19:45:07 2015 (r279745) @@ -182,7 +182,7 @@ expire_automounted(double expiration_tim { struct automounted_fs *af, *tmpaf; time_t now; - double mounted_for, mounted_max = 0; + double mounted_for, mounted_max = -1.0; int error; now = time(NULL); @@ -231,21 +231,28 @@ do_wait(int kq, double sleep_time) { struct timespec timeout; struct kevent unused; - int error; - - assert(sleep_time > 0); - timeout.tv_sec = sleep_time; - timeout.tv_nsec = 0; + int nevents; - log_debugx("waiting for filesystem event for %.0f seconds", sleep_time); - error = kevent(kq, NULL, 0, &unused, 1, &timeout); - if (error < 0) + if (sleep_time != -1.0) { + assert(sleep_time > 0.0); + timeout.tv_sec = sleep_time; + timeout.tv_nsec = 0; + + log_debugx("waiting for filesystem event for %.0f seconds", sleep_time); + nevents = kevent(kq, NULL, 0, &unused, 1, &timeout); + } else { + log_debugx("waiting for filesystem event"); + nevents = kevent(kq, NULL, 0, &unused, 1, NULL); + } + if (nevents < 0) log_err(1, "kevent"); - if (error == 0) + if (nevents == 0) { log_debugx("timeout reached"); - else + assert(sleep_time > 0.0); + } else { log_debugx("got filesystem event"); + } } int @@ -324,7 +331,10 @@ main_autounmountd(int argc, char **argv) for (;;) { refresh_automounted(); mounted_max = expire_automounted(expiration_time); - if (mounted_max < expiration_time) { + if (mounted_max == -1.0) { + sleep_time = mounted_max; + log_debugx("no filesystems to expire"); + } else if (mounted_max < expiration_time) { sleep_time = difftime(expiration_time, mounted_max); log_debugx("some filesystems expire in %.0f seconds", sleep_time);