mirror of
https://github.com/znc/znc.git
synced 2026-05-06 21:42:28 +02:00
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:
@@ -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; }
|
||||
|
||||
Reference in New Issue
Block a user