summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVijay Bellur <vbellur@redhat.com>2014-11-20 23:01:00 +0530
committerNiels de Vos <ndevos@redhat.com>2014-12-04 13:32:59 -0800
commit7b160e36352a7f6da4a40e2278f58fba2fe60c88 (patch)
tree49c8ae6b8e0f6ba49d329a1e4da80a525f8342f1
parent2de7f7c1e8da083d37b3fb4f5004750ae09d9e38 (diff)
features/index: Perform closedir() in error paths to avoid fd leaks
Change-Id: I7c8fc22ebe3c9cdf88e803e27c645cbad0012d16 BUG: 1166275 Signed-off-by: Vijay Bellur <vbellur@redhat.com> Reviewed-on: http://review.gluster.org/9167 Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Niels de Vos <ndevos@redhat.com>
-rw-r--r--xlators/features/index/src/index.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/xlators/features/index/src/index.c b/xlators/features/index/src/index.c
index 8acddf0..fce57ab 100644
--- a/xlators/features/index/src/index.c
+++ b/xlators/features/index/src/index.c
@@ -423,15 +423,13 @@ sync_base_indices (void *index_priv)
}
}
- ret = closedir (xattrop_dir);
- if (ret)
- goto out;
- ret = closedir (dir_base_holder);
- if (ret)
- goto out;
ret = 0;
out:
+ if (xattrop_dir)
+ closedir (xattrop_dir);
+ if (dir_base_holder)
+ closedir (dir_base_holder);
return ret;
}
@@ -501,7 +499,6 @@ sync_base_indices_from_xattrop (xlator_t *this)
if (ret)
goto out;
}
- closedir (dir);
}
/*At this point of time we have index/base_indicies_holder directory
@@ -519,9 +516,10 @@ sync_base_indices_from_xattrop (xlator_t *this)
ret = synctask_new (this->ctx->env, sync_base_indices,
base_indices_syncing_done,frame, priv);
-
-
out:
+ if (dir)
+ closedir (dir);
+
return ret;
}
@@ -775,6 +773,7 @@ __index_fd_ctx_get (fd_t *fd, xlator_t *this, index_fd_ctx_t **ctx)
ret = __fd_ctx_set (fd, this, (uint64_t)(long)fctx);
if (ret) {
+ closedir (fctx->dir);
GF_FREE (fctx);
fctx = NULL;
ret = -EINVAL;