tags 738759 + patch thanks Hi!
Please find attach a proposed patch for the issue. I hope we can get around at work to test it properly within the next few days, but from what I can tell this should be a good approach. Enjoy, Rhonda -- Fühlst du dich mutlos, fass endlich Mut, los | Fühlst du dich hilflos, geh raus und hilf, los | Wir sind Helden Fühlst du dich machtlos, geh raus und mach, los | 23.55: Alles auf Anfang Fühlst du dich haltlos, such Halt und lass los |
>From e211b7ba4fdce03d66b9edc097349c4d17d94063 Mon Sep 17 00:00:00 2001 From: Gerfried Fuchs <rho...@debian.org> Date: Fri, 14 Feb 2014 08:03:25 +0100 Subject: [PATCH] only scan the rcX.d once for reading all kill or all start links (closes: #738759) --- debian/changelog | 5 ++ debian/src/sysv-rc/etc/init.d/rc | 138 ++++++++++++++++++++++----------------- 2 files changed, 84 insertions(+), 59 deletions(-) diff --git a/debian/changelog b/debian/changelog index ac3f0a0..0bff2a4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,13 @@ sysvinit (2.88dsf-52) UNRELEASED; urgency=low + [ Petter Reinholdtsen ] * Replace debian/watch with file available from http://qa.debian.org/cgi-bin/watchfile.cgi?package=sysvinit . + [ Gerfried Fuchs ] + * only scan the rcX.d once for reading all kill or all start links + (closes: #738759) + -- Petter Reinholdtsen <p...@debian.org> Thu, 13 Feb 2014 13:23:35 +0100 sysvinit (2.88dsf-51) unstable; urgency=low diff --git a/debian/src/sysv-rc/etc/init.d/rc b/debian/src/sysv-rc/etc/init.d/rc index 4e95302..7767778 100644 --- a/debian/src/sysv-rc/etc/init.d/rc +++ b/debian/src/sysv-rc/etc/init.d/rc @@ -124,6 +124,65 @@ case "$CONCURRENCY" in ;; esac +# helper scripts +kill_test_add() { + script=$1 + # Check if the script is there. + [ ! -f $script ] && return "" + + # + # Find stop script in previous runlevel but + # no start script there. + # + suffix=${script#/etc/rc$runlevel.d/K[0-9][0-9]} + previous_stop=/etc/rc$previous.d/K[0-9][0-9]$suffix + previous_start=/etc/rc$previous.d/S[0-9][0-9]$suffix + # + # If there is a stop script in the previous level + # and _no_ start script there, we don't + # have to re-stop the service. + # + [ -f $previous_stop ] && [ ! -f $previous_start ] && return "" + + # Stop the service. + return $script +} +start_test_add() { + script=$1 + [ ! -f $script ] && return "" + + suffix=${script#/etc/rc$runlevel.d/S[0-9][0-9]} + if [ "$previous" != N ] + then + # + # Find start script in previous runlevel and + # stop script in this runlevel. + # + stop=/etc/rc$runlevel.d/K[0-9][0-9]$suffix + previous_start=/etc/rc$previous.d/S[0-9][0-9]$suffix + # + # If there is a start script in the previous level + # and _no_ stop script in this level, we don't + # have to re-start the service. + # + if [ start = "$ACTION" ] ; then + [ -f $previous_start ] && [ ! -f $stop ] && return "" + else + # Workaround for the special + # handling of runlevels 0 and 6. + previous_stop=/etc/rc$previous.d/K[0-9][0-9]$suffix + # + # If there is a stop script in the previous level + # and _no_ start script there, we don't + # have to re-stop the service. + # + [ -f $previous_stop ] && [ ! -f $previous_start ] && return "" + fi + + fi + return $script +} + # Is there an rc directory for this new runlevel? if [ -d /etc/rc$runlevel.d ] then @@ -150,41 +209,28 @@ then then # Run all scripts with the same level in parallel CURLEVEL="" + SCRIPTS="" for s in /etc/rc$runlevel.d/K* do # Extract order value from symlink level=${s#/etc/rc$runlevel.d/K} level=${level%%[a-zA-Z]*} + if [ -z "$CURLEVEL" ] + then + CURLEVEL=$level + fi if [ "$level" = "$CURLEVEL" ] then + SCRIPTS="$SCRIPTS $(kill_test_add $s)" continue fi - CURLEVEL=$level - SCRIPTS="" - for i in /etc/rc$runlevel.d/K$level* - do - # Check if the script is there. - [ ! -f $i ] && continue - - # - # Find stop script in previous runlevel but - # no start script there. - # - suffix=${i#/etc/rc$runlevel.d/K[0-9][0-9]} - previous_stop=/etc/rc$previous.d/K[0-9][0-9]$suffix - previous_start=/etc/rc$previous.d/S[0-9][0-9]$suffix - # - # If there is a stop script in the previous level - # and _no_ start script there, we don't - # have to re-stop the service. - # - [ -f $previous_stop ] && [ ! -f $previous_start ] && continue + SCRIPTS="$SCRIPTS $(kill_test_add $s)" - # Stop the service. - SCRIPTS="$SCRIPTS $i" - done startup stop $SCRIPTS + CURLEVEL=$level + SCRIPTS="" done + startup stop $SCRIPTS fi if [ makefile = "$CONCURRENCY" ] @@ -199,54 +245,28 @@ then # Now run the START scripts for this runlevel. # Run all scripts with the same level in parallel CURLEVEL="" + SCRIPTS="" for s in /etc/rc$runlevel.d/S* do # Extract order value from symlink level=${s#/etc/rc$runlevel.d/S} level=${level%%[a-zA-Z]*} + if [ -z "$CURLEVEL" ] + then + CURLEVEL=$level + fi if [ "$level" = "$CURLEVEL" ] then + SCRIPTS="$SCRIPTS $(start_test_add $s)" continue fi - CURLEVEL=$level - SCRIPTS="" - for i in /etc/rc$runlevel.d/S$level* - do - [ ! -f $i ] && continue - - suffix=${i#/etc/rc$runlevel.d/S[0-9][0-9]} - if [ "$previous" != N ] - then - # - # Find start script in previous runlevel and - # stop script in this runlevel. - # - stop=/etc/rc$runlevel.d/K[0-9][0-9]$suffix - previous_start=/etc/rc$previous.d/S[0-9][0-9]$suffix - # - # If there is a start script in the previous level - # and _no_ stop script in this level, we don't - # have to re-start the service. - # - if [ start = "$ACTION" ] ; then - [ -f $previous_start ] && [ ! -f $stop ] && continue - else - # Workaround for the special - # handling of runlevels 0 and 6. - previous_stop=/etc/rc$previous.d/K[0-9][0-9]$suffix - # - # If there is a stop script in the previous level - # and _no_ start script there, we don't - # have to re-stop the service. - # - [ -f $previous_stop ] && [ ! -f $previous_start ] && continue - fi + SCRIPTS="$SCRIPTS $(start_test_add $s)" - fi - SCRIPTS="$SCRIPTS $i" - done startup $ACTION $SCRIPTS + CURLEVEL=$level + SCRIPTS="" done + startup $ACTION $SCRIPTS fi fi -- 1.8.5.3
_______________________________________________ Pkg-sysvinit-devel mailing list Pkg-sysvinit-devel@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-sysvinit-devel