From ef5ad624ab2463cbbb58e7a616de9e6b191fcb3b Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 17 Apr 2003 17:20:47 +0300 Subject: [PATCH] We got dotlock's mtime before modifying it, which caused problems sometimes. --HG-- branch : HEAD --- src/lib/file-dotlock.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/lib/file-dotlock.c b/src/lib/file-dotlock.c index 699abb1b9b..b25a2fa609 100644 --- a/src/lib/file-dotlock.c +++ b/src/lib/file-dotlock.c @@ -147,17 +147,6 @@ static int try_create_lock(const char *lock_path, struct dotlock *dotlock_r) if (fd == -1) return -1; - /* got it, save the inode info */ - if (fstat(fd, &st) < 0) { - i_error("fstat(%s) failed: %m", lock_path); - (void)close(fd); - return -1; - } - - dotlock_r->dev = st.st_dev; - dotlock_r->ino = st.st_ino; - dotlock_r->mtime = st.st_mtime; - /* write our pid and host, if possible */ str = t_strdup_printf("%s:%s", my_pid, my_hostname); if (write_full(fd, str, strlen(str)) < 0) { @@ -170,6 +159,17 @@ static int try_create_lock(const char *lock_path, struct dotlock *dotlock_r) } } + /* save the inode info after writing */ + if (fstat(fd, &st) < 0) { + i_error("fstat(%s) failed: %m", lock_path); + (void)close(fd); + return -1; + } + + dotlock_r->dev = st.st_dev; + dotlock_r->ino = st.st_ino; + dotlock_r->mtime = st.st_mtime; + if (close(fd) < 0) { i_error("close(%s) failed: %m", lock_path); (void)unlink(lock_path); -- 2.47.3