Feature: share the device transfer gate with MCP file transfers

Preview and MCP must not run file transfers on one device at the same
time: MCP's stream interceptor is device-keyed and not tool-aware, so a
preview stream arriving while an upload/C2C session exists would be
swallowed. Claim the shared DeviceTransferGate in all three MCP entry
points (download/read, upload_file, copy_files_c2c) before touching the
pending/file-transfer registries, and release it in ClearFileTransfer.

C2C claims both src and dst atomically; a failed registry check releases
the claim before returning. The gate is acquired before m_PendingMutex
and m_FileXferMutex to keep the documented order.

Co-Authored-By: deepseek-flash
This commit is contained in:
yuanyuanxianganddeepseek-flash committed 2026-12-05 15:30:30 +01:00
1 parent 3b945d1992
commit 4d37d85bac
2 files changed
+96 -34

No files matched your search

+1
View File
@@ -911,6 +911,7 @@ private:
// ===== P6:文件传输会话(受 m_FileXferMutex 保护;单设备单传输)=====
struct FileTransferSession {
std::string tool; // "download_file" / "upload_file" / "copy_files_c2c"
uint64_t gateOwner = 0; // DeviceTransferGate 认领 owner(收尾释放用)
uint64_t dstClientID = 0; // copy_files_c2c:目标客户端(其余工具恒 0)
bool c2cResult = false; // copy_files_c2c:已收到源端结果包
uint32_t c2cStatus = 0; // 结果包 status(0=全部发出)