summaryrefslogtreecommitdiff
path: root/fast-import.c
diff options
context:
space:
mode:
authorBrandon Casey <casey@nrlssc.navy.mil>2008-01-16 13:12:46 -0600
committerJunio C Hamano <gitster@pobox.com>2008-01-16 15:35:35 -0800
commit4ed7cd3ab07f7c721daf4241fe1dac306fefd1fb (patch)
treee3b03a59cd0bca192fb396522f813210451404b8 /fast-import.c
parentd6cf61bfd4bccffcc8b095f8469dbe749d70abdf (diff)
downloadgit-4ed7cd3ab07f7c721daf4241fe1dac306fefd1fb.tar.gz
Improve use of lockfile API
Remove remaining double close(2)'s. i.e. close() before commit_locked_index() or commit_lock_file(). Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fast-import.c')
-rw-r--r--fast-import.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/fast-import.c b/fast-import.c
index 82e9161339..3609c24288 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -1546,10 +1546,18 @@ static void dump_marks(void)
}
dump_marks_helper(f, 0, marks);
- fclose(f);
- if (commit_lock_file(&mark_lock))
+ if (ferror(f) || fclose(f))
failure |= error("Unable to write marks file %s: %s",
mark_file, strerror(errno));
+ /*
+ * Since the lock file was fdopen()'ed and then fclose()'ed above,
+ * assign -1 to the lock file descriptor so that commit_lock_file()
+ * won't try to close() it.
+ */
+ mark_lock.fd = -1;
+ if (commit_lock_file(&mark_lock))
+ failure |= error("Unable to write commit file %s: %s",
+ mark_file, strerror(errno));
}
static int read_next_command(void)