Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 21 Aug 2011 15:20:45 +0200
From:      Jilles Tjoelker <jilles@stack.nl>
To:        d@delphij.net
Cc:        freebsd-rc@FreeBSD.ORG
Subject:   Re: [PATCH] Don't test if a service is enabled when it's required
Message-ID:  <20110821132045.GA3940@stack.nl>
In-Reply-To: <4E50B5E3.90702@delphij.net>
References:  <4E50B5E3.90702@delphij.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Aug 21, 2011 at 12:38:11AM -0700, Xin LI wrote:
> Currently we do a checkyesno before doing forcestatus on a service that 
> is required.  However, this way if a dependent service is enabled but 
> stopped, it would not be started.

> For instance:

> echo 'mountd_enable="YES"' >> /etc/rc.conf
> /etc/rc.d/mountd stop
> /etc/rc.d/nfsd stop
> /etc/rc.d/nfsd start

> Would not start mountd.

> I'd like to propose the attached patch since it doesn't seem to be 
> necessary that we test the enable status before doing forcestatus.

> Comments?

> Index: amd
> ===================================================================
> --- amd	(revision 225055)
> +++ amd	(working copy)
> @@ -23,8 +23,7 @@
>  		force_depend nfsclient || return 1
>  	fi
>  
> -	if ! checkyesno rpcbind_enable  && \
> -	    ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1
> +	if ! /etc/rc.d/rpcbind forcestatus 1>/dev/null 2>&1
>  	then
>  		force_depend rpcbind || return 1
>  	fi
[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).

-- 
Jilles Tjoelker



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