[sheepdog] [PATCH] dog/farm: fix closing negative fd

Ruoyu liangry at ucweb.com
Wed Jun 18 12:17:57 CEST 2014


When executing dog cluster snapshot command, valgrind report
"Warning: invalid file descriptor -1 in syscall close()".

This patch fix the problem.

Signed-off-by: Ruoyu <liangry at ucweb.com>
---
 dog/farm/snap.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/dog/farm/snap.c b/dog/farm/snap.c
index ff03047..9040369 100644
--- a/dog/farm/snap.c
+++ b/dog/farm/snap.c
@@ -36,10 +36,11 @@ int snap_init(const char *farm_dir)
 
 	fd = open(snap_log_path, O_CREAT | O_EXCL, 0666);
 	if (fd < 0) {
-		if (errno != EEXIST) {
+		if (errno != EEXIST)
 			sd_err("%m");
-			goto out;
-		}
+		else
+			ret = 0;
+		goto out;
 	}
 
 	ret = 0;
-- 
1.8.3.2





More information about the sheepdog mailing list