Skip to content

fix(http1): fix rare missed write wakeup on connections - #1153

Merged
0x676e67 merged 1 commit into
mainfrom
fix
Apr 23, 2026
Merged

0x676e67 merged 1 commit into
mainfrom
fix

Conversation

@0x676e67

@0x676e67 0x676e67 commented Apr 22, 2026 •

Copy link
Copy Markdown
Owner

backport: hyperium/hyper#3988

Summary by CodeRabbit

Release Notes

  • Refactor

    • Optimized internal polling logic to improve efficiency and reduce unnecessary processing cycles.
    • Enhanced method inlining for improved performance.
  • Tests

    • Reorganized test utilities for better maintainability.

@coderabbitai

coderabbitai Bot commented Apr 22, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Added #[inline] hints to three HTTP1 connection methods, refactored the dispatcher's poll loop to capture write readiness states and prevent hot-looping via a new can_write_again() predicate, and relocated a test-only flush helper method to test-scoped implementation code.

Changes

Cohort / File(s) Summary
Inline Optimization
src/client/core/proto/http1/conn.rs
Added #[inline] attributes to can_write_head(), can_write_body(), and on_upgrade() methods without altering logic.
Polling Logic Refinement
src/client/core/proto/http1/dispatch.rs
Modified Dispatcher::poll_loop() to capture readiness from poll_write and poll_flush, introduced can_write_again() predicate, and added specialized handling to prevent hot-looping when write is pending but flush remains perpetually ready.
Test Helper Relocation
src/client/core/proto/http1/io.rs
Moved flush() helper method from production-guarded inherent impl to test-only impl block, preserving test functionality while removing it from non-test builds.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Three methods now inline, swift and fleet,
Poll loops dance with readiness—no heat!
Flush hops to tests where it belongs so right,
Smooth HTTP flows, optimized and bright! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(http1): fix rare missed write wakeup on connections' directly describes the main change: fixing a missed write wakeup issue in HTTP/1 connections. It aligns with the PR objectives of backporting a wakeup fix and the file-level changes in dispatch.rs that optimize write polling logic.
Docstring Coverage ✅ Passed Docstring coverage is 91.67% which is sufficient. The required threshold is 80.00%.
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.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/client/core/proto/http1/dispatch.rs`:
- Around line 435-438: can_write_again currently returns true whenever body_rx
is Some(), causing poll_loop to keep self-waking during shutdown; update
can_write_again in src/client/core/proto/http1/dispatch.rs to also check that
the dispatcher is not closing (e.g., return self.body_rx.is_some() &&
!self.is_closing() or equivalent check against the closing/closed flag used by
close()), so poll_write won't report writable when close() has begun and
poll_loop can reach is_done().
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7c611a20-24d6-42b1-9ddd-3d404e469645

📥 Commits

Reviewing files that changed from the base of the PR and between a683233 and 88b5a3f.

📒 Files selected for processing (3)
  • src/client/core/proto/http1/conn.rs
  • src/client/core/proto/http1/dispatch.rs
  • src/client/core/proto/http1/io.rs

Comment thread src/client/core/proto/http1/dispatch.rs Resolved
@0x676e67
0x676e67 merged commit ccf70e4 into main Apr 23, 2026
24 checks passed
@0x676e67
0x676e67 deleted the fix branch April 23, 2026 19:50

This branch was previously deployed

4 inactive deployments
Windows — 88b5a3ff Deployed Apr 22, 2026 by 0x676e67 via Build (Windows) #1803
Linux — 88b5a3ff Deployed Apr 22, 2026 by 0x676e67 via Build (Linux) #1803
macOS — 88b5a3ff Deployed Apr 22, 2026 by 0x676e67 via Build (macOS) #1803
Android — 88b5a3ff Deployed Apr 22, 2026 by 0x676e67 via Build (Android) #1803
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