Skip to content

Commit

Permalink
avoid deadlock: cancel hydration requests coming from itself
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
mgallien authored and backportbot[bot] committed Jul 1, 2024
1 parent 0324395 commit 3a34b39
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/libsync/vfs/cfapi/cfapiwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<OCC::VfsCfApi *>(callbackInfo->CallbackContext);
Q_ASSERT(vfs->metaObject()->className() == QByteArrayLiteral("OCC::VfsCfApi"));
const auto path = QString(QString::fromWCharArray(callbackInfo->VolumeDosName) + QString::fromWCharArray(callbackInfo->NormalizedPath));
Expand Down

0 comments on commit 3a34b39

Please sign in to comment.