Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Aug 2011 22:17:48 +0200
From:      Jilles Tjoelker <jilles@stack.nl>
To:        Xin LI <delphij@gmail.com>
Cc:        freebsd-rc@freebsd.org
Subject:   Re: [PATCH] Don't test if a service is enabled when it's required
Message-ID:  <20110823201748.GA70915@stack.nl>
In-Reply-To: <CAGMYy3u25PA0faZzScnTmJMRfWUHx6DCpFKY7TYg_AukcYgH3w@mail.gmail.com>
References:  <4E50B5E3.90702@delphij.net> <20110821132045.GA3940@stack.nl> <CAGMYy3u25PA0faZzScnTmJMRfWUHx6DCpFKY7TYg_AukcYgH3w@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Aug 21, 2011 at 03:16:32PM -0700, Xin LI wrote:
> On Sun, Aug 21, 2011 at 6:20 AM, Jilles Tjoelker <jilles@stack.nl> wrote:
> [snip]
> > I don't like that this adds a bunch of unnecessary checks to the boot.
> > If we are booting and the appropriate variable is set, the service is
> > running and it is not necessary to check for a process (unless it
> > failed, in which case there is little point in trying again). Calling
> > checkyesno is much faster than checking status (which forks several
> > times and reads ps output byte-by-byte with the read builtin).

> That's good point but isn't the whole point of having forced
> dependencies to ease use?  (For instance, if nfsd requires mountd to
> be started, why it starts mountd for user when _enabled="NO" and not
> when _enabled="YES"?  I think starting anyway makes more sense...)

> I'll take a look at whether we can make the 'fast' path skip these
> checks, e.g. change these checks against _enabled to check rc_fast
> instead, do you think that would be more sensible solution for this?

What could work is

if { [ -z "$rc_fast" ] || ! checkyesno rpcbind_enable; } &&
	! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1
then
	force_depend rpcbind || return 1
fi

This means:
* If rc_fast is empty, check for a process.
* If rc_fast is empty and the rc.conf variable is not set, check for a
  process (a check is required, since a previous script may have started
  the service already due to a similar check).
* If rc_fast is empty and the rc.conf variable is set, do not check for
  a process and do not run force_depend.

This looks complicated enough that it would be beneficial to move it
into (a variant of) force_depend.

-- 
Jilles Tjoelker



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110823201748.GA70915>