Patchwork [BUG:10] Adding GF_LOG_OCCASIONALLY to prevent repeated log messages

login
register
Submitter Anush Shetty
Date 2010-05-07 09:55:28
Message ID <20100507095528.GA422@dev.gluster.com>
Download mbox | patch
Permalink /patch/3242/
State Accepted
Headers show

Comments

Anush Shetty - 2010-05-07 09:55:28
Signed-off-by: Anush Shetty <anush@gluster.com>
---
 xlators/mount/fuse/src/fuse-bridge.c         |   14 +++++++++-----
 xlators/protocol/transport/socket/src/name.c |   17 ++++++++++-------
 2 files changed, 19 insertions(+), 12 deletions(-)

Patch

diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c
index faf7c48..9f210aa 100644
--- a/xlators/mount/fuse/src/fuse-bridge.c
+++ b/xlators/mount/fuse/src/fuse-bridge.c
@@ -68,6 +68,8 @@ 
 
 #define MAX_FUSE_PROC_DELAY 1
 
+static int gf_fuse_conn_err_log;
+
 typedef struct fuse_in_header fuse_in_header_t;
 typedef void (fuse_handler_t) (xlator_t *this, fuse_in_header_t *finh,
                                void *msg);
@@ -719,11 +721,13 @@  fuse_attr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
                 send_fuse_data (this, finh, &fao,
                                 FUSE_COMPAT_ATTR_OUT_SIZE);
         } else {
-                gf_log ("glusterfs-fuse", GF_LOG_WARNING,
-                        "%"PRIu64": %s() %s => -1 (%s)", frame->root->unique,
-                        gf_fop_list[frame->root->op],
-                        state->loc.path ? state->loc.path : "ERR",
-                        strerror (op_errno));
+                GF_LOG_OCCASIONALLY ( gf_fuse_conn_err_log, "glusterfs-fuse", 
+                                      GF_LOG_WARNING, 
+                                      "%"PRIu64": %s() %s => -1 (%s)", 
+                                      frame->root->unique,
+                                      gf_fop_list[frame->root->op],
+                                      state->loc.path ? state->loc.path : "ERR",
+                                      strerror (op_errno));
 
                 send_fuse_err (this, finh, op_errno);
         }
diff --git a/xlators/protocol/transport/socket/src/name.c b/xlators/protocol/transport/socket/src/name.c
index 120a669..74abe44 100644
--- a/xlators/protocol/transport/socket/src/name.c
+++ b/xlators/protocol/transport/socket/src/name.c
@@ -34,6 +34,8 @@ 
 #define AF_INET_SDP 27
 #endif
 
+static int gf_name_addr_enotspec_log;
+
 #include "transport.h"
 #include "socket.h"
 
@@ -139,13 +141,14 @@  client_fill_address_family (transport_t *this, sa_family_t *sa_family)
 
                 if (!(remote_host_data || connect_path_data) || 
                     (remote_host_data && connect_path_data)) {
-                        gf_log (this->xl->name, GF_LOG_ERROR,
-                                "transport.address-family not specified and "
-                                "not able to determine the "
-                                "same from other options (remote-host:%s and "
-                                "transport.unix.connect-path:%s)", 
-                                data_to_str (remote_host_data), 
-                                data_to_str (connect_path_data));
+                        GF_LOG_OCCASIONALLY (gf_name_addr_enotspec_log, 
+                                             this->xl->name, GF_LOG_ERROR,
+                                             "transport.address-family not specified and "
+                                             "not able to determine the "
+                                             "same from other options (remote-host:%s and "
+                                             "transport.unix.connect-path:%s)", 
+                                             data_to_str (remote_host_data), 
+                                             data_to_str (connect_path_data));
                         goto out;
                 }