changeset 6799:c1bd43be8f9a HEAD

Don't flush attribute cache the first time when stating a lock file. Usually the locking works fine without it.
author Timo Sirainen <tss@iki.fi>
date Thu, 15 Nov 2007 00:46:43 +0200
parents e70686f19f67
children ca849e28a062
files src/lib/file-dotlock.c
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/file-dotlock.c	Thu Nov 15 00:38:05 2007 +0200
+++ b/src/lib/file-dotlock.c	Thu Nov 15 00:46:43 2007 +0200
@@ -66,6 +66,7 @@
 	unsigned int have_pid:1;
 	unsigned int pid_read:1;
 	unsigned int use_io_notify:1;
+	unsigned int lock_stated:1;
 };
 
 static struct dotlock *
@@ -155,8 +156,12 @@
 {
 	struct stat st;
 
-	if (lock_info->set->nfs_flush)
+	/* don't waste time flushing attribute cache the first time we're here.
+	   if it's stale we'll get back here soon. */
+	if (lock_info->set->nfs_flush && lock_info->lock_stated)
 		nfs_flush_attr_cache(lock_info->lock_path, TRUE);
+
+	lock_info->lock_stated = TRUE;
 	if (nfs_safe_lstat(lock_info->lock_path, &st) < 0) {
 		if (errno != ENOENT) {
 			i_error("lstat(%s) failed: %m", lock_info->lock_path);
@@ -448,7 +453,7 @@
 	lock_info.lock_path = lock_path;
 	lock_info.fd = -1;
 	lock_info.use_io_notify = set->use_io_notify;
-;
+
 	last_notify = 0; do_wait = FALSE;
 
 	do {