[PATCH] Don't test if a service is enabled when it's required
Jilles Tjoelker
jilles at stack.nl
Tue Aug 23 20:17:51 UTC 2011
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 at 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
More information about the freebsd-rc
mailing list