cloudflare / cloudflare/pingora

Reusable virtual L4 streams

Open
#883 0 comments 0 reactions 1 assignee Claimed by @drcaramelsyrup View on GitHub
enhancement
Dominant language
Rust
Stars
27.4k
Forks
1.7k
Avg merge
6h 22m
Merged PRs (30d)
3

Description

## What is the problem your feature solves, or the need it fulfills?

Virtual L4 streams introduced in https://github.com/cloudflare/pingora/pull/695 does not have a real fd and -1 is returned by default (and 0 in windows respectively):

https://github.com/cloudflare/pingora/blob/faac65b0c2a0bfdbfdc5f13a1591f53f3c15321a/pingora-core/src/protocols/l4/stream.rs#L137-L146

but the reuse of an established stream needs to pass the following tests before the stream can be actually reused:

https://github.com/cloudflare/pingora/blob/faac65b0c2a0bfdbfdc5f13a1591f53f3c15321a/pingora-core/src/connectors/mod.rs#L214-L219

https://github.com/cloudflare/pingora/blob/faac65b0c2a0bfdbfdc5f13a1591f53f3c15321a/pingora-core/src/protocols/mod.rs#L315-L341

and the `getpeername` syscall will always error for the default -1 fd. So currently virtual L4 streams can never be reused, even if they were added to connection pool.

## Describe the solution you'd like

Allow virtual L4 streams to have dummy `SocketAddr` and update the fd check so the streams can pass the test if they have the same `SocketAddr` as the peer.

## Describe alternatives you've considered

Maybe the reuse check of the streams can be rewritten into a dedicated trait for `RawStream`. It can also make the reuse checks easier to be understood.

Also, not reusing virtual streams won't break simple http1.1 servers. Just avoid virtual L4 streams when reusing streams is required.

## Additional context

No

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.