Mercurial > dovecot > original-hg > dovecot-1.2
changeset 5969:29770d8a013b HEAD
Use nfs_safe_lstat() when dotlocking. Also use lstat() not stat() for
checking how our file was created (probably doesn't ever really matter).
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 12 Jul 2007 23:52:03 +0300 |
parents | 885ed4d5c51d |
children | a290b84d144a |
files | src/lib/file-dotlock.c |
diffstat | 1 files changed, 9 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib/file-dotlock.c Thu Jul 12 23:50:54 2007 +0300 +++ b/src/lib/file-dotlock.c Thu Jul 12 23:52:03 2007 +0300 @@ -8,6 +8,7 @@ #include "randgen.h" #include "write-full.h" #include "safe-mkstemp.h" +#include "nfs-workarounds.h" #include "file-dotlock.h" #include <stdio.h> @@ -148,7 +149,7 @@ { struct stat st; - if (lstat(lock_info->lock_path, &st) < 0) { + if (nfs_safe_lstat(lock_info->lock_path, &st) < 0) { if (errno != ENOENT) { i_error("lstat(%s) failed: %m", lock_info->lock_path); return -1; @@ -231,7 +232,7 @@ /* possibly stale lock file. check also the timestamp of the file we're protecting. */ - if (stat(lock_info->path, &st) < 0) { + if (nfs_safe_stat(lock_info->path, &st) < 0) { if (errno == ENOENT) { /* file doesn't exist. treat it as if it hasn't changed */ @@ -574,9 +575,10 @@ return -1; } - /* some NFS implementations may have used cached mtime in previous - fstat() call. Check again to avoid "dotlock was modified" errors. */ - if (stat(lock_path, &st) < 0) { + /* With NFS the writes may have been flushed only when closing the + file. Get the mtime again after that to avoid "dotlock was modified" + errors. */ + if (lstat(lock_path, &st) < 0) { if (errno != ENOENT) i_error("stat(%s) failed: %m", lock_path); else { @@ -612,7 +614,7 @@ *dotlock_p = NULL; lock_path = file_dotlock_get_lock_path(dotlock); - if (lstat(lock_path, &st) < 0) { + if (nfs_safe_lstat(lock_path, &st) < 0) { if (errno == ENOENT) { i_warning("Our dotlock file %s was deleted " "(kept it %d secs)", lock_path, @@ -708,7 +710,7 @@ return -1; } - if (lstat(lock_path, &st2) < 0) { + if (nfs_safe_lstat(lock_path, &st2) < 0) { i_error("lstat(%s) failed: %m", lock_path); file_dotlock_free(dotlock); return -1;