Fix: keep the device gate outside the MCP pending lock
Release the DeviceTransferGate only after leaving m_PendingMutex in the three MCP begin paths, matching the documented gate -> pending -> xfer order (the gate mutex is brief, but this keeps the order explicit and avoids future nesting mistakes). Also short-circuit ObserveChunk when there are no preview requests or tombstones, so ordinary V2 chunk paths do not scan the preview maps. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
3683b4ebeb
commit
ea5d69d1c0
2 files changed
+21
-13
No files matched your search
@@ -14607,12 +14607,14 @@ bool CMcpServer::BeginFileTransferPending(uint64_t device_id, const std::string&
|
||||
if (!DeviceTransferGate::Instance().TryClaim(device_id, owner)) return false;
|
||||
|
||||
// 与一次性挂起请求互斥(F2):先查对方注册表再查自己的,避免跨锁嵌套死锁。
|
||||
bool pendingBusy = false;
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(m_PendingMutex);
|
||||
if (m_Pending.find(device_id) != m_Pending.end()) {
|
||||
DeviceTransferGate::Instance().Release(device_id, owner);
|
||||
return false;
|
||||
}
|
||||
pendingBusy = m_Pending.find(device_id) != m_Pending.end();
|
||||
}
|
||||
if (pendingBusy) {
|
||||
DeviceTransferGate::Instance().Release(device_id, owner);
|
||||
return false;
|
||||
}
|
||||
bool registered = false;
|
||||
{
|
||||
@@ -14644,12 +14646,14 @@ bool CMcpServer::BeginFileUpload(uint64_t device_id, uint64_t transfer_id) {
|
||||
if (!DeviceTransferGate::Instance().TryClaim(device_id, owner)) return false;
|
||||
|
||||
// 与一次性挂起请求互斥(F2):先查对方注册表再查自己的,避免跨锁嵌套死锁。
|
||||
bool pendingBusy = false;
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(m_PendingMutex);
|
||||
if (m_Pending.find(device_id) != m_Pending.end()) {
|
||||
DeviceTransferGate::Instance().Release(device_id, owner);
|
||||
return false;
|
||||
}
|
||||
pendingBusy = m_Pending.find(device_id) != m_Pending.end();
|
||||
}
|
||||
if (pendingBusy) {
|
||||
DeviceTransferGate::Instance().Release(device_id, owner);
|
||||
return false;
|
||||
}
|
||||
bool registered = false;
|
||||
{
|
||||
@@ -14685,14 +14689,16 @@ bool CMcpServer::BeginC2CTransfer(uint64_t src_id, uint64_t dst_id, uint64_t tra
|
||||
const uint64_t owner = s_ownerSeq.fetch_add(1);
|
||||
if (!DeviceTransferGate::Instance().TryClaimPair(src_id, dst_id, owner)) return false;
|
||||
|
||||
bool pendingBusy = false;
|
||||
{
|
||||
// 与一次性挂起请求互斥(F2):先查对方注册表再查自己的,避免跨锁嵌套死锁。
|
||||
std::lock_guard<std::mutex> lk(m_PendingMutex);
|
||||
if (m_Pending.find(src_id) != m_Pending.end() ||
|
||||
m_Pending.find(dst_id) != m_Pending.end()) {
|
||||
DeviceTransferGate::Instance().ReleasePair(src_id, dst_id, owner);
|
||||
return false;
|
||||
}
|
||||
pendingBusy = (m_Pending.find(src_id) != m_Pending.end() ||
|
||||
m_Pending.find(dst_id) != m_Pending.end());
|
||||
}
|
||||
if (pendingBusy) {
|
||||
DeviceTransferGate::Instance().ReleasePair(src_id, dst_id, owner);
|
||||
return false;
|
||||
}
|
||||
bool registered = false;
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user