Index: head/libexec/rc/rc =================================================================== --- head/libexec/rc/rc +++ head/libexec/rc/rc @@ -71,6 +71,12 @@ . /etc/rc.subr load_rc_config +# rc_parallel_start default is "NO" +rc_parallel_start=${rc_parallel_start:-NO} +_rc_parallel='' +# enable rcorder -p if /etc/rc.conf rc_parallel_start is "YES" +checkyesno rc_parallel_start && _rc_parallel='-p' + # If we receive a SIGALRM, re-source /etc/rc.conf; this allows rc.d # scripts to perform "boot-time configuration" including enabling and # disabling rc.d scripts which appear later in the boot order. @@ -92,16 +98,22 @@ # Do a first pass to get everything up to $early_late_divider so that # we can do a second pass that includes $local_startup directories # -files=`rcorder ${skip} ${skip_firstboot} /etc/rc.d/* 2>/dev/null` +files=`rcorder ${skip} ${skip_firstboot} ${_rc_parallel} /etc/rc.d/* 2>/dev/null` _rc_elem_done=' ' -for _rc_elem in ${files}; do - run_rc_script ${_rc_elem} ${_boot} - _rc_elem_done="${_rc_elem_done}${_rc_elem} " - - case "$_rc_elem" in - */${early_late_divider}) break ;; - esac +IFS=$'\n' +for _rc_group in ${files}; do + IFS=$' ' + for _rc_elem in ${_rc_group}; do + run_rc_script ${_rc_elem} ${_boot} & + _rc_elem_done="${_rc_elem_done}${_rc_elem} " + + case "$_rc_elem" in + */${early_late_divider}) break ;; + esac + done + wait + IFS=$'\n' done unset files local_rc @@ -120,14 +132,21 @@ skip_firstboot="" fi -files=`rcorder ${skip} ${skip_firstboot} /etc/rc.d/* ${local_rc} 2>/dev/null` -for _rc_elem in ${files}; do - case "$_rc_elem_done" in - *" $_rc_elem "*) continue ;; - esac - - run_rc_script ${_rc_elem} ${_boot} +files=`rcorder ${skip} ${skip_firstboot} /etc/rc.d/* ${local_rc} ${_rc_parallel} 2>/dev/null` +IFS=$'\n' +for _rc_group in ${files}; do + IFS=$' ' + for _rc_elem in ${_rc_group}; do + case "$_rc_elem_done" in + *" $_rc_elem "*) continue ;; + esac + + run_rc_script ${_rc_elem} ${_boot} & + done + wait + IFS=$'\n' done +unset IFS # Remove the firstboot sentinel, and reboot if it was requested. # Be a bit paranoid about removing it to handle the common failure