diff options
author | Pranith Kumar K <pranithk@gluster.com> | 2012-02-21 14:46:05 +0530 |
---|---|---|
committer | Vijay Bellur <vijay@gluster.com> | 2012-02-21 02:50:49 -0800 |
commit | 6a6abb5367f46bab4a7363db9e181c845a334cdb (patch) | |
tree | 0447bfe1f7cb5c452850f13ca57b9c9309ec8746 /xlators/features/index/src | |
parent | 709de8c86a2947c98d59a5b32bcf258c196bab4b (diff) |
features/index: Fix fd leak
Change-Id: Ib01d03999b099369674495ce500f48d492758f91
BUG: 763820
Signed-off-by: Pranith Kumar K <pranithk@gluster.com>
Reviewed-on: http://review.gluster.com/2781
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'xlators/features/index/src')
-rw-r--r-- | xlators/features/index/src/index.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/xlators/features/index/src/index.c b/xlators/features/index/src/index.c index 636c0f6da02..98c52220feb 100644 --- a/xlators/features/index/src/index.c +++ b/xlators/features/index/src/index.c @@ -356,6 +356,7 @@ index_add (xlator_t *this, uuid_t gfid, const char *subdir) uuid_t index = {0}; index_priv_t *priv = NULL; struct stat st = {0}; + int fd = 0; priv = this->private; GF_ASSERT_AND_GOTO_WITH_ERROR (this->name, !uuid_is_null (gfid), @@ -389,14 +390,16 @@ index_add (xlator_t *this, uuid_t gfid, const char *subdir) goto out; } - ret = creat (index_path, 0); - if (ret && (errno != EEXIST)) { + fd = creat (index_path, 0); + if ((fd < 0) && (errno != EEXIST)) { gf_log (this->name, GF_LOG_ERROR, "%s: Not able to " "create index (%s)", uuid_utoa (gfid), strerror (errno)); goto out; } + if (fd >= 0) + close (fd); ret = link (index_path, gfid_path); if (ret && (errno != EEXIST)) { |