summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorKrishna Srinivas <krishna@zresearch.com>2009-02-24 06:53:21 -0800
committerAnand V. Avati <avati@amp.gluster.com>2009-02-25 16:48:35 +0530
commit1d556afdf8bf5459a1ea1a27ed5638d440439666 (patch)
tree03567d9ec3bdbbd2ba24b40807a4b90179041f35 /xlators
parent8479df9809107f20df31afb332b8fb6a1931b861 (diff)
Ping timer does not timeout in case there is any activity (cbks) from the server side.
Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/protocol/client/src/client-protocol.c49
-rw-r--r--xlators/protocol/client/src/client-protocol.h1
2 files changed, 42 insertions, 8 deletions
diff --git a/xlators/protocol/client/src/client-protocol.c b/xlators/protocol/client/src/client-protocol.c
index 569295400..8c5a1fa22 100644
--- a/xlators/protocol/client/src/client-protocol.c
+++ b/xlators/protocol/client/src/client-protocol.c
@@ -455,26 +455,56 @@ client_ping_timer_expired (void *data)
transport_t *trans = NULL;
client_conf_t *conf = NULL;
client_connection_t *conn = NULL;
-
+ int disconnect = 0;
+ int transport_activity = 0;
+ struct timeval timeout = {0, };
+ struct timeval current = {0, };
+
trans = data;
this = trans->xl;
conf = this->private;
conn = trans->xl_private;
- gf_log (this->name, GF_LOG_ERROR,
- "ping timer expired! bailing transport");
-
pthread_mutex_lock (&conn->lock);
{
if (conn->ping_timer)
gf_timer_call_cancel (trans->xl->ctx,
conn->ping_timer);
+ gettimeofday (&current, NULL);
+
+ if ((current.tv_sec - conn->last_received.tv_sec) <
+ conn->ping_timeout) {
+ transport_activity = 1;
+ }
+
+ if (transport_activity) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "ping timer expired but transport activity "
+ "detected - not bailing transport");
+ conn->transport_activity = 0;
+ timeout.tv_sec = conn->ping_timeout;
+ timeout.tv_usec = 0;
+
+ conn->ping_timer =
+ gf_timer_call_after (trans->xl->ctx, timeout,
+ client_ping_timer_expired,
+ (void *) trans);
+ if (conn->ping_timer == NULL)
+ gf_log (this->name, GF_LOG_ERROR,
+ "unable to setup timer");
- conn->ping_started = 0;
- conn->ping_timer = NULL;
+ } else {
+ conn->ping_started = 0;
+ conn->ping_timer = NULL;
+ disconnect = 1;
+ }
}
pthread_mutex_unlock (&conn->lock);
- transport_disconnect (trans);
+ if (disconnect) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "ping timer expired! bailing transport");
+ transport_disconnect (trans);
+ }
}
@@ -531,8 +561,9 @@ client_start_ping (void *data)
if (conn->ping_timer == NULL) {
gf_log (this->name, GF_LOG_ERROR,
"unable to setup timer");
- } else
+ } else {
conn->ping_started = 1;
+ }
}
pthread_mutex_unlock (&conn->lock);
@@ -6174,7 +6205,9 @@ protocol_client_interpret (xlator_t *this, transport_t *trans,
uint64_t callid = 0;
int type = -1;
int op = -1;
+ client_connection_t *conn = NULL;
+ conn = trans->xl_private;
hdr = (gf_hdr_common_t *)hdr_p;
diff --git a/xlators/protocol/client/src/client-protocol.h b/xlators/protocol/client/src/client-protocol.h
index c90cc980d..07898bba4 100644
--- a/xlators/protocol/client/src/client-protocol.h
+++ b/xlators/protocol/client/src/client-protocol.h
@@ -90,6 +90,7 @@ struct client_connection {
int32_t transport_timeout;
int32_t ping_started;
int32_t ping_timeout;
+ int32_t transport_activity;
gf_timer_t *reconnect;
char connected;
uint64_t max_block_size;