Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 17 Jul 2016 14:12:34 +0000 (UTC)
From:      Jamie Gritton <jamie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r302956 - stable/10/etc/rc.d
Message-ID:  <201607171412.u6HECY3f037154@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jamie
Date: Sun Jul 17 14:12:34 2016
New Revision: 302956
URL: https://svnweb.freebsd.org/changeset/base/302956

Log:
  MFC r302855:
  
      Wait for jails to complete startup if jail_parallel_start is YES,
      instead of assuming they'll take less than one second.
  
  PR:		203172
  Submitted by:	dmitry2004@yandex.ru

Modified:
  stable/10/etc/rc.d/jail
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/etc/rc.d/jail
==============================================================================
--- stable/10/etc/rc.d/jail	Sun Jul 17 14:07:51 2016	(r302955)
+++ stable/10/etc/rc.d/jail	Sun Jul 17 14:12:34 2016	(r302956)
@@ -422,7 +422,7 @@ jail_status()
 
 jail_start()
 {
-	local _j _jv _jid _jl _id _name
+	local _j _jv _jid _id _name
 
 	if [ $# = 0 ]; then
 		return
@@ -452,29 +452,30 @@ jail_start()
 		# Start jails in parallel and then check jail id when
 		# jail_parallel_start is YES.
 		#
-		_jl=
 		for _j in $@; do
 			_j=$(echo $_j | tr /. _)
 			_jv=$(echo -n $_j | tr -c '[:alnum:]' _)
 			parse_options $_j $_jv || continue
 
-			_jl="$_jl $_j"
 			eval rc_flags=\${jail_${_jv}_flags:-$jail_flags}
 			eval command=\${jail_${_jv}_program:-$jail_program}
 			command_args="-i -f $_conf -c $_j"
-			$command $rc_flags $command_args \
-			    >/dev/null 2>&1 </dev/null &
-		done
-		sleep 1
-		for _j in $_jl; do
-			echo -n " ${_hostname:-${_j}}"
-			if _jid=$($jail_jls -j $_j jid); then
-				echo "$_jid" > /var/run/jail_${_j}.id
-			else
-				echo " cannot start jail " \
-				    "\"${_hostname:-${_j}}\": "
-			fi
+			(
+				_tmp=`mktemp -t jail_${_j}` || exit 3
+				if $command $rc_flags $command_args \
+				    >> $_tmp 2>&1 </dev/null; then
+					echo -n " ${_hostname:-${_j}}"
+					_jid=$($jail_jls -j $_j jid)
+					echo $_jid > /var/run/jail_${_j}.id
+				else
+					echo " cannot start jail " \
+					    "\"${_hostname:-${_j}}\": "
+					cat $_tmp
+				fi
+				rm -f $_tmp
+			) &
 		done
+		wait
 	else
 		#
 		# Start jails one-by-one when jail_parallel_start is NO.



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