From 73eca3be5c5ccc71bbad934338c1ef58ed37c483 Mon Sep 17 00:00:00 2001 From: Rajesh Date: Tue, 19 Jul 2011 15:57:30 +0530 Subject: 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 Reviewed-by: Anand Avati --- rpc/rpc-transport/socket/src/socket.c | 35 +++++++++++++++++++++++++++-------- rpc/rpc-transport/socket/src/socket.h | 1 + 2 files changed, 28 insertions(+), 8 deletions(-) (limited to 'rpc/rpc-transport') diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c index 674259e5f..9937dc4a6 100644 --- a/rpc/rpc-transport/socket/src/socket.c +++ b/rpc/rpc-transport/socket/src/socket.c @@ -43,7 +43,6 @@ #include #include #include - #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 4acecab2a..c52026cc8 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; -- cgit