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 <psychon@znc.in>
This commit is contained in:
Uli Schlachter
2011-03-31 18:10:02 +02:00
parent 70358cabdd
commit cc2d84d4a6

View File

@@ -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();