From 3a34b396eae6ee6ccb7c91c1a6f55e6cf5fc719f Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Mon, 1 Jul 2024 16:10:02 +0200 Subject: [PATCH] avoid deadlock: cancel hydration requests coming from itself our current infrastructure will cause a deadlock for any hydration requests coming from desktop files client itself the main thread is responsible for executing the hydration request but if the same thread is already blocked waiting for the hydration to happen, both (open system call and hydration request handling) process will never be completed and wait for each over in a stuck cycle Signed-off-by: Matthieu Gallien --- src/libsync/vfs/cfapi/cfapiwrapper.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libsync/vfs/cfapi/cfapiwrapper.cpp b/src/libsync/vfs/cfapi/cfapiwrapper.cpp index 3e2928f7bc17c..a5f370acbf42a 100644 --- a/src/libsync/vfs/cfapi/cfapiwrapper.cpp +++ b/src/libsync/vfs/cfapi/cfapiwrapper.cpp @@ -157,6 +157,12 @@ void CALLBACK cfApiFetchDataCallback(const CF_CALLBACK_INFO *callbackInfo, const callbackInfo->FileSize.QuadPart); }; + if (QCoreApplication::applicationPid() == callbackInfo->ProcessInfo->ProcessId) { + qCCritical(lcCfApiWrapper) << "implicit hydration triggered by the client itself. Will lead to a deadlock. Cancel"; + sendTransferError(); + return; + } + auto vfs = reinterpret_cast(callbackInfo->CallbackContext); Q_ASSERT(vfs->metaObject()->className() == QByteArrayLiteral("OCC::VfsCfApi")); const auto path = QString(QString::fromWCharArray(callbackInfo->VolumeDosName) + QString::fromWCharArray(callbackInfo->NormalizedPath));