Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 76673 Details for
Bug 118418
[baselayout] Locking functionality - implementation attached
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Removes race conditions from runscript.sh
lock.patch (text/plain), 5.97 KB, created by
Roy Marples (RETIRED)
on 2006-01-09 15:12:27 UTC
(
hide
)
Description:
Removes race conditions from runscript.sh
Filename:
MIME Type:
Creator:
Roy Marples (RETIRED)
Created:
2006-01-09 15:12:27 UTC
Size:
5.97 KB
patch
obsolete
>Index: runscript.sh >=================================================================== >--- runscript.sh (revision 1796) >+++ runscript.sh (working copy) >@@ -91,24 +91,24 @@ > local ordservice= > local was_inactive=false > >- if service_stopping "${myservice}" ; then >- eerror "ERROR: \"${myservice}\" is already stopping." >- return 0 >- elif service_stopped "${myservice}" ; then >- eerror "ERROR: \"${myservice}\" has not yet been started." >- return 0 >- fi >- > # Do not try to stop if it had already failed to do so on runlevel change > if is_runlevel_stop && service_failed "${myservice}" ; then > return 1 > fi >+ >+ if service_stopped "${myservice}" ; then >+ ewarn "WARNING: \"${myservice}\" has not yet been started." >+ return 0 >+ fi > > service_inactive "${myservice}" && was_inactive=true >- >- # Remove symlink to prevent recursion >- mark_service_stopping "${myservice}" >- >+ if ! mark_service_stopping "${myservice}" ; then >+ ewarn "WARNING: \"${myservice}\" is already stopping." >+ return 0 >+ fi >+ # Lock service starting too ... >+ mark_service_starting "${myservice}" >+ > service_message "Stopping service ${myservice}" > > if in_runlevel "${myservice}" "${BOOTLEVEL}" && \ >@@ -212,6 +212,7 @@ > else > # Stop einfo/ebegin/eend from working as parallel messes us up > [[ ${RC_PARALLEL_STARTUP} == "yes" ]] && RC_QUIET_STDOUT="yes" >+ > # Now that deps are stopped, stop our service > ( stop ) > retval=$? >@@ -224,9 +225,7 @@ > if [[ ${retval} -ne 0 ]] ; then > # Did we fail to stop? create symlink to stop multible attempts at > # runlevel change. Note this is only used at runlevel change ... >- if is_runlevel_stop ; then >- mark_service_failed "${myservice}" >- fi >+ is_runlevel_stop && mark_service_failed "${myservice}" > > # If we are halting the system, do it as cleanly as possible > if [[ ${SOFTLEVEL} != "reboot" && ${SOFTLEVEL} != "shutdown" ]] ; then >@@ -259,29 +258,31 @@ > local y= > local myserv= > local ordservice= >+ local was_inactive=false > >- if service_starting "${myservice}" ; then >- ewarn "WARNING: \"${myservice}\" is already starting." >+ # Do not try to start if i have done so already on runlevel change >+ if is_runlevel_start && service_failed "${myservice}" ; then >+ return 1 >+ fi >+ >+ if service_started "${myservice}" ; then >+ ewarn "WARNING: \"${myservice}\" has already been started." > return 0 > elif service_stopping "${myservice}" ; then >- ewarn "WARNING: please wait for \"${myservice}\" to stop first." >- return 0 >+ eerror "ERROR: please wait for \"${myservice}\" to stop first." >+ return 1 > elif service_inactive "${myservice}" ; then > if [[ ${IN_BACKGROUND} != "true" ]] ; then > ewarn "WARNING: \"${myservice}\" has already been started." > return 0 > fi >- elif service_started "${myservice}" ; then >- ewarn "WARNING: \"${myservice}\" has already been started." >- return 0 > fi > >- # Do not try to start if i have done so already on runlevel change >- if is_runlevel_start && service_failed "${myservice}" ; then >- return 1 >+ service_inactive "${myservice}" && was_inactive=true >+ if ! mark_service_starting "${myservice}" ; then >+ ewarn "WARNING: \"${myservice}\" is already starting." >+ return 0 > fi >- >- mark_service_starting "${myservice}" > service_message "Starting service ${myservice}" > > # On rc change, start all services "before $myservice" first >@@ -383,7 +384,11 @@ > # If we're booting, we need to continue and do our best to get the > # system up. > if [[ ${SOFTLEVEL} != "${BOOTLEVEL}" ]]; then >- mark_service_stopped "${myservice}" >+ if ${was_inactive} ; then >+ mark_service_inactive "${myservice}" >+ else >+ mark_service_stopped "${myservice}" >+ fi > fi > > service_message "eerror" "FAILED to start service ${myservice}!" >Index: rc-services.sh >=================================================================== >--- rc-services.sh (revision 1795) >+++ rc-services.sh (working copy) >@@ -449,14 +449,11 @@ > mark_service_starting() { > [[ -z $1 ]] && return 1 > >- ln -snf "/etc/init.d/$1" "${svcdir}/starting/$1" >- local retval=$? >- >- [[ -f "${svcdir}/started/$1" ]] && rm -f "${svcdir}/started/$1" >+ ln -sn "/etc/init.d/$1" "${svcdir}/starting/$1" 2>/dev/null || return 1 >+ >+ # We need to clear the inactive flag > [[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1" >- [[ -f "${svcdir}/stopping/$1" ]] && rm -f "${svcdir}/stopping/$1" >- >- return "${retval}" >+ return 0 > } > > # bool mark_service_started(service) >@@ -467,13 +464,12 @@ > [[ -z $1 ]] && return 1 > > ln -snf "/etc/init.d/$1" "${svcdir}/started/$1" >- local retval=$? > > [[ -f "${svcdir}/starting/$1" ]] && rm -f "${svcdir}/starting/$1" > [[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1" > [[ -f "${svcdir}/stopping/$1" ]] && rm -f "${svcdir}/stopping/$1" > >- return "${retval}" >+ return 0 > } > > # bool mark_service_inactive(service) >@@ -484,12 +480,12 @@ > [[ -z $1 ]] && return 1 > > ln -snf "/etc/init.d/$1" "${svcdir}/inactive/$1" >- local retval=$? >+ > [[ -f "${svcdir}/started/$1" ]] && rm -f "${svcdir}/started/$1" > [[ -f "${svcdir}/starting/$1" ]] && rm -f "${svcdir}/starting/$1" > [[ -f "${svcdir}/stopping/$1" ]] && rm -f "${svcdir}/stopping/$1" > >- return "${retval}" >+ return 0 > } > > # bool mark_service_stopping(service) >@@ -499,14 +495,11 @@ > mark_service_stopping() { > [[ -z $1 ]] && return 1 > >- ln -snf "/etc/init.d/$1" "${svcdir}/stopping/$1" >- local retval=$? >- >- [[ -f "${svcdir}/starting/$1" ]] && rm -f "${svcdir}/starting/$1" >- [[ -f "${svcdir}/started/$1" ]] && rm -f "${svcdir}/started/$1" >- [[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1" >+ ln -sn "/etc/init.d/$1" "${svcdir}/stopping/$1" 2>/dev/null || return 1 > >- return "${retval}" >+ # We need to clear the inactive flag >+ [[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1" >+ return 0 > } > > # bool mark_service_stopped(service) >@@ -522,7 +515,7 @@ > [[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1" > [[ -f "${svcdir}/stopping/$1" ]] && rm -f "${svcdir}/stopping/$1" > >- return $? >+ return 0 > } > > # bool test_service_state(char *service, char *state)
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 118418
:
76646
| 76673 |
76813
|
76815