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) {
}
}
+ /* 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);