Reuse the FD for locking the config for reading it

This saves us one whole open() :P
Honestly, this fixes some (stupid) locking problems with cygwin and shouldn't
hurt much otherwise (And no, cygwin still isn't supported yet).


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1020 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2008-04-08 18:53:05 +00:00
parent 0afd0cf5dd
commit 52f755f0fd
+5 -4
View File
@@ -909,11 +909,12 @@ bool CZNC::DoRehash(CString& sError)
return false;
}
CFile File(m_sConfigFile);
CFile File(m_LockFile.GetFD(), m_sConfigFile);
if (!File.Open(O_RDONLY)) {
sError = "Could not open config";
CUtils::PrintStatus(false);
// This fd is re-used for rehashing, so we must seek back to the beginning!
if (!File.Seek(0)) {
sError = "Could not seek to the beginning of the config.";
CUtils::PrintStatus(false, sError);
return false;
}