diff options
author | Krishnan P <kp@gluster.com> | 2011-07-12 01:51:17 +0000 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2011-07-12 02:12:58 -0700 |
commit | 03df277c7880541570107bbaa7f91e5cf7ad5a69 (patch) | |
tree | bf9d1e0dbd302dd2c6a05ab7b27eadf070db8e53 /xlators/cluster/afr/src/afr-self-heal-data.c | |
parent | 1f5119627b278b98518afb68a7eb88752932976c (diff) |
pump, afr: dict related memory fixes.
Signed-off-by: Krishnan Parthasarathi <kp@gluster.com>
Signed-off-by: Anand Avati <avati@gluster.com>
BUG: 2489 (GlusterFS crashing with replace-brick)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2489
Diffstat (limited to 'xlators/cluster/afr/src/afr-self-heal-data.c')
-rw-r--r-- | xlators/cluster/afr/src/afr-self-heal-data.c | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heal-data.c b/xlators/cluster/afr/src/afr-self-heal-data.c index 13aa054dc75..f4cc4275de5 100644 --- a/xlators/cluster/afr/src/afr-self-heal-data.c +++ b/xlators/cluster/afr/src/afr-self-heal-data.c @@ -844,7 +844,7 @@ afr_sh_data_fxattrop (call_frame_t *frame, xlator_t *this) afr_local_t *local = NULL; afr_private_t *priv = NULL; dict_t *xattr_req = NULL; - int32_t zero_pending[3] = {0,}; + int32_t *zero_pending = NULL; int call_count = 0; int i = 0; int ret = 0; @@ -859,13 +859,27 @@ afr_sh_data_fxattrop (call_frame_t *frame, xlator_t *this) local->call_count = call_count; xattr_req = dict_new(); - if (xattr_req) { - for (i = 0; i < priv->child_count; i++) { - ret = dict_set_static_bin (xattr_req, priv->pending_key[i], - zero_pending, 3 * sizeof(int32_t)); - if (ret < 0) - gf_log (this->name, GF_LOG_WARNING, - "Unable to set dict value"); + if (!xattr_req) { + ret = -1; + goto out; + } + + for (i = 0; i < priv->child_count; i++) { + zero_pending = GF_CALLOC (3, sizeof (*zero_pending), + gf_afr_mt_int32_t); + if (!zero_pending) { + ret = -1; + goto out; + } + ret = dict_set_dynptr (xattr_req, priv->pending_key[i], + zero_pending, + 3 * sizeof (*zero_pending)); + if (ret < 0) { + gf_log (this->name, GF_LOG_WARNING, + "Unable to set dict value"); + goto out; + } else { + zero_pending = NULL; } } @@ -883,13 +897,20 @@ afr_sh_data_fxattrop (call_frame_t *frame, xlator_t *this) } } +out: if (xattr_req) dict_unref (xattr_req); + if (ret) { + if (zero_pending) + GF_FREE (zero_pending); + sh->op_failed = 1; + afr_sh_data_done (frame, this); + } + return 0; } - int afr_sh_data_lock_rec (call_frame_t *frame, xlator_t *this); |