summaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorKrishnan Parthasarathi <kparthas@redhat.com>2014-05-05 15:51:18 +0530
committerRaghavendra G <rgowdapp@redhat.com>2014-05-06 21:23:31 -0700
commit05d084b93f76475c86c9c445f92c43bbd2b52569 (patch)
tree14bb1da951cdda0270253cfd78999a10d5683c20 /rpc
parentfb173e9a10d62d49cc8b57c6b3c5bbdf1b326c18 (diff)
rpc: don't stop sending ping packets to an active server.
- Removed an unnecessary ref on rpc_clnt object. - Removed saved_frames_delete function, which was unused. Change-Id: Ie8a9c4bb20c1fd59744b64b56eb043eca095e5e3 BUG: 1094655 Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com> Reviewed-on: http://review.gluster.org/7678 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Raghavendra G <rgowdapp@redhat.com> Tested-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'rpc')
-rw-r--r--rpc/rpc-lib/src/rpc-clnt-ping.c51
-rw-r--r--rpc/rpc-lib/src/rpc-clnt.c24
2 files changed, 35 insertions, 40 deletions
diff --git a/rpc/rpc-lib/src/rpc-clnt-ping.c b/rpc/rpc-lib/src/rpc-clnt-ping.c
index b3bd5e11deb..845ce235a2b 100644
--- a/rpc/rpc-lib/src/rpc-clnt-ping.c
+++ b/rpc/rpc-lib/src/rpc-clnt-ping.c
@@ -64,8 +64,8 @@ rpc_clnt_ping_timer_expired (void *rpc_ptr)
conn->ping_timer = NULL;
rpc_clnt_unref (rpc);
}
- gettimeofday (&current, NULL);
+ gettimeofday (&current, NULL);
if (((current.tv_sec - conn->last_received.tv_sec) <
conn->ping_timeout)
|| ((current.tv_sec - conn->last_sent.tv_sec) <
@@ -119,6 +119,7 @@ rpc_clnt_ping_cbk (struct rpc_req *req, struct iovec *iov, int count,
xlator_t *this = NULL;
rpc_clnt_connection_t *conn = NULL;
call_frame_t *frame = NULL;
+ struct timespec timeout = {0, };
if (!myframe) {
gf_log (THIS->name, GF_LOG_WARNING,
@@ -132,9 +133,9 @@ rpc_clnt_ping_cbk (struct rpc_req *req, struct iovec *iov, int count,
frame->local = NULL; /* Prevent STACK_DESTROY from segfaulting */
conn = &rpc->conn;
- if (req->rpc_status == -1) {
- pthread_mutex_lock (&conn->lock);
- {
+ pthread_mutex_lock (&conn->lock);
+ {
+ if (req->rpc_status == -1) {
if (conn->ping_timer != NULL) {
gf_log (this->name, GF_LOG_WARNING,
"socket or ib related error");
@@ -142,20 +143,43 @@ rpc_clnt_ping_cbk (struct rpc_req *req, struct iovec *iov, int count,
conn->ping_timer);
conn->ping_timer = NULL;
rpc_clnt_unref (rpc);
+
} else {
/* timer expired and transport bailed out */
gf_log (this->name, GF_LOG_WARNING,
"timer must have expired");
+
}
conn->ping_started = 0;
+ goto unlock;
}
- pthread_mutex_unlock (&conn->lock);
+
+ /*This allows other RPCs to be able to start the ping timer
+ * if they come by before the following start ping routine
+ * is executed by the timer thread.*/
+ conn->ping_started = 0;
+ gf_timer_call_cancel (this->ctx,
+ conn->ping_timer);
+
+ timeout.tv_sec = conn->ping_timeout;
+ timeout.tv_nsec = 0;
+ rpc_clnt_ref (rpc);
+ conn->ping_timer = gf_timer_call_after (this->ctx, timeout,
+ rpc_clnt_start_ping,
+ (void *)rpc);
+
+ if (conn->ping_timer == NULL) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "failed to set the ping timer");
+ rpc_clnt_unref (rpc);
+ }
+
}
+unlock:
+ pthread_mutex_unlock (&conn->lock);
out:
if (frame)
STACK_DESTROY (frame->root);
- if (rpc)
- rpc_clnt_unref (rpc);
return 0;
}
@@ -169,7 +193,7 @@ rpc_clnt_ping (struct rpc_clnt *rpc)
if (!frame)
goto fail;
- frame->local = rpc_clnt_ref (rpc);
+ frame->local = rpc;
ret = rpc_clnt_submit (rpc, &clnt_ping_prog,
GF_DUMP_PING, rpc_clnt_ping_cbk, NULL, 0,
@@ -219,10 +243,12 @@ rpc_clnt_start_ping (void *rpc_ptr)
rpc_clnt_unref (rpc);
}
- if (conn->saved_frames)
+ if (conn->saved_frames) {
+ GF_ASSERT (conn->saved_frames->count >= 0);
/* treat the case where conn->saved_frames is NULL
as no pending frames */
frame_count = conn->saved_frames->count;
+ }
if ((frame_count == 0) || !conn->connected) {
gf_log (THIS->name, GF_LOG_DEBUG,
@@ -234,13 +260,6 @@ rpc_clnt_start_ping (void *rpc_ptr)
return;
}
- if (frame_count < 0) {
- gf_log (THIS->name, GF_LOG_WARNING,
- "saved_frames->count is %"PRId64,
- conn->saved_frames->count);
- conn->saved_frames->count = 0;
- }
-
timeout.tv_sec = conn->ping_timeout;
timeout.tv_nsec = 0;
diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c
index 46ee0eebcd0..475afb49739 100644
--- a/rpc/rpc-lib/src/rpc-clnt.c
+++ b/rpc/rpc-lib/src/rpc-clnt.c
@@ -110,30 +110,6 @@ out:
}
-void
-saved_frames_delete (struct saved_frame *saved_frame,
- rpc_clnt_connection_t *conn)
-{
- GF_VALIDATE_OR_GOTO ("rpc-clnt", saved_frame, out);
- GF_VALIDATE_OR_GOTO ("rpc-clnt", conn, out);
-
- pthread_mutex_lock (&conn->lock);
- {
- list_del_init (&saved_frame->list);
- conn->saved_frames->count--;
- }
- pthread_mutex_unlock (&conn->lock);
-
- if (saved_frame->rpcreq != NULL) {
- rpc_clnt_reply_deinit (saved_frame->rpcreq,
- conn->rpc_clnt->reqpool);
- }
-
- mem_put (saved_frame);
-out:
- return;
-}
-
static void
call_bail (void *data)