From: Timo Sirainen Date: Mon, 28 Jun 2004 16:44:38 +0000 (+0300) Subject: don't close dotlock fd if it's given as -1 X-Git-Tag: 1.1.alpha1~3860 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d6f2a39470b2d0b9e44bd886abacd41e6e1ec2d2;p=thirdparty%2Fdovecot%2Fcore.git don't close dotlock fd if it's given as -1 --HG-- branch : HEAD --- diff --git a/src/lib/file-dotlock.c b/src/lib/file-dotlock.c index e1ae927092..49ccea03cd 100644 --- a/src/lib/file-dotlock.c +++ b/src/lib/file-dotlock.c @@ -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) { diff --git a/src/lib/file-dotlock.h b/src/lib/file-dotlock.h index 454efcefcb..bd9f6a9879 100644 --- a/src/lib/file-dotlock.h +++ b/src/lib/file-dotlock.h @@ -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. */