]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix endless loop when waiting for Rspamd to stop
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 7 Aug 2018 13:15:22 +0000 (14:15 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 7 Aug 2018 13:15:22 +0000 (14:15 +0100)
centos/sources/rspamd.init

index 67bfa15ff7757b5c75904a384aaee8885c986cff..3dd3b99be1f0902e6a10cdc4560acd484148727a 100644 (file)
@@ -11,7 +11,7 @@
 # Description:       Rspamd spam filtering daemon process
 ### END INIT INFO
 #
-# chkconfig:   - 85 15 
+# chkconfig:   - 85 15
 # description:  rspamd is a spam filtering system
 # processname: rspamd
 # config:      /etc/rspamd/rspamd.conf
@@ -58,11 +58,22 @@ stop() {
         if [ "$CONSOLETYPE" != "serial" ]; then
            echo -en "\\033[16G"
         fi
-        while rh_status_q
-        do
+        STOPTIMEOUT=30
+        while [ $STOPTIMEOUT -gt 0 ]; do
+            rh_status_q || break
             sleep 1
-            echo -n $"."
+            let STOPTIMEOUT=${STOPTIMEOUT}-1
         done
+        if [ $STOPTIMEOUT -eq 0 ]; then
+          echo "Timeout error occurred trying to stop Rspamd. Forcefully stop the remaining processes."
+          killproc $prog -KILL
+          # Sleep forever after SIGKILL being sent (e.g. UNINT SLEEP)
+          while rh_status_q
+          do
+            sleep 1
+            echo -n $"."
+          done
+        fi
         rm -f $lockfile
     fi
     echo