Skip to content

fix(volo-http): return reusable HTTP/1 connections from the driver - #663

Open
junliurs wants to merge 1 commit into
mainfrom
fix/http1-managed-connection-reuse
Open

fix(volo-http): return reusable HTTP/1 connections from the driver#663
junliurs wants to merge 1 commit into
mainfrom
fix/http1-managed-connection-reuse

Conversation

@junliurs

Copy link
Copy Markdown
Contributor

Move the HTTP/1 sender between the pool, request future, and connection driver through a return channel. Reinsert the connection only after Hyper reports it ready, while preserving cancellation safety and the existing response body fast path.

Motivation

Solution

@junliurs
junliurs requested review from Joshuahoky and shenyj3 August 12, 2026 09:13
@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.48534% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.90%. Comparing base (faf5d99) to head (5cc45b3).

Files with missing lines Patch % Lines
volo-http/src/client/transport/protocol.rs 92.70% 20 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #663      +/-   ##
==========================================
+ Coverage   50.23%   50.90%   +0.66%     
==========================================
  Files         163      163              
  Lines       20588    20891     +303     
==========================================
+ Hits        10342    10634     +292     
- Misses      10246    10257      +11     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

B::Error: Into<BoxError> + 'static,
{
#[cfg(feature = "http1")]
let key = (peer.scheme.clone(), peer.address.clone());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When __tls is enabled, PeerInfo::name contains the TLS SNI/service name, but PoolKey only contains (Scheme, Address). This means two HTTPS connections to the same IP but with different SNI names can collide in the connection pool and a connection established for one hostname may be reused for another. The PoolKey should include the TLS server name:

#[cfg(feature = "__tls")]
type PoolKey = (Scheme, Address, Option<faststr::FastStr>);

#[cfg(not(feature = "__tls"))]
type PoolKey = (Scheme, Address);


// 5. The response body or request flush is still in progress. Wait for
// the next connection wakeup.
if !returned.http_sender.is_ready() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这里是不是可以直接用 poll_ready?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

可以

@junliurs
junliurs force-pushed the fix/http1-managed-connection-reuse branch 2 times, most recently from 229c223 to 7f468e0 Compare August 13, 2026 10:19
Move the HTTP/1 sender between the pool, request future, and connection
driver through a return channel. Reinsert the connection only after
Hyper reports it ready, while preserving cancellation safety and the
existing response body fast path.
@junliurs
junliurs force-pushed the fix/http1-managed-connection-reuse branch from 7f468e0 to 5cc45b3 Compare August 13, 2026 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants