From cc2d84d4a69453cf12d1bb3af7d9c2f98fbf6df3 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Thu, 31 Mar 2011 18:10:02 +0200 Subject: [PATCH] CFile::TryExLock(): Use O_RDWR by default Getting an exclusive lock on a file with TryExLock() requires write access, therefor O_RDONLY is wrong here. This worked back when we were using flock() for file locking, because flock() doesn't need write access for an exclusive locks. This fixes a bug where "--makeconf" claims that there is already a znc instance running on the config file. This happened because it mis-interpreted the -EBADF error from fcntl() as "something else already has a lock". Signed-off-by: Uli Schlachter --- FileUtils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FileUtils.h b/FileUtils.h index 3323cb5c..46d43e14 100644 --- a/FileUtils.h +++ b/FileUtils.h @@ -110,7 +110,7 @@ public: void Close(); void ClearBuffer(); - bool TryExLock(const CString& sLockFile, int iFlags = O_RDONLY | O_CREAT); + bool TryExLock(const CString& sLockFile, int iFlags = O_RDWR | O_CREAT); bool TryExLock(); bool ExLock(); bool UnLock();