fix: prevent zombie client re-insertion after disconnectClient#88
Conversation
After sendResponse() calls disconnectClient(fd:) to drop a stalled client, readFromClient() would write the ClientState copy back into the clients dictionary at line 178, re-inserting a zombie entry with a cancelled DispatchSource. Now checks clients[fd] after each sendResponse() and bails if the client was removed. Also: write() returning 0 now properly disconnects instead of silently breaking the write loop. Found by code review agent on PR #87. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Summary
sendResponse()callsdisconnectClient(fd:)to drop a stalled client,readFromClient()would write theClientStatecopy back into theclientsdictionary, re-inserting a zombie entry with a cancelled DispatchSourceclients[fd]after eachsendResponse()and bails if the client was removedwrite()returning 0 now properly disconnects instead of silently breaking the write loopFound by code review agent during PR #87 review.
Test plan
swift build -c releaseclean🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com