summaryrefslogtreecommitdiffstats
path: root/rpc/rpc-transport/socket
diff options
context:
space:
mode:
authorRajesh <rajesh@gluster.com>2011-07-19 15:57:30 +0530
committerAnand Avati <avati@gluster.com>2011-07-25 09:25:25 -0700
commit73eca3be5c5ccc71bbad934338c1ef58ed37c483 (patch)
tree39758ab32ba0781b17a64f2f8f10c1b5051c4197 /rpc/rpc-transport/socket
parentd35e17152720a074c15f54f5c3b8a400e456b19e (diff)
rpc-transport/socket: avoid logging socket read fails
An option, transport.socket.read-fail-log was added in glusterd. This can also be added to any translator which uses socket.c. A gf_boolean_t flag(read_fail_log) is added in socket_private_t. Using this, logging of socket read failures can be controlled. The options is set to 'off' in glusterd.vol by default. Change-Id: I85cf4afc1f534f5f51018449d5d84baef18fce23 BUG: 3156 Reviewed-on: http://review.gluster.com/22 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@gluster.com>
Diffstat (limited to 'rpc/rpc-transport/socket')
-rw-r--r--rpc/rpc-transport/socket/src/socket.c35
-rw-r--r--rpc/rpc-transport/socket/src/socket.h1
2 files changed, 28 insertions, 8 deletions
diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c
index 674259e5f18..9937dc4a6e6 100644
--- a/rpc/rpc-transport/socket/src/socket.c
+++ b/rpc/rpc-transport/socket/src/socket.c
@@ -43,7 +43,6 @@
#include <errno.h>
#include <netinet/tcp.h>
#include <rpc/xdr.h>
-
#define GF_LOG_ERRNO(errno) ((errno == ENOTCONN) ? GF_LOG_DEBUG : GF_LOG_ERROR)
#define SA(ptr) ((struct sockaddr *)ptr)
@@ -1486,12 +1485,14 @@ __socket_proto_state_machine (rpc_transport_t *this,
&priv->incoming.pending_count,
NULL);
if (ret == -1) {
- gf_log (this->name,
- ((priv->connected == 1) ?
- GF_LOG_WARNING : GF_LOG_DEBUG),
- "reading from socket failed. Error (%s)"
- ", peer (%s)", strerror (errno),
- this->peerinfo.identifier);
+ if (priv->read_fail_log == 1) {
+ gf_log (this->name,
+ ((priv->connected == 1) ?
+ GF_LOG_WARNING : GF_LOG_DEBUG),
+ "reading from socket failed. Error (%s)"
+ ", peer (%s)", strerror (errno),
+ this->peerinfo.identifier);
+ }
goto out;
}
@@ -2536,7 +2537,6 @@ socket_init (rpc_transport_t *this)
priv->nodelay = 1;
priv->bio = 0;
priv->windowsize = GF_DEFAULT_SOCKET_WINDOW_SIZE;
-
INIT_LIST_HEAD (&priv->ioq);
/* All the below section needs 'this->options' to be present */
@@ -2629,6 +2629,22 @@ socket_init (rpc_transport_t *this)
priv->backlog = backlog;
}
+ optstr = NULL;
+
+ /* Check if socket read failures are to be logged */
+ priv->read_fail_log = 1;
+ if (dict_get (this->options, "transport.socket.read-fail-log")) {
+ optstr = data_to_str (dict_get (this->options, "transport.socket.read-fail-log"));
+ if (gf_string2boolean (optstr, &tmp_bool) == -1) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "'transport.socket.read-fail-log' takes only "
+ "boolean options; logging socket read fails");
+ }
+ else if (tmp_bool == _gf_false) {
+ priv->read_fail_log = 0;
+ }
+ }
+
priv->windowsize = (int)windowsize;
out:
this->private = priv;
@@ -2734,5 +2750,8 @@ struct volume_options options[] = {
{ .key = {"transport.socket.listen-backlog"},
.type = GF_OPTION_TYPE_INT
},
+ { .key = {"transport.socket.read-fail-log"},
+ .type = GF_OPTION_TYPE_BOOL
+ },
{ .key = {NULL} }
};
diff --git a/rpc/rpc-transport/socket/src/socket.h b/rpc/rpc-transport/socket/src/socket.h
index 4acecab2a61..c52026cc829 100644
--- a/rpc/rpc-transport/socket/src/socket.h
+++ b/rpc/rpc-transport/socket/src/socket.h
@@ -193,6 +193,7 @@ typedef struct {
int keepaliveidle;
int keepaliveintvl;
uint32_t backlog;
+ gf_boolean_t read_fail_log;
} socket_private_t;