From 4792bb9a6caa4c74b6facebaba9379694893070e Mon Sep 17 00:00:00 2001 From: Anush Shetty Date: Mon, 26 Jul 2010 05:07:18 +0000 Subject: Set fdctx only if op_ret is not -1 Signed-off-by: Anush Shetty Signed-off-by: Anand V. Avati BUG: 1218 (Crash in client_fdctx_destroy) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1218 --- xlators/protocol/client/src/client3_1-fops.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'xlators/protocol/client/src/client3_1-fops.c') diff --git a/xlators/protocol/client/src/client3_1-fops.c b/xlators/protocol/client/src/client3_1-fops.c index 8c99a1609..06b333484 100644 --- a/xlators/protocol/client/src/client3_1-fops.c +++ b/xlators/protocol/client/src/client3_1-fops.c @@ -2098,11 +2098,9 @@ client3_1_reopen_cbk (struct rpc_req *req, struct iovec *iov, int count, call_frame_t *frame = NULL; frame = myframe; - local = frame->local; conf = frame->this->private; - fdctx = local->fdctx; - + if (-1 == req->rpc_status) { rsp.op_ret = -1; rsp.op_errno = ENOTCONN; @@ -2122,6 +2120,8 @@ client3_1_reopen_cbk (struct rpc_req *req, struct iovec *iov, int count, local->loc.path, rsp.op_ret, rsp.fd); if (-1 != rsp.op_ret) { + fdctx = local->fdctx; + if(fdctx) { pthread_mutex_lock (&conf->lock); { fdctx->remote_fd = rsp.fd; @@ -2132,6 +2132,8 @@ client3_1_reopen_cbk (struct rpc_req *req, struct iovec *iov, int count, } } pthread_mutex_unlock (&conf->lock); + + } } out: @@ -2164,8 +2166,7 @@ client3_1_reopendir_cbk (struct rpc_req *req, struct iovec *iov, int count, local = frame->local; frame->local = NULL; conf = frame->this->private; - fdctx = local->fdctx; - + if (-1 == req->rpc_status) { rsp.op_ret = -1; rsp.op_errno = ENOTCONN; @@ -2184,7 +2185,9 @@ client3_1_reopendir_cbk (struct rpc_req *req, struct iovec *iov, int count, "reopendir on %s returned %d (%"PRId64")", local->loc.path, rsp.op_ret, rsp.fd); - if (fdctx) { + if (-1 != rsp.op_ret) { + fdctx = local->fdctx; + if (fdctx) { pthread_mutex_lock (&conf->lock); { fdctx->remote_fd = rsp.fd; @@ -2195,6 +2198,8 @@ client3_1_reopendir_cbk (struct rpc_req *req, struct iovec *iov, int count, } } pthread_mutex_unlock (&conf->lock); + + } } out: -- cgit