Skip to content

Stop send worker after send failure#660

Merged
AngeloTadeucci merged 1 commit intomasterfrom
dev
Feb 24, 2026
Merged

Stop send worker after send failure#660
AngeloTadeucci merged 1 commit intomasterfrom
dev

Conversation

@AngeloTadeucci
Copy link
Copy Markdown
Collaborator

@AngeloTadeucci AngeloTadeucci commented Feb 24, 2026

Add a volatile sendFailed flag to Session to record the first SendRaw failure and prevent the send queue from continuing to drain after a failed write. sendFailed is set on write timeout and on IO/Socket/other write exceptions. SendWorker now checks sendFailed (in addition to disposed) and breaks out of its loop when set. This avoids continuing to process/encrypt queued packets after the connection is known-bad and reduces wasted work or potential blocking.

Summary by CodeRabbit

Bug Fixes

  • Enhanced network connection reliability by improving error handling during transmission failures
  • Strengthened disconnect behavior to prevent repeated send attempts after a failure is detected

Add a volatile sendFailed flag to Session to record the first SendRaw failure and prevent the send queue from continuing to drain after a failed write. sendFailed is set on write timeout and on IO/Socket/other write exceptions. SendWorker now checks sendFailed (in addition to disposed) and breaks out of its loop when set. This avoids continuing to process/encrypt queued packets after the connection is known-bad and reduces wasted work or potential blocking.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0d7c586 and 1ca5611.

📒 Files selected for processing (1)
  • Maple2.Server.Core/Network/Session.cs

📝 Walkthrough

Walkthrough

The changes add a volatile sendFailed flag to track the first SendRaw failure and prevent further queue draining. When SendRaw encounters a timeout or exception (IOException, SocketException, or general), it sets the flag, logs appropriately, and initiates disconnect. SendWorker now checks this flag to stop processing the send queue after failure.

Changes

Cohort / File(s) Summary
Send Pipeline Error Handling
Maple2.Server.Core/Network/Session.cs
Introduces volatile sendFailed flag to track send failures; modifies SendRaw to set flag and disconnect on timeout and IO/socket exceptions; updates SendWorker drain loop to stop processing when flag is set.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested reviewers

  • Zintixx

Poem

🐰 A flag so volatile, marking when sends go wrong,
No more draining queues when failures come along,
Timeouts and exceptions caught with grace,
The send loop stops and exits the race! 🚫

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and concisely describes the main change: introducing a mechanism to stop the send worker after a send failure, which is exactly what the PR does by adding a sendFailed flag and updating SendWorker to break when failures occur.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev

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

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

@AngeloTadeucci AngeloTadeucci merged commit 6590f86 into master Feb 24, 2026
3 checks passed
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.

1 participant