[Sheepdog] [PATCH] fixed a fd leak in read_working_object()

Li Wenpeng levin108 at gmail.com
Thu Apr 5 08:43:35 CEST 2012


From: levin li <xingke.lwp at taobao.com>

Signed-off-by: levin li <xingke.lwp at taobao.com>
---
 sheep/farm/farm.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/sheep/farm/farm.c b/sheep/farm/farm.c
index 37faf7a..eaf361c 100644
--- a/sheep/farm/farm.c
+++ b/sheep/farm/farm.c
@@ -314,9 +314,10 @@ static void *read_working_object(uint64_t oid, int length)
 		buf = NULL;
 		goto out;
 	}
-	close(fd);
 
 out:
+	if (fd > 0)
+		close(fd);
 	return buf;
 }
 
-- 
1.7.1




More information about the sheepdog mailing list