e3c68b
From 82d7c8e057b9e22d13ca89f2a75e65a42878b7c3 Mon Sep 17 00:00:00 2001
e3c68b
From: Atin Mukherjee <amukherj@redhat.com>
e3c68b
Date: Tue, 2 Apr 2019 10:45:15 +0530
e3c68b
Subject: [PATCH 092/124] logging: Fix GF_LOG_OCCASSIONALLY API
e3c68b
e3c68b
GF_LOG_OCCASSIONALLY doesn't log on the first instance rather at every
e3c68b
42nd iterations which isn't effective as in some cases we might not have
e3c68b
the code flow hitting the same log for as many as 42 times and we'd end
e3c68b
up suppressing the log.
e3c68b
e3c68b
>upstream fix : https://review.gluster.org/#/c/glusterfs/+/22475/
e3c68b
>Fixes: bz#1694925
e3c68b
>Change-Id: Iee293281d25a652b64df111d59b13de4efce06fa
e3c68b
>Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
e3c68b
e3c68b
BUG: 1691620
e3c68b
Change-Id: Iee293281d25a652b64df111d59b13de4efce06fa
e3c68b
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
e3c68b
Reviewed-on: https://code.engineering.redhat.com/gerrit/167822
e3c68b
Tested-by: RHGS Build Bot <nigelb@redhat.com>
e3c68b
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
e3c68b
---
e3c68b
 libglusterfs/src/glusterfs/logging.h | 2 +-
e3c68b
 1 file changed, 1 insertion(+), 1 deletion(-)
e3c68b
e3c68b
diff --git a/libglusterfs/src/glusterfs/logging.h b/libglusterfs/src/glusterfs/logging.h
e3c68b
index c81e19b..3655b1d 100644
e3c68b
--- a/libglusterfs/src/glusterfs/logging.h
e3c68b
+++ b/libglusterfs/src/glusterfs/logging.h
e3c68b
@@ -300,7 +300,7 @@ _gf_log_eh(const char *function, const char *fmt, ...)
e3c68b
 
e3c68b
 /* Log once in GF_UNIVERSAL_ANSWER times */
e3c68b
 #define GF_LOG_OCCASIONALLY(var, args...)                                      \
e3c68b
-    if (!(var++ % GF_UNIVERSAL_ANSWER)) {                                      \
e3c68b
+    if (var++ == 0 || !((var - 1) % GF_UNIVERSAL_ANSWER)) {                    \
e3c68b
         gf_log(args);                                                          \
e3c68b
     }
e3c68b
 
e3c68b
-- 
e3c68b
1.8.3.1
e3c68b