From 1f1a2f8c47c4b67438d9413e7fc7a18af9083f4b Mon Sep 17 00:00:00 2001 From: Anand Avati Date: Mon, 22 Feb 2010 03:42:04 +0000 Subject: protocol/client: better pointer check on saved_frames mapping in ping timer Signed-off-by: Anand V. Avati Signed-off-by: Anand V. Avati BUG: 434 (Crash with 3.0.0pre2 on client01 with "metarates" parallel MPI metadata benchmark) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=434 --- xlators/protocol/client/src/client-protocol.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/xlators/protocol/client/src/client-protocol.c b/xlators/protocol/client/src/client-protocol.c index 8182954ceb6..3adfbd79b74 100644 --- a/xlators/protocol/client/src/client-protocol.c +++ b/xlators/protocol/client/src/client-protocol.c @@ -433,6 +433,7 @@ client_start_ping (void *data) call_frame_t *dummy_frame = NULL; size_t hdrlen = -1; gf_mop_ping_req_t *req = NULL; + int frame_count = 0; trans = data; @@ -445,33 +446,35 @@ client_start_ping (void *data) pthread_mutex_lock (&conn->lock); { - if ((conn->saved_frames->count == 0) || - !conn->connected) { + if (conn->ping_timer) + gf_timer_call_cancel (trans->xl->ctx, conn->ping_timer); + + conn->ping_timer = NULL; + conn->ping_started = 0; + + if (conn->saved_frames) + /* 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) { /* using goto looked ugly here, * hence getting out this way */ - if (conn->ping_timer) - gf_timer_call_cancel (trans->xl->ctx, - conn->ping_timer); - conn->ping_timer = NULL; - conn->ping_started = 0; /* unlock */ pthread_mutex_unlock (&conn->lock); return; } - if (conn->saved_frames->count < 0) { + if (frame_count < 0) { gf_log (this->name, GF_LOG_DEBUG, "saved_frames->count is %"PRId64, conn->saved_frames->count); conn->saved_frames->count = 0; } + timeout.tv_sec = conn->ping_timeout; timeout.tv_usec = 0; - if (conn->ping_timer) - gf_timer_call_cancel (trans->xl->ctx, - conn->ping_timer); - conn->ping_timer = gf_timer_call_after (trans->xl->ctx, timeout, client_ping_timer_expired, -- cgit