Remove CLockFile and let CFile do its job

This shouldn't contain any major behaviour change, but there are some minor
ones. Also, the API for a shared lock wasn't used and thus is dropped.

Thanks to cnu for this idea.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1337 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2009-01-20 13:21:29 +00:00
parent 6345ce12fa
commit 127347825e
5 changed files with 45 additions and 118 deletions

View File

@@ -372,6 +372,31 @@ void CFile::Close() {
}
void CFile::ClearBuffer() { m_sBuffer.clear(); }
bool CFile::TryExLock(const CString& sLockFile, int iFlags) {
Open(sLockFile, iFlags);
return TryExLock();
}
bool CFile::TryExLock() {
return Lock(LOCK_EX|LOCK_NB);
}
bool CFile::UnLock() {
return Lock(LOCK_UN);
}
bool CFile::Lock(int iOperation) {
if (m_iFD == -1) {
return false;
}
if (::flock(m_iFD, iOperation) != 0) {
return false;
}
return true;
}
bool CFile::IsOpen() const { return (m_iFD != -1); }
CString CFile::GetLongName() const { return m_sLongName; }
CString CFile::GetShortName() const { return m_sShortName; }