Blame SOURCES/bz1689184-Squid-1-fix-pidfile-issue.patch

4d1913
From d228d41c61f57f2576dd87aa7be86f9ca26e3059 Mon Sep 17 00:00:00 2001
4d1913
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
4d1913
Date: Mon, 18 Mar 2019 16:03:14 +0100
4d1913
Subject: [PATCH] Squid: fix pid file issue due to new Squid version saving the
4d1913
 PID of the parent process instead of the listener child process
4d1913
4d1913
---
4d1913
 heartbeat/Squid.in | 21 +++++----------------
4d1913
 1 file changed, 5 insertions(+), 16 deletions(-)
4d1913
4d1913
diff --git a/heartbeat/Squid.in b/heartbeat/Squid.in
4d1913
index a99892d75..0b3c8ea86 100644
4d1913
--- a/heartbeat/Squid.in
4d1913
+++ b/heartbeat/Squid.in
4d1913
@@ -96,12 +96,9 @@ for a squid instance managed by this RA.
4d1913
 <content type="string" default=""/>
4d1913
 </parameter>
4d1913
 
4d1913
-<parameter name="squid_pidfile" required="1" unique="1">
4d1913
-<longdesc lang="en">
4d1913
-This is a required parameter. This parameter specifies a process id file
4d1913
-for a squid instance managed by this RA.
4d1913
-</longdesc>
4d1913
-<shortdesc lang="en">Pidfile</shortdesc>
4d1913
+<parameter name="squid_pidfile" required="0" unique="1">
4d1913
+<longdesc lang="en">Deprecated - do not use anymore</longdesc>
4d1913
+<shortdesc lang="en">deprecated - do not use anymore</shortdesc>
4d1913
 <content type="string" default=""/>
4d1913
 </parameter>
4d1913
 
4d1913
@@ -175,8 +172,8 @@ get_pids()
4d1913
 	# Seek by pattern
4d1913
 	SQUID_PIDS[0]=$(pgrep -f "$PROCESS_PATTERN")
4d1913
 
4d1913
-	# Seek by pidfile
4d1913
-	SQUID_PIDS[1]=$(awk '1{print $1}' $SQUID_PIDFILE 2>/dev/null)
4d1913
+	# Seek by child process
4d1913
+	SQUID_PIDS[1]=$(pgrep -P ${SQUID_PIDS[0]})
4d1913
 
4d1913
 	if [[ -n "${SQUID_PIDS[1]}" ]]; then
4d1913
 		typeset exe
4d1913
@@ -306,7 +303,6 @@ stop_squid()
4d1913
 		while true; do
4d1913
 			get_pids
4d1913
 			if is_squid_dead; then
4d1913
-				rm -f $SQUID_PIDFILE
4d1913
 				return $OCF_SUCCESS
4d1913
 			fi
4d1913
 			(( lapse_sec = lapse_sec + 1 ))
4d1913
@@ -326,7 +322,6 @@ stop_squid()
4d1913
 		kill -KILL ${SQUID_PIDS[0]} ${SQUID_PIDS[2]}
4d1913
 		sleep 1
4d1913
 		if is_squid_dead; then
4d1913
-			rm -f $SQUID_PIDFILE
4d1913
 			return $OCF_SUCCESS
4d1913
 		fi
4d1913
 	done
4d1913
@@ -389,12 +384,6 @@ if [[ ! -x "$SQUID_EXE" ]]; then
4d1913
 	exit $OCF_ERR_CONFIGURED
4d1913
 fi
4d1913
 
4d1913
-SQUID_PIDFILE="${OCF_RESKEY_squid_pidfile}"
4d1913
-if [[ -z "$SQUID_PIDFILE" ]]; then
4d1913
-	ocf_exit_reason "SQUID_PIDFILE is not defined"
4d1913
-	exit $OCF_ERR_CONFIGURED
4d1913
-fi
4d1913
-
4d1913
 SQUID_PORT="${OCF_RESKEY_squid_port}"
4d1913
 if [[ -z "$SQUID_PORT" ]]; then
4d1913
 	ocf_exit_reason "SQUID_PORT is not defined"