cloudflare / cloudflare/quiche

Suggestion: separate tls context from config, and make quiche::accept take a &config

Open
#2,214 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
11.8k
Forks
1.1k
Avg merge
21h 9m
Merged PRs (30d)
6

Description

So in rust mutable references are exclusive.

Because accepting a connection takes a &mut config, that means you can't quiche::accept in multiple threads without mutexing your config.

There's the obvious question of "wait why does the config need to be mutated? Config is generally understood to be a read only abstract concept."

I looked at the source code reveals the answer:

```rust
fn new(
scid: &ConnectionId, odcid: Option<&ConnectionId>, local: SocketAddr,
peer: SocketAddr, config: &mut Config, is_server: bool,
) -> Result> {
let tls = config.tls_ctx.new_handshake()?;
Connection::with_tls(scid, odcid, local, peer, config, tls, is_server)
}

fn with_tls(
scid: &ConnectionId, odcid: Option<&ConnectionId>, local: SocketAddr,
peer: SocketAddr, config: &Config, tls: tls::Handshake, is_server: bool,
) -> Result> {
```

The with_tls function takes a &Config not a &mut Config. We can see where Config is required to be mutated, it is exclusively the tls_ctx portion.

Please please separate out the config, from the tls context RNG. Those are two completely separate things. Then for concurrency the tls context can be cloned or mutexed or whatever you want, without poisoning the entire config.

Contributor guide

Open the contributing guide

Research direction

Start at quiche::accept and trace how Config, tls_ctx, Connection::new, and Connection::with_tls are used. Determine the API and ownership changes needed so accepting connections does not require a mutable Config, while preserving TLS-handshake behavior. Done means the revised separation supports concurrent accepts and the affected callers compile.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.