diff -rw -U3 dovecot-1.0.10/src/lib/file-dotlock.c dovecot-1.0.10-patch/src/lib/file-dotlock.c
--- dovecot-1.0.10/src/lib/file-dotlock.c	2007-12-11 13:52:08.000000000 -0500
+++ dovecot-1.0.10/src/lib/file-dotlock.c	2008-01-23 08:53:33.000000000 -0500
@@ -635,7 +635,7 @@
 	struct dotlock *dotlock;
 	struct stat st, st2;
 	const char *lock_path;
-	int fd;
+	int fd, old_errno;
 
 	dotlock = *dotlock_p;
 	*dotlock_p = NULL;
@@ -669,6 +669,14 @@
 		}
 	}
 
+        if (dotlock->fd != -1) {
+                old_errno = errno;
+                if (close(dotlock->fd) < 0)
+                        i_error("close(%s) failed: %m", dotlock->path);
+                dotlock->fd = -1;
+                errno = old_errno;
+        }
+	
 	if (rename(lock_path, dotlock->path) < 0) {
 		i_error("rename(%s, %s) failed: %m", lock_path, dotlock->path);
 		file_dotlock_free(dotlock);
