From 52f755f0fdafbfe2f06d1e777485399496b94f26 Mon Sep 17 00:00:00 2001 From: psychon Date: Tue, 8 Apr 2008 18:53:05 +0000 Subject: [PATCH] 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 --- znc.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/znc.cpp b/znc.cpp index 1f24d468..f2439a1c 100644 --- a/znc.cpp +++ b/znc.cpp @@ -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; }