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

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