Blame SOURCES/bz1128933-Fix-ha_log-drop-global-__ha_log_ignore_stderr_once-h.patch

c608c9
From 2364eff6a6837ae4418f1876f7f29459fdeec3bb Mon Sep 17 00:00:00 2001
c608c9
From: Lars Ellenberg <lars.ellenberg@linbit.com>
c608c9
Date: Mon, 22 Sep 2014 15:26:59 +0200
c608c9
Subject: [PATCH 4/6] Fix: ha_log: drop global __ha_log_ignore_stderr_once hack
c608c9
c608c9
Use a helper function instead,
c608c9
which understands --ignore-stderr as first parameter.
c608c9
---
c608c9
 heartbeat/ocf-shellfuncs.in | 23 +++++++++--------------
c608c9
 1 file changed, 9 insertions(+), 14 deletions(-)
c608c9
c608c9
diff --git a/heartbeat/ocf-shellfuncs.in b/heartbeat/ocf-shellfuncs.in
c608c9
index c370fca..fd916e7 100644
c608c9
--- a/heartbeat/ocf-shellfuncs.in
c608c9
+++ b/heartbeat/ocf-shellfuncs.in
c608c9
@@ -43,14 +43,6 @@ unset LANGUAGE; export LANGUAGE
c608c9
 
c608c9
 __SCRIPT_NAME=`basename $0`
c608c9
 
c608c9
-# This is internal to shellfuncs.
c608c9
-# When set, ha_log can be used in a way that guarantees
c608c9
-# that stderr will not be printed to. This allows us to
c608c9
-# use ocf_exit_reason to print a string to stderr and use
c608c9
-# ha_log to print the same string to the other log facilities
c608c9
-# without having duplicate messages sent to stderr.
c608c9
-__ha_log_ignore_stderr_once=""
c608c9
-
c608c9
 if [ -z "$OCF_ROOT" ]; then
c608c9
     : ${OCF_ROOT=@OCF_ROOT_DIR@}
c608c9
 fi
c608c9
@@ -189,12 +181,11 @@ set_logtag() {
c608c9
 	fi
c608c9
 }
c608c9
 
c608c9
-ha_log() {
c608c9
-	local ignore_stderr="$__ha_log_ignore_stderr_once"
c608c9
+__ha_log() {
c608c9
+	local ignore_stderr=false
c608c9
 	local loglevel
c608c9
 
c608c9
-	# always reset this variable
c608c9
-	__ha_log_ignore_stderr_once=""
c608c9
+	[ "x$1" = "x--ignore-stderr" ] && ignore_stderr=true && shift
c608c9
 
c608c9
 	[ none = "$HA_LOGFACILITY" ] && HA_LOGFACILITY=""
c608c9
 	# if we're connected to a tty, then output to stderr
c608c9
@@ -257,6 +248,11 @@ ha_log() {
c608c9
         fi
c608c9
 }
c608c9
 
c608c9
+ha_log()
c608c9
+{
c608c9
+	__ha_log "$@"
c608c9
+}
c608c9
+
c608c9
 ha_debug() {
c608c9
 
c608c9
         if [ "x${HA_debug}" = "x0" ] ; then
c608c9
@@ -383,8 +379,7 @@ ocf_exit_reason()
c608c9
 
c608c9
 	msg=$(printf "${fmt}" "$@")
c608c9
 	printf >&2 "%s%s\n" "$cookie" "$msg"
c608c9
-	__ha_log_ignore_stderr_once="true"
c608c9
-	ha_log "ERROR: $msg"
c608c9
+	__ha_log --ignore-stderr "ERROR: $msg"
c608c9
 }
c608c9
 
c608c9
 #
c608c9
-- 
c608c9
1.8.4.2
c608c9