Mercurial > dovecot > original-hg > dovecot-1.2
changeset 7544:7512b6d8afe1 HEAD
squat: Flush NFS caches.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 25 May 2008 03:11:15 +0300 |
parents | 8a4ac809d472 |
children | 2c3bb09045be |
files | src/plugins/fts-squat/squat-trie.c |
diffstat | 1 files changed, 14 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/fts-squat/squat-trie.c Sun May 25 02:58:42 2008 +0300 +++ b/src/plugins/fts-squat/squat-trie.c Sun May 25 03:11:15 2008 +0300 @@ -7,6 +7,7 @@ #include "istream.h" #include "ostream.h" #include "unichar.h" +#include "nfs-workarounds.h" #include "file-cache.h" #include "seq-range-array.h" #include "squat-uidlist.h" @@ -246,7 +247,9 @@ { struct stat st, st2; - if (stat(trie->path, &st) < 0) { + if ((trie->flags & SQUAT_INDEX_FLAG_NFS_FLUSH) != 0) + nfs_flush_file_handle_cache(trie->path); + if (nfs_safe_stat(trie->path, &st) < 0) { if (errno == ENOENT) return 1; @@ -254,6 +257,8 @@ return -1; } if (fstat(trie->fd, &st2) < 0) { + if (errno == ESTALE) + return 1; i_error("fstat(%s) failed: %m", trie->path); return -1; } @@ -281,7 +286,7 @@ *file_lock_r = NULL; *dotlock_r = NULL; - while (trie->fd != -1) { + for (;;) { if (trie->lock_method != FILE_LOCK_METHOD_DOTLOCK) { ret = file_wait_lock(trie->fd, trie->path, lock_type, trie->lock_method, @@ -302,7 +307,7 @@ file and try to lock again */ ret = squat_trie_is_file_stale(trie); if (ret == 0) - return 1; + break; if (*file_lock_r != NULL) file_unlock(file_lock_r); @@ -314,8 +319,13 @@ squat_trie_close(trie); if (squat_trie_open_fd(trie) < 0) return -1; + if (trie->fd == -1) + return 0; } - return 0; + + if ((trie->flags & SQUAT_INDEX_FLAG_NFS_FLUSH) != 0) + nfs_flush_read_cache_locked(trie->path, trie->fd); + return 1; } static void