Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 51435 Details for
Bug 69854
parallel startup scripts is not parallel enough
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
parallel patch for baselayout 1.11.9-r1
parallel.patch (text/plain), 8.87 KB, created by
Paul Pacheco
on 2005-02-17 06:41:14 UTC
(
hide
)
Description:
parallel patch for baselayout 1.11.9-r1
Filename:
MIME Type:
Creator:
Paul Pacheco
Created:
2005-02-17 06:41:14 UTC
Size:
8.87 KB
patch
obsolete
>--- /sbin/depscan.sh.orig 2005-02-17 08:16:22.000000000 -0600 >+++ /sbin/depscan.sh 2005-02-17 08:19:06.339628872 -0600 >@@ -13,7 +13,7 @@ > fi > fi > >-for x in softscripts snapshot options started >+for x in softscripts snapshot options started exclusive exitcodes > do > if [ ! -d "${svcdir}/${x}" ] > then >--- /sbin/rc.orig 2005-02-17 08:16:22.000000000 -0600 >+++ /sbin/rc 2005-02-17 08:20:42.861955248 -0600 >@@ -429,6 +429,8 @@ > > splash "rc_init" "${argv1}" > >+ export START_CRITICAL="yes" >+ > # We do not want to break compatibility, so we do not fully integrate > # these into /sbin/rc, but rather start them by hand ... > for x in ${CRITICAL_SERVICES} >@@ -453,6 +455,8 @@ > splash "svc_started" "${x}" "0" > done > >+ unset START_CRITICAL >+ > # Check that $svcdir exists ... > check_statedir "${svcdir}" > >--- /sbin/runscript.sh.orig 2005-02-17 08:16:22.000000000 -0600 >+++ /sbin/runscript.sh 2005-02-17 08:29:46.135365136 -0600 >@@ -237,30 +237,63 @@ > > for y in ${netservices} ; do > mynetservice="${y##*/}" >- >- if ! service_started "${mynetservice}" ; then >- start_service "${mynetservice}" >- >- # A 'need' dependency is critical for startup >- if [[ $? -ne 0 ]] && ineed -t "${myservice}" "${x}" >/dev/null ; then >- # Only worry about a net.* service if we do not have one >- # up and running already, or if RC_NET_STRICT_CHECKING >- # is set .... >- if ! is_net_up ; then >- startfail="yes" >- fi >+ start_service "${mynetservice}" >+ >+ # If parallel startup is disabled, the exit code will be returned immediatelly >+ # and may not be saved for later because we may not have >+ # write access yet. >+ if [ "$?" -ne 0 ] && ineed -t "${myservice}" "${x}" >/dev/null ; then >+ # Only worry about a net.* service if we do not have one >+ # up and running already, or if RC_NET_STRICT_CHECKING >+ # is set .... >+ if ! is_net_up ; then >+ startfail="yes" > fi > fi >+ > done > > elif [[ ${x} != "net" ]] ; then >- if ! service_started "${x}" ; then >- start_service "${x}" >+ start_service "${x}" >+ >+ # If parallel startup is disabled, the exit code will be returned immediatelly >+ # and may not be saved for later because we may not have >+ # write access yet >+ if [ "$?" -ne 0 ] && ineed -t "${myservice}" "${x}" >/dev/null ; then >+ startfail="yes" >+ fi >+ fi >+ done >+ >+ # wait for dependencies to finish >+ for x in ${startupservices} ; do >+ if [ "${x}" = "net" -a "${NETSERVICE}" != "yes" ] ; then >+ local netservices="$(dolisting "/etc/runlevels/${BOOTLEVEL}/net.*") \ >+ $(dolisting "/etc/runlevels/${mylevel}/net.*")" >+ >+ for y in ${netservices} ; do >+ mynetservice="${y##*/}" >+ >+ wait_service "${mynetservice}" > >- # A 'need' dependacy is critical for startup >- if [[ $? -ne 0 ]] && ineed -t "${myservice}" "${x}" >/dev/null ; then >- startfail="yes" >+ # A 'need' dependency is critical for startup >+ if [ "$?" -ne 0 ] && ineed -t "${myservice}" "${x}" >/dev/null ; then >+ # Only worry about a net.* service if we do not have one >+ # up and running already, or if RC_NET_STRICT_CHECKING >+ # is set .... >+ if ! is_net_up ; then >+ startfail="yes" >+ fi > fi >+ done >+ >+ elif [ "${x}" != "net" ] ; then >+ >+ wait_service "${x}" >+ >+ # A 'need' dependacy is critical for startup >+ if [ "$?" -ne 0 ] && ineed -t "${myservice}" "${x}" >/dev/null ; then >+ startfail="yes" > fi > fi > done >--- /lib/rcscripts/sh/rc-services.sh.orig 2005-02-17 08:16:22.000000000 -0600 >+++ /lib/rcscripts/sh/rc-services.sh 2005-02-17 08:19:06.348627504 -0600 >@@ -397,31 +397,128 @@ > return 1 > } > >+# bool begin_service( service ) >+# >+# atomically marks the service as being executed >+# use like this: >+# >+# if begion_service service ; then >+# whatever is in here can only be executed by one process >+# end_service service >+# fi >+ >+begin_service() >+{ >+ local service="$1" >+ [ "$START_CRITICAL" == "yes" ] && return 0 >+ >+ mkfifo "${svcdir}/exclusive/${service}" &> /dev/null >+ return $? >+} >+ >+# void end_exclusive(service, exitcode) >+# >+# stops executing a exclusive region and >+# wakes up anybody who is waiting for the exclusive region >+# >+end_service() >+{ >+ local service="$1" >+ local exitstatus="$2" >+ local tempname >+ >+ # if we are doing critical services, there is no fifo >+ >+ [ "$START_CRITICAL" == "yes" ] && return >+ >+ if [ -n "${exitstatus}" ] ; then >+ echo "${exitstatus}" > "${svcdir}/exitcodes/${service}" >+ fi >+ >+ # move the fifo to a unique name so noone is waiting for it after we touch it >+ tempname="$(mktemp "${svcdir}/exclusive/${service}.XXXXXXXXXX")" >+ mv -f "${svcdir}/exclusive/${service}" "${tempname}" >+ >+ # wake up anybody that was waiting for the fifo >+ touch "${tempname}" >+ >+ # We dont need the fifo anymore >+ rm -f "${tempname}" >+} >+ >+# int wait_exclusive(service) >+ >+wait_service() >+{ >+ local service="$1" >+ local exitstatus >+ >+ [ "$START_CRITICAL" == "yes" ] && return 0 >+ >+ # this will block until the fifo is touched. It is touched by calling end_exclusive >+ # if no begin_eclusive has being called or end_exclusive has already finished >+ # this will not block >+ cat "${svcdir}/exclusive/${service}" 2> /dev/null >+ exitstatus="$( cat "${svcdir}/exitcodes/${service}")" >+ return "${exitstatus}" >+} >+ > # int start_service(service) > # > # Start 'service' if it is not already running. > # > start_service() { >+ local service="$1" > local retval=0 >+ >+ [ -z "${service}" ] && return 1 > >- [ -z "$1" ] && return 1 >- >- if ! service_started "$1" >- then >- splash "svc_start" "$1" >+ #critical services can not start in parallel and begin_service fails because >+ #we don't have write permition to ${svcdir} >+ # so if we are doing critical services, disable the parallel feature >+ >+ # if it is not currently running or we are doing critical services >+ if begin_service "${service}" ; then >+ >+ >+ >+ if ! service_started "${service}" >+ then >+ splash "svc_start" "${service}" >+ if is_fake_service "${service}" "${SOFTLEVEL}" >+ then >+ mark_service_started "${service}" >+ splash "svc_started" "${service}" "0" >+ end_service "${service}" "0" >+ else > >- if is_fake_service "$1" "${SOFTLEVEL}" >- then >- mark_service_started "$1" >- splash "svc_started" "$1" "0" >+ if [ "${RC_PARALLEL_STARTUP}" != "yes" -o "$START_CRITICAL" == "yes" ] >+ then >+ >+ # if we can not start the services in parallel, then just start it and return the exit status >+ (. /sbin/runscript.sh "/etc/init.d/${service}" start) >+ retval="$?" >+ splash "svc_started" "${service}" "${retval}" >+ end_service "${service}" "${retval}" >+ return "${retval}" >+ else >+ # if parallel startup is allowed, start it in background >+ ( >+ >+ (. /sbin/runscript.sh "/etc/init.d/${service}" start) >+ retval="$?" >+ splash "svc_started" "${service}" "${retval}" >+ end_service "${service}" "${retval}" >+ ) & >+ >+ fi >+ fi > else >- (. /sbin/runscript.sh "/etc/init.d/$1" start) >- retval="$?" >- splash "svc_started" "$1" "${retval}" >- return "${retval}" >+ end_service "${service}" > fi > fi > >+ > return 0 > } > >@@ -471,6 +568,8 @@ > mark_service_started() { > [ -z "$1" ] && return 1 > >+ echo "0" > "${svcdir}/exitcodes/$1" >+ > ln -snf "/etc/init.d/$1" "${svcdir}/started/$1" > > return $? >@@ -594,60 +693,14 @@ > # Schedule 'service' for startup, in parallel if possible. > # > schedule_service_startup() { >- local count=0 >- local current_job= >- >- if [ "${RC_PARALLEL_STARTUP}" = "yes" ] >+ local service="$1" >+ >+ if ! iparallel "${service}" > then >- set -m +b >- >- if [ "$(jobs | grep -c "Running")" -gt 0 ] >- then >- if [ "$(jobs | grep -c "Running")" -eq 1 ] >- then >- if [ -n "$(jobs)" ] >- then >- current_job="$(jobs | awk '/Running/ { print $4}')" >- fi >- >- # Wait if we cannot start this service with the already running >- # one (running one might start this one ...). >- query_before "$1" "${current_job}" && wait >- >- elif [ "$(jobs | grep -c "Running")" -ge 2 ] >- then >- count="$(jobs | grep -c "Running")" >- >- # Wait until we have only one service running >- while [ "${count}" -gt 1 ] >- do >- count="$(jobs | grep -c "Running")" >- done >- >- if [ -n "$(jobs)" ] >- then >- current_job="$(jobs | awk '/Running/ { print $4}')" >- fi >- >- # Wait if we cannot start this service with the already running >- # one (running one might start this one ...). >- query_before "$1" "${current_job}" && wait >- fi >- fi >- >- if iparallel "$1" >- then >- eval start_service "$1" \& >- else >- # Do not start with any service running if we cannot start >- # this service in parallel ... >-# wait >- >- start_service "$1" >- fi >- else >- start_service "$1" >+ wait > fi >+ >+ start_service "${service}" > > # We do not need to check the return value here, as svc_{start,stop}() do > # their own error handling ...
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 69854
:
43606
|
43665
|
44157
|
45004
| 51435