From 5459e74ef28bd08e48f95c2732f04144fdbbee56 Mon Sep 17 00:00:00 2001 From: linbaiye Date: Fri, 28 Sep 2012 18:56:26 +0800 Subject: Preventing client crashing as the callings of GF_CALLOC has been failed. As the callings of GF_CALLOC can seldom come to a failure, glusterfs client will crash due to segment fault. We should have returned once the variables of transaction's local can't be alloced. Change-Id: Ia3798b8349d832b23c7825e64dbad93ebe29cd1b BUG: 861335 Signed-off-by: linbaiye Reviewed-on: http://review.gluster.org/4005 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- xlators/cluster/afr/src/afr-transaction.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'xlators/cluster/afr/src/afr-transaction.c') diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c index be4a914d4..265d93b61 100644 --- a/xlators/cluster/afr/src/afr-transaction.c +++ b/xlators/cluster/afr/src/afr-transaction.c @@ -1452,21 +1452,25 @@ afr_transaction (call_frame_t *frame, xlator_t *this, afr_transaction_type type) afr_local_t * local = NULL; afr_private_t * priv = NULL; fd_t *fd = NULL; + int ret = -1; local = frame->local; priv = this->private; - afr_transaction_local_init (local, this); + if (local->fd && priv->eager_lock && + local->transaction.type == AFR_DATA_TRANSACTION) + afr_set_lk_owner (frame, this, local->fd); + else + afr_set_lk_owner (frame, this, frame->root); + + ret = afr_transaction_local_init (local, this); + if (ret < 0) { + goto out; + } local->transaction.resume = afr_transaction_resume; local->transaction.type = type; - if (local->fd && priv->eager_lock && - local->transaction.type == AFR_DATA_TRANSACTION) - afr_set_lk_owner (frame, this, local->fd); - else - afr_set_lk_owner (frame, this, frame->root); - if (_does_transaction_conflict_with_delayed_post_op (frame) && local->loc.inode) { fd = fd_lookup (local->loc.inode, frame->root->pid); @@ -1481,6 +1485,7 @@ afr_transaction (call_frame_t *frame, xlator_t *this, afr_transaction_type type) } else { afr_lock (frame, this); } - - return 0; + ret = 0; +out: + return ret; } -- cgit