Use the allexport option in load_rc_config() in order to avoid having

to repeatedly read the conf files. Depending on what is enabled the
files are being read anywhere from 15, 30, or more times currently.
By loading the values in the environment this is reduced to 1, with
perhaps a couple more, again depending on what is enabled.

The speed-up for boot and shutdown is negligible when rc.conf is
on local disk, noticable when accessing files over NFS, and dramatic
when pulling rc.conf values from a database.

This change also includes a minor optimization to the conditional
for $_rc_conf_loaded.
This commit is contained in:
dougb 2011-03-12 21:13:08 +00:00
parent 1d7bc8e314
commit 1a54928233

View File

@ -998,9 +998,8 @@ load_rc_config()
err 3 'USAGE: load_rc_config name'
fi
if ${_rc_conf_loaded:-false}; then
:
else
if [ -z "$_rc_conf_loaded" ]; then
set -o allexport
if [ -r /etc/defaults/rc.conf ]; then
debug "Sourcing /etc/defaults/rc.conf"
. /etc/defaults/rc.conf
@ -1010,6 +1009,7 @@ load_rc_config()
. /etc/rc.conf
fi
_rc_conf_loaded=true
set +o allexport
fi
if [ -f /etc/rc.conf.d/"$_name" ]; then
debug "Sourcing /etc/rc.conf.d/${_name}"