From 610ce35050ea229263c63173633a285561c4c675 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Fri, 31 May 2024 20:14:41 +0300 Subject: [PATCH] kdecore: log debug messages for KLockFile Signed-off-by: Ivailo Monev --- kdecore/io/klockfile_unix.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kdecore/io/klockfile_unix.cpp b/kdecore/io/klockfile_unix.cpp index 4e9fa230..dc21f072 100644 --- a/kdecore/io/klockfile_unix.cpp +++ b/kdecore/io/klockfile_unix.cpp @@ -39,6 +39,7 @@ class KLockFilePrivate public: KLockFilePrivate(); + QString m_lockname; QByteArray m_lockfile; int m_lockfd; }; @@ -51,6 +52,7 @@ KLockFilePrivate::KLockFilePrivate() KLockFile::KLockFile(const QString &file) : d(new KLockFilePrivate()) { + d->m_lockname = file; // NOTE: KConfig may attempt to create KLockFile from its destructor when KGlobal is no more // thus QStandardPaths::writableLocation() is used here d->m_lockfile = QFile::encodeName(QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation)); @@ -78,10 +80,12 @@ bool KLockFile::tryLock() void KLockFile::lock() { + kDebug() << "locking" << d->m_lockname << d->m_lockfile; while (!tryLock() && !d->m_lockfile.isEmpty()) { QCoreApplication::processEvents(QEventLoop::AllEvents, KLOCKFILE_TIMEOUT); QThread::msleep(KLOCKFILE_SLEEPTIME); } + kDebug() << "locked" << d->m_lockname << d->m_lockfile; } bool KLockFile::isLocked() const @@ -95,8 +99,9 @@ void KLockFile::unlock() QT_CLOSE(d->m_lockfd); if (Q_UNLIKELY(::unlink(d->m_lockfile.constData()) == -1)) { const int savederrno = errno; - kWarning() << "Could not remove lock file" << qt_error_string(savederrno); + kWarning() << "could not remove lock file" << qt_error_string(savederrno); } d->m_lockfd = -1; + kDebug() << "unlocked" << d->m_lockname << d->m_lockfile; } }