Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Jul 2016 19:51:55 +0000 (UTC)
From:      Jamie Gritton <jamie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r302855 - head/etc/rc.d
Message-ID:  <201607141951.u6EJptPs064003@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jamie
Date: Thu Jul 14 19:51:54 2016
New Revision: 302855
URL: https://svnweb.freebsd.org/changeset/base/302855

Log:
  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:
  head/etc/rc.d/jail

Modified: head/etc/rc.d/jail
==============================================================================
--- head/etc/rc.d/jail	Thu Jul 14 18:49:05 2016	(r302854)
+++ head/etc/rc.d/jail	Thu Jul 14 19:51:54 2016	(r302855)
@@ -440,7 +440,7 @@ jail_status()
 
 jail_start()
 {
-	local _j _jv _jid _jl _id _name
+	local _j _jv _jid _id _name
 
 	if [ $# = 0 ]; then
 		return
@@ -470,29 +470,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?201607141951.u6EJptPs064003>