From 865e5fa4108bb3f470b9424ec34dc573d97e2473 Mon Sep 17 00:00:00 2001 From: David Faure <faure> Date: Wed, 24 Aug 2011 10:29:09 +0200 Subject: [PATCH] Fix fd leak in KLockFile Didn't expect that after open(fd), QFile::close doesn't close the fd :) --- kdecore/io/klockfile_unix.cpp | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/kdecore/io/klockfile_unix.cpp b/kdecore/io/klockfile_unix.cpp index fa2eda4..93e92e2 100644 --- a/kdecore/io/klockfile_unix.cpp +++ b/kdecore/io/klockfile_unix.cpp @@ -78,6 +78,7 @@ public: : staleTime(30), // 30 seconds isLocked(false), linkCountSupport(true), + mustCloseFd(false), m_pid(-1), m_componentData(c) { @@ -102,6 +103,7 @@ public: int staleTime; bool isLocked; bool linkCountSupport; + bool mustCloseFd; QTime staleTimer; KDE_struct_stat statBuf; int m_pid; @@ -285,7 +287,10 @@ KLockFile::LockResult KLockFile::Private::lockFileOExcl(KDE_struct_stat &st_buf) if (!m_file.open(fd, QIODevice::WriteOnly)) { return LockError; } + mustCloseFd = true; writeIntoLockFile(m_file, m_componentData); + + // stat to get the modification time const int result = KDE_lstat(QFile::encodeName(m_fileName), &st_buf); if (result != 0) return KLockFile::LockError; @@ -476,6 +481,10 @@ void KLockFile::unlock() if (d->isLocked) { ::unlink(QFile::encodeName(d->m_fileName)); + if (d->mustCloseFd) { + close(d->m_file.handle()); + d->mustCloseFd = false; + } d->m_file.close(); d->m_pid = -1; d->isLocked = false; -- 1.7.6.4
kdelibs-4.6.5-8.fc15 has been submitted as an update for Fedora 15. https://admin.fedoraproject.org/updates/kdelibs-4.6.5-8.fc15
kdelibs-4.6.5-8.fc14 has been submitted as an update for Fedora 14. https://admin.fedoraproject.org/updates/kdelibs-4.6.5-8.fc14
*** Bug 754405 has been marked as a duplicate of this bug. ***
kdelibs-4.6.5-8.fc15 has been pushed to the Fedora 15 stable repository. If problems still persist, please make note of it in this bug report.
kdelibs-4.6.5-8.fc14 has been pushed to the Fedora 14 stable repository. If problems still persist, please make note of it in this bug report.