From 74623a9e5c08d9866ff4989c008dfc59f849befb Mon Sep 17 00:00:00 2001 From: psychon Date: Mon, 11 Feb 2008 21:01:50 +0000 Subject: [PATCH] Fix CLockFile's fd leak CLockFile::Close() only closed the fd if we didn't call fork() or are the father. Fix this. This also fixes rehashing for --disable-debug. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@955 726aef4b-f618-498e-8847-2d620e286838 --- Utils.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Utils.h b/Utils.h index 4bdda588..4a6d528e 100644 --- a/Utils.h +++ b/Utils.h @@ -85,15 +85,18 @@ public: void Close() { if (getpid() == m_pid && m_fd > -1) { + // This UnLock() also unlocks for all of our childs! UnLock(); close(m_fd); if (m_bCreated) { unlink(m_sFileName.c_str()); } + } else if (m_fd > -1) + // Make sure we don't leak this fd + close(m_fd); - Init(); - } + Init(); } void Open(const CString& sFile, bool bRw = false) {