Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Sep 2009 20:09:57 GMT
From:      alberto villa <villa.alberto@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   conf/138460: [patch] start local rc scripts in background
Message-ID:  <200909012009.n81K9vG0028672@www.freebsd.org>
Resent-Message-ID: <200909012010.n81KA4Hk006840@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         138460
>Category:       conf
>Synopsis:       [patch] start local rc scripts in background
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Sep 01 20:10:04 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     alberto villa
>Release:        FreeBSD 8-STABLE
>Organization:
>Environment:
FreeBSD echo.hoth 8.0-BETA2 FreeBSD 8.0-BETA2 #11: Sat Aug 15 17:55:03 CEST 2009     root@echo.hoth:/usr/obj/usr/src/sys/TPR60  i386
>Description:
starting every rc script in sequence makes long boot times. the only option to control this is background_dhclient, which can save up to 20 seconds, but local services take more than half the boot time
>How-To-Repeat:

>Fix:
the attached patch (/etc/rc) checks for local scripts which don't have to start BEFORE other scripts: it should be safe to start them in background, unless they depend on other local scripts (this shouldn't happen, but it should be handled anyway)
being able to control the behaviour with a rcvar (something like background_daemons=YES|NO) would be nice, but i wasn't able to get its value (for some reason, it resulted empty if read with load_rc_config 'background_daemons')

a /sbin/rcorder modification would be also needed to handle local scripts which depend on other local scripts... with rcorder listing background able scripts at the end, it would be easy

Patch attached with submission follows:

--- /etc/rc.orig	2009-09-01 15:20:23.231449039 +0200
+++ /etc/rc	2009-09-01 19:01:23.412933856 +0200
@@ -92,7 +92,7 @@
 	esac
 done
 
-unset files local_rc
+unset files late_files local_rc
 
 # Now that disks are mounted, for each dir in $local_startup
 # search for init scripts that use the new rc.d semantics.
@@ -113,7 +113,20 @@
 		;;
 	esac
 
-	run_rc_script ${_rc_elem} ${_boot}
+	case "$_rc_elem" in
+	/etc/rc.d/*)	_skip_late=0 ;;
+	*)	_skip_late=`grep --quiet '# BEFORE:' ${_rc_elem} 2>/dev/null; echo $?` ;;
+	esac
+
+	if [ ${_skip_late} -eq 1 ]; then
+		late_files="$late_files $_rc_elem"
+	else
+		run_rc_script ${_rc_elem} ${_boot}
+	fi
+done
+
+for _rc_elem in `echo ${late_files}`; do
+	run_rc_script ${_rc_elem} ${_boot} &
 done
 
 echo ''


>Release-Note:
>Audit-Trail:
>Unformatted:



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