Skip to content

Networking: Drop a closed sender's asset receivers - #328

Merged
Segfaultd merged 1 commit into
developfrom
networking/asset-transfer-drops-closed-receivers
Oct 15, 2026
Merged

Segfaultd merged 1 commit into
developfrom
networking/asset-transfer-drops-closed-receivers

Conversation

@Segfaultd

@Segfaultd Segfaultd commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Part of #315 (the "Related" item).

AssetFileTransfer::OnClosedConnection overrode FileListTransfer::OnClosedConnection without calling it. When a connection dropped, RemoveReceiver() never ran, so the receivers and their handlers stayed alive until Shutdown() cleared them. Its callback is never set, so the override's only effect was to block that cleanup. It now calls the base first.

Tests

New asset_transfer module: a receiver set up for a sender is dropped and dereferenced once when that sender's connection closes, and other senders' receivers are kept. The first test fails without the fix. FrameworkTests: 662/662.

The crash in #315 itself is fixed in MafiaNet (MafiaHub/MafiaNet#73) and reaches the Framework with the next MafiaNet pin bump.

Summary by CodeRabbit

  • Bug Fixes
    • Asset transfers now complete base-level cleanup when a connection closes. This keeps receive-handler state in sync with the connection, including when another sender’s connection remains open.
  • Tests
    • Added coverage for receive-handler behavior when asset-transfer connections close.

AssetFileTransfer overrode OnClosedConnection without calling
FileListTransfer's, so a dropped connection never removed its
receivers: they and their handlers lived on until the peer shut
down. The override now runs the base first.
@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dd445592-f8e6-436c-9f4d-c8e3c487b8e2
📥 Commits

Reviewing files that changed from the base of the PR and between e900160 and 19f6d51.

📒 Files selected for processing: 3
  • code/framework/src/networking/network_client.cpp
  • code/tests/framework_ut.cpp
  • code/tests/modules/asset_transfer_ut.h

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

AssetFileTransfer::OnClosedConnection now calls the base implementation before its callback. New unit tests check handler behavior when the matching sender’s connection closes and when another sender’s connection closes.

Changes

Asset transfer cleanup

Layer / File(s) Summary
Connection cleanup and tests
code/framework/src/networking/network_client.cpp, code/tests/modules/asset_transfer_ut.h, code/tests/framework_ut.cpp
The close handler delegates to the base implementation before invoking its callback. Unit tests check handler deactivation and dereference counts for matching and non-matching senders. The test runner registers the asset-transfer tests.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: zpl-zak

Merge Risk: ⚪ Minimal · up to 19f6d

Connection closure now performs the base receiver cleanup before invoking the callback. The pinned implementation supports that cleanup path, so no material merge-blocking risk is apparent.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: removing asset receivers when a sender connection closes.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks the closing door,
The base call tidies up the floor.
The matching handler rests at ease,
The other waits, untouched by these.
Tests count each hop beneath the trees.

Comment @coderabbitai help to get the list of available commands.

@Segfaultd
Segfaultd merged commit 762a6dc into develop Oct 15, 2026
6 checks passed
@Segfaultd
Segfaultd deleted the networking/asset-transfer-drops-closed-receivers branch October 15, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants