From 6a6abb5367f46bab4a7363db9e181c845a334cdb Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Tue, 21 Feb 2012 14:46:05 +0530 Subject: features/index: Fix fd leak Change-Id: Ib01d03999b099369674495ce500f48d492758f91 BUG: 763820 Signed-off-by: Pranith Kumar K Reviewed-on: http://review.gluster.com/2781 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- xlators/features/index/src/index.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'xlators/features/index') 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)) { -- cgit