diff options
author | linbaiye <linbaiye@gmail.com> | 2012-09-28 18:56:26 +0800 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2012-10-11 20:59:45 -0700 |
commit | 5459e74ef28bd08e48f95c2732f04144fdbbee56 (patch) | |
tree | e4dd506813c344e59adf47765d2376cbd9d8df9e /xlators/cluster/afr/src/afr-transaction.c | |
parent | 7413b50220779d185efdb1d259c379a119a30a77 (diff) |
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 <linbaiye@gmail.com>
Reviewed-on: http://review.gluster.org/4005
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/cluster/afr/src/afr-transaction.c')
-rw-r--r-- | xlators/cluster/afr/src/afr-transaction.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c index be4a914d4a6..265d93b6189 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; } |