From da81db2ad57bbd18e28bfdb22b851619ff149c18 Mon Sep 17 00:00:00 2001 From: Milind Changire Date: Thu, 23 Feb 2017 17:58:46 +0530 Subject: [PATCH 348/361] rpc: log more about socket disconnects Log more about the different paths leading to socket disconnect for ease of debugging. Log via gf_log_callingfn() in __socket_disconnect() at loglevel TRACE if socket connection is being torn down. mainline: > BUG: 1426125 > Reviewed-on: https://review.gluster.org/16732 > Smoke: Gluster Build System > NetBSD-regression: NetBSD Build System > CentOS-regression: Gluster Build System > Reviewed-by: Jeff Darcy (cherry picked from commit 3247022699870884f3ff6c64282a529cfcb9e114) BUG: 1426034 Change-Id: I1e551c2d685784b5ec747f481179f64d524c0461 Signed-off-by: Milind Changire Reviewed-on: https://code.engineering.redhat.com/gerrit/101324 Reviewed-by: Atin Mukherjee --- rpc/rpc-transport/socket/src/socket.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c index 088efda..cf2f75e 100644 --- a/rpc/rpc-transport/socket/src/socket.c +++ b/rpc/rpc-transport/socket/src/socket.c @@ -726,6 +726,8 @@ __socket_disconnect (rpc_transport_t *this) priv->ot_state, priv->ot_gen, priv->sock); if (priv->sock != -1) { + gf_log_callingfn (this->name, GF_LOG_TRACE, + "tearing down socket connection"); ret = __socket_teardown_connection (this); if (ret) { gf_log (this->name, GF_LOG_DEBUG, @@ -1203,6 +1205,9 @@ socket_event_poll_out (rpc_transport_t *this) ret = __socket_ioq_churn (this); if (ret == -1) { + gf_log (this->name, GF_LOG_TRACE, + "__socket_ioq_churn returned -1; " + "disconnecting socket"); __socket_disconnect (this); } } @@ -2307,7 +2312,8 @@ socket_connect_finish (rpc_transport_t *this) if (ret == -1 && errno != EINPROGRESS) { if (!priv->connect_finish_log) { gf_log (this->name, GF_LOG_ERROR, - "connection to %s failed (%s)", + "connection to %s failed (%s); " + "disconnecting socket", this->peerinfo.identifier, strerror (errno)); priv->connect_finish_log = 1; @@ -2327,7 +2333,8 @@ socket_connect_finish (rpc_transport_t *this) &this->myinfo.sockaddr_len); if (ret == -1) { gf_log (this->name, GF_LOG_WARNING, - "getsockname on (%d) failed (%s)", + "getsockname on (%d) failed (%s) - " + "disconnecting socket", priv->sock, strerror (errno)); __socket_disconnect (this); event = RPC_TRANSPORT_DISCONNECT; @@ -2380,6 +2387,10 @@ socket_event_handler (int fd, int idx, void *data, EINPROGRESS or ENOENT, so nothing more to do, fail reading/writing anything even if poll_in or poll_out is set */ + gf_log ("transport", GF_LOG_DEBUG, + "connect failed with some other error than " + "EINPROGRESS or ENOENT, so nothing more to " + "do; disconnecting socket"); ret = socket_disconnect (this, _gf_false); /* Force ret to be -1, as we are officially done with @@ -2403,7 +2414,7 @@ socket_event_handler (int fd, int idx, void *data, if ((ret < 0) || poll_err) { /* Logging has happened already in earlier cases */ gf_log ("transport", ((ret >= 0) ? GF_LOG_INFO : GF_LOG_DEBUG), - "disconnecting now"); + "EPOLLERR - disconnecting now"); socket_event_poll_err (this); rpc_transport_unref (this); } @@ -2578,6 +2589,7 @@ err: /* All (and only) I/O errors should come here. */ pthread_mutex_lock(&priv->lock); { + gf_log (this->name, GF_LOG_TRACE, "disconnecting socket"); __socket_teardown_connection (this); sys_close (priv->sock); priv->sock = -1; -- 1.8.3.1