Skip to content

fix: restore concurrent transfer check in rpc handler - #836

Draft
pppanghu77 wants to merge 1 commit into
linuxdeepin:release/v20from
pppanghu77:fix/pms-250595-restore-concurrent-check
Draft

pppanghu77 wants to merge 1 commit into
linuxdeepin:release/v20from
pppanghu77:fix/pms-250595-restore-concurrent-check

Conversation

@pppanghu77

@pppanghu77 pppanghu77 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Root Cause Analysis

The concurrent transfer check checkTransCanConnect() in handlerpcservice.cpp:141 was commented out (commit f19577d2, 2023-12-14), hardcoding statu to true. This disabled concurrent transfer detection, allowing file transfer (dde-cooperation-transfer) and cross-device cooperation (dde-cooperation) to simultaneously initiate transfers to the same device. Both transfers share the same RPC port (UNI_RPC_PORT_TRANS=51599) and the same IP-based executor (remoteservice.cpp:196-210), causing connection-level competition. When one transfer fails due to competition, offlineCancel cascades and clears all jobs (jobmanager.cpp:341-360), terminating the other transfer and showing a network error on the receiving device.

Fix

Uncomment the checkTransCanConnect() call at handlerpcservice.cpp:141, restoring concurrent transfer checking. The second concurrent transfer request is now rejected at the connection check stage instead of causing connection competition and cascading cancellation.

Change Safety Assessment

Code Safety

  • Risk Level: Medium
  • Target line is the product of historical fix commit f19577d2 ("fix: Unable to transfer files again after network disconnection"), which commented out checkTransCanConnect(). This change reverts that comment behavior — need to verify _cur_status resets correctly after network disconnection to avoid recurrence.
  • Only 1 caller affected (handlerpcservice.cpp:141 in handleRemoteLogin); function signature unchanged, no new public interface.

Business Impact Scope

  • File transfer concurrency control: Restores concurrent transfer detection when file transfer and cooperation apps send to the same device simultaneously
  • Affected caller: handlerpcservice.cpp:141 (handleRemoteLogin function)
  • Related PMS bugs (232941, 354299, 266935) checked — no conflict with this change

Verification Suggestion

  1. Test concurrent file transfer from two apps to the same device — second request should be rejected
  2. Test file transfer after network disconnection and reconnection — verify _cur_status resets correctly (regression of f19577d2 original issue)
  3. Verify normal single-app file transfer is unaffected

根因分析

handlerpcservice.cpp:141 的并发传输检查 checkTransCanConnect() 被注释禁用(commit f19577d2, 2023-12-14),statu 硬编码为 true。这导致文件投送和跨端协同两个应用同时向同一设备发起传输时请求均被接受。两个传输共享同一 RPC 端口(UNI_RPC_PORT_TRANS=51599)和同一 IP 的 executor 连接(remoteservice.cpp:196-210),造成连接级竞争。其中一个传输因竞争失败时,offlineCancel 级联清除所有任务(jobmanager.cpp:341-360),导致另一个传输也被终止,接收端显示网络错误。

修复方案

取消 handlerpcservice.cpp:141 的注释,恢复 checkTransCanConnect() 调用。第二个并发传输请求将在连接检查阶段被拒绝,而非导致连接竞争和级联取消。

改动安全评估

代码安全评估

  • 风险等级: 中风险
  • 目标行是历史修复 commit f19577d2("fix: Unable to transfer files again after network disconnection")注释掉 checkTransCanConnect() 的产物,本次改动恢复该调用——需验证断网后 _cur_status 正确重置以避免原问题复发
  • 仅 1 个调用者受影响(handlerpcservice.cpp:141 的 handleRemoteLogin 函数);函数签名不变,无新增公开接口

业务影响范围

  • 文件传输并发控制:恢复文件投送与跨端协同同时向同一设备发起传输时的并发检查
  • 涉及调用者:handlerpcservice.cpp:141(handleRemoteLogin 函数)
  • 关联 PMS bug(232941、354299、266935)已检查,与本次改动无冲突

验证建议

  1. 测试两个应用同时向同一设备投送文件——第二个请求应被拒绝
  2. 测试断网后重新发起文件传输——验证 _cur_status 正确重置(回归 f19577d2 原问题)
  3. 验证单一应用正常文件传输不受影响

PMS: BUG-250595

Summary by Sourcery

Bug Fixes:

  • Restore concurrent transfer validation so conflicting transfer requests to the same device are rejected before they cause connection contention and cascading cancellations.

1. Root cause: checkTransCanConnect() was commented out in
   handlerpcservice.cpp, disabling concurrent transfer detection
2. Fix: uncomment the call to restore concurrent transfer checking,
   preventing connection competition when two apps transfer to same device
3. Impact: second concurrent transfer request is now rejected instead of
   causing network error on receiving device

Log: fix concurrent transfer conflict between file transfer and cooperation

Influence:
1. Test concurrent file transfer from two apps to same device
2. Test file transfer after network disconnection and reconnection
3. Verify normal single-app file transfer still works

fix: 恢复 RPC 处理器中的并发传输检查

1. 根因:handlerpcservice.cpp 中 checkTransCanConnect() 被注释禁用,
   并发传输检查失效
2. 方案:取消注释恢复 checkTransCanConnect() 调用,防止两个应用
   同时向同一设备发起传输时连接竞争导致接收失败
3. 影响:第二个并发传输请求将被拒绝,而非导致接收端网络错误

Log: 修复文件投送与跨端协同同时投送文件到同一设备的接收错误

Influence:
1. 测试两个应用同时向同一设备投送文件
2. 测试断网后重新发起文件传输
3. 验证单一应用正常文件传输不受影响

PMS: BUG-250595
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: pppanghu77

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@pppanghu77
pppanghu77 marked this pull request as draft October 29, 2026 19:12
@sourcery-ai

sourcery-ai Bot commented Oct 29, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Re-enables connection-level concurrency control in handleRemoteLogin, ensuring a second transfer to the same device is rejected early instead of competing for the shared RPC connection and potentially triggering cascading cancellation. Review the status-reset behavior after network disconnection, along with concurrent-transfer rejection and normal single-transfer flows.

Sequence diagram for concurrent transfer rejection

sequenceDiagram
    participant TransferApp
    participant HandleRpcService
    participant Comshare
    participant SharedRpcConnection
    participant JobManager

    TransferApp->>HandleRpcService: handleRemoteLogin(info)
    HandleRpcService->>Comshare: checkTransCanConnect()
    Comshare-->>HandleRpcService: false
    HandleRpcService-->>TransferApp: result=false
    Note over SharedRpcConnection,JobManager: No competing connection or cascading cancellation
Loading

File-Level Changes

Change Details Files
Restore the concurrent transfer connection check before accepting remote login requests.
  • Replace the hardcoded successful status with a call to Comshare::instance()->checkTransCanConnect().
  • Reject the request with the existing connection-status error when another transfer is active, while preserving authentication handling.
src/plugins/daemon/core/service/rpc/handlerpcservice.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/plugins/daemon/core/service/rpc/handlerpcservice.cpp" line_range="141" />
<code_context>
             }
         }
-        bool statu = true;//Comshare::instance()->checkTransCanConnect();
+        bool statu = Comshare::instance()->checkTransCanConnect();
         if (!authOK || !statu) {
             lores.result = false;
</code_context>
<issue_to_address>
**Rejected logins still connect**

When authentication succeeds while `checkTransCanConnect()` returns false, `handleRemoteLogin` rejects the RPC login but passes `authOK` alone to `handleRpcLogin`; that handler creates a sender, updates connection state, and reports success to the local frontend, so the caller sees a successful connection for a rejected login.

Use `authOK && statu` as the admission result passed to `handleRpcLogin` and use it to prevent rejected logins from establishing connection state.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

}
}
bool statu = true;//Comshare::instance()->checkTransCanConnect();
bool statu = Comshare::instance()->checkTransCanConnect();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High · Rejected logins still connect

When authentication succeeds while checkTransCanConnect() returns false, handleRemoteLogin rejects the RPC login but passes authOK alone to handleRpcLogin; that handler creates a sender, updates connection state, and reports success to the local frontend, so the caller sees a successful connection for a rejected login.

Use authOK && statu as the admission result passed to handleRpcLogin and use it to prevent rejected logins from establishing connection state.

Prompt for AI agents
In `src/plugins/daemon/core/service/rpc/handlerpcservice.cpp` at line 141:

**Rejected logins still connect**

When authentication succeeds while `checkTransCanConnect()` returns false, `handleRemoteLogin` rejects the RPC login but passes `authOK` alone to `handleRpcLogin`; that handler creates a sender, updates connection state, and reports success to the local frontend, so the caller sees a successful connection for a rejected login.

Use `authOK && statu` as the admission result passed to `handleRpcLogin` and use it to prevent rejected logins from establishing connection state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants