]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
don't close dotlock fd if it's given as -1
authorTimo Sirainen <tss@iki.fi>
Mon, 28 Jun 2004 16:44:38 +0000 (19:44 +0300)
committerTimo Sirainen <tss@iki.fi>
Mon, 28 Jun 2004 16:44:38 +0000 (19:44 +0300)
--HG--
branch : HEAD

src/lib/file-dotlock.c
src/lib/file-dotlock.h

index e1ae927092f3c9cb90f2b9ccf5d5024a6a84846a..49ccea03cdffdaca00b761e6b1b5113c78586c8a 100644 (file)
@@ -487,9 +487,11 @@ int file_dotlock_replace(const char *path, const char *lock_suffix,
                        return -1;
                }
        }
-       if (close(fd) < 0) {
-               i_error("close(%s) failed: %m", lock_path);
-               return -1;
+       if (fd != -1) {
+               if (close(fd) < 0) {
+                       i_error("close(%s) failed: %m", lock_path);
+                       return -1;
+               }
        }
 
        if (verify_owner) {
index 454efcefcb9f7aa2b7d5d2970cbeb5d5f81e6883..bd9f6a98795c387966531ec9ca17779d8a8046b7 100644 (file)
@@ -47,8 +47,9 @@ int file_dotlock_open(const char *path,
                      int (*callback)(unsigned int secs_left, int stale,
                                      void *context),
                      void *context);
-/* Replaces path with path.lock file. Closes given fd. If verify_owner is TRUE,
-   it checks that lock file hasn't been overwritten before renaming. */
+/* Replaces path with path.lock file. If verify_owner is TRUE, it checks that
+   lock file hasn't been overwritten before renaming. Closes given fd, unless
+   it's given as -1 in which case verify_owner must be FALSE. */
 int file_dotlock_replace(const char *path, const char *lock_suffix,
                         int fd, int verify_owner);
 /* Like file_unlock_dotlock(). Closes given fd. */