Fix for OpenBSD and don't busy loop for file locks

I don't think there is a high change that the file lock becomes available
in the short time we did loop and retry the lock, so that code served no
real purpose.

Also, this includes unistd.h in Utils.h which is needed for OpenBSD.
Thanks to fred for testing on his openbsd/sparc box.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@918 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2008-01-08 17:13:10 +00:00
parent f497932fb2
commit 5210c3bfae
2 changed files with 10 additions and 45 deletions

View File

@@ -186,7 +186,7 @@ bool CZNC::WriteISpoof(CUser* pUser) {
if (!m_sISpoofFile.empty()) {
m_pISpoofLockFile = new CLockFile;
if(!m_pISpoofLockFile->TryExLock(m_sISpoofFile, 50, true)) {
if(!m_pISpoofLockFile->TryExLock(m_sISpoofFile, true)) {
delete m_pISpoofLockFile;
m_pISpoofLockFile = NULL;
return false;
@@ -457,7 +457,7 @@ bool CZNC::WriteNewConfig(const CString& sConfig) {
vector<CString> vsLines;
if (CFile::Exists(sConfigFile)) {
if (!m_LockFile.TryExLock(sConfigFile, 50)) {
if (!m_LockFile.TryExLock(sConfigFile)) {
CUtils::PrintError("ZNC is currently running on this config.");
return false;
}
@@ -760,7 +760,7 @@ bool CZNC::ParseConfig(const CString& sConfig) {
return false;
}
if (!m_LockFile.TryExLock(m_sConfigFile, 50)) {
if (!m_LockFile.TryExLock(m_sConfigFile)) {
CUtils::PrintStatus(false, "ZNC is already running on this config.");
return false;
}