Repository navigation
Net: a seek that cancels an HTTP/2 transfer dials a fresh connection - #1289
Conversation
The media transport never sets CURLOPT_HTTP_VERSION, so a firmware libcurl of 7.62 or later negotiates HTTP/2 with a server that offers it (webOS 10.3's 7.82 does). A seek removes the unfinished transfer and attaches a fresh easy handle to the same multi. On HTTP/1.1 libcurl closes a connection whose transfer was removed unfinished, so the next request dials; on HTTP/2 it keeps the connection (a premature multi_done does not close a multiplexed connection, 7.82 and 8.x alike) and hands it to the next request, whose bytes then wait behind everything the server had already queued for the cancelled stream in its kernel send buffer: 2.6-3.6 MB measured with ss and a pcap, time-to-new-data about that over the link rate, Traefik and nginx alike. On a television, paired medians against HTTP/1.1 over 8 rounds: the firmware curl's seek-to-resume was 3.14x slower at 8 Mbit/s and 2.22x at 20 Mbit/s; with CURLOPT_FRESH_CONNECT on the seek's requests, 1.00x [0.79, 1.02] and 1.38x [1.01, 1.89], and 12-17% less client CPU per MB. stop() now reads CURLINFO_HTTP_VERSION of the handle it detaches (falling back to the version the source's last response came over, for a handle detached before its own response line) and, when the transfer was unfinished and on HTTP/2, records that origin as busy. The next request chain consumes the fact and sets CURLOPT_FRESH_CONNECT on every attempt to that origin (a redirect's return to it, a TLS ladder rung); a chain that fails puts the fact back, since the busy connection is still cached for the seek after. The decision is two pure functions, left_backlog and dial_fresh. Only HTTP/2: HTTP/1.1 already dials (libcurl closed the connection), so the option would change nothing; HTTP/3 cancels per stream, with no shared byte stream to queue behind; a finished transfer queued nothing, and reusing its connection stays the right call (HLS segments). CURLOPT_FORBID_REUSE on the abandoned handle is NOT added. It would close the busy connection at removal, which libcurl's source shows works the same way in 7.82 and 8.23 (multi_done reads reuse_forbid off the removed handle), and it would stop the old backlog competing for the link and keep it out of libcurl's cache. But it has to be set on a transfer still in progress, which curl_easy_setopt's contract calls undefined, and nothing measured it: the measured fix set FRESH_CONNECT alone and reached parity at 8 Mbit/s. The busy connection is left to libcurl's cache, which bounds it (7.82 closes the oldest cached connection once the cache holds more than four per easy handle). One residual is known: a later request that does not replace an unfinished HTTP/2 transfer (a seek after a transfer finished, the next HLS segment) may still be handed the old connection, since 7.82 picks the oldest idle match. The residual 1.38x at 20 Mbit/s may be that backlog still arriving on the old connection; measuring it is the condition for adding the close. Compatibility: no new symbol. CURLOPT_FRESH_CONNECT (74) is in curl.h since 7.7 and still in 8.23 (net::keypin already sets it on the control plane); CURLINFO_HTTP_VERSION (LONG + 46) since 7.50.0, below the 7.53.1 floor. Both go through the already-bound setopt/getinfo wrappers. A refused setopt is logged and the request reuses the connection, as today; a refused getinfo reads as an unknown version, which never dials fresh. On 7.53 and 7.61 the default is HTTP/1.1, so the rule does not fire there. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: fraygox <[email protected]>
Review follow-ups to the previous commit.
The busy fact is no longer consumed by the request that dialled past
it. libcurl hands a request the OLDEST matching idle connection (7.82
appends each returned connection to its host bundle and takes the first
match, url.c ConnectionExists; 8.23 the same), so after one fresh dial
the next request that did not replace an unfinished HTTP/2 transfer was
handed the busy connection again: the HLS segment after the one that
followed a cancel, or the MKV open's seek back after a Cues read to the
end. Now every origin a detached unfinished HTTP/2 transfer left busy
stays in CurlSource::busy, and every later request to it sets
CURLOPT_FRESH_CONNECT, until the multi is rebuilt (an empty cache).
Why this over a counted window ("until N requests have dialled fresh"):
the busy connection stays choosable until libcurl evicts it, and when
that happens depends on the cache limit (7.82: more than four cached
connections per easy handle) and on libcurl's version, so any N is a
guess at libcurl internals. The cost of staying fresh is one TCP+TLS
handshake per request to that origin: for progressive playback, where
requests are seeks, that is exactly HTTP/1.1's per-seek dial, the
measured baseline; for HLS it is one handshake per segment after the
first cancel, against seconds of a 2.6-3.6 MB backlog at link rate each
time the busy connection is handed out. Closing the busy connection
would end both costs, but needs CURLOPT_FORBID_REUSE on a transfer in
progress (undefined per curl_easy_setopt) and is still unmeasured.
- Origins are compared as libcurl dials them (target_of, the redirect
code's reading), not origin::split's tolerant one, which reads a URL
with no port as :32400: https://cdn/a and https://cdn:443/b are one
connection, https://h/a and https://h:32400/b are two.
- A key-mode handle records nothing: keypin::apply sets FRESH_CONNECT
and FORBID_REUSE on this plane's key-mode handles too, so its
connection closes with it and the new setopt is a no-op there. The
constant's doc said only that the control plane sets it.
- The multi-rebuild path empties the list, so the fresh-connection log
line never claims a busy connection in an empty cache; the line now
prints the actual range (bounded probes included).
- finish_redirect_body's doc said a connection removed mid-body is
closed; on HTTP/2 it stays cached, and stop() records it.
- The record lives in a bounded list (MAX_BUSY_ORIGINS, 8, registered
in ci/list-caps.ini as work): past it the oldest origin is forgotten,
costing one possible reuse of a busy connection.
- The chain plumbing of the previous commit (run_chain, the backlog
parameter, restore-on-failure) is gone: start_attempt reads the list.
Tests: dial_fresh over conn_origin (443 vs 32400, case, scheme);
note_busy dedup and bound; every later seek to a busy origin dials
(accept count 3 on the third request); and the stop() wiring through
real libcurl: a reopen stopped before its response line falls back to
the source's last version, records the origin, the next reopen logs a
fresh connection, and the failed chain keeps the record.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: fraygox <[email protected]>
GLinnik21
left a comment
There was a problem hiding this comment.
Eight inline findings, most severe first: three about when an origin is recorded busy (the per-source version fallback, a failed transfer counted as finished, a never-attached handle), two about how long it stays recorded (for the multi's life; FIFO eviction), one on test coverage, and two cleanups.
These come from reading the diff against the surrounding curlio.rs; nothing was run, and the claims about libcurl's connection handling for a failed HTTP/2 transfer are from memory of its source rather than checked against the 7.82 firmware build.
Generated by Claude Code
| // What this transfer leaves on its connection, read while the handle can still answer. | ||
| // A transfer detached before its response line has no version of its own yet; it rode | ||
| // the connection the source's last response came over, or a new one to the same host. | ||
| let version = match http_version(self.easy) { |
There was a problem hiding this comment.
The version fallback is per source, not per origin. A handle detached before its own response line takes self.http_version, which is the last response from any origin, and it is used even when the handle never got a connection.
Chain PMS (HTTP/1.1) → 302 → CDN (HTTP/2): the CDN response leaves http_version = 3. The next seek replays the chain and is stopped (or deadlined) before the PMS hop answers, possibly still in DNS/connect. The PMS origin, which has no HTTP/2 connection at all, is recorded busy and every later request to it dials fresh.
The inverse also happens: once the PMS hop has answered (http_version = 2), a CDN hop cancelled before its response line on the reused h2 connection is not recorded, so the backlog this PR targets is reused.
Keeping the last version per origin (beside busy) would fix both directions.
Generated by Claude Code
There was a problem hiding this comment.
Fixed in 56e5b45: the fallback is now the last version of that handle's origin (ConnLedger), so neither direction of the PMS → CDN case misfires. Details in point 1 of #1289 (comment).
| // stream's queued bytes (`left_backlog`, `busy`): dial past it. Not `require_setopt!`: | ||
| // a libcurl that refuses reuses the connection, which is slower and nothing worse. A | ||
| // key-mode handle already dials fresh (`keypin::apply`), so this changes nothing there. | ||
| if dial_fresh(&self.busy, conn_origin(self.hop_url.to_str().unwrap_or_default()).as_ref()) { |
There was a problem hiding this comment.
A busy origin is never forgotten until the multi is rebuilt. After one cancelled HTTP/2 transfer, every later request to that origin does a full TCP+TLS dial, long after libcurl has evicted the busy connection: the cache holds four, and the busy one is the oldest, so it goes first after about four fresh dials.
For HLS over HTTP/2 (reopen_until shares one multi precisely to keep connections) one mid-segment seek means every segment and playlist refresh for the rest of playback pays a handshake on the TV's CPU and writes one curlio: fresh connection event-log line. An unfinished 3xx body on HTTP/2 likewise pins the redirecting origin fresh for every later seek.
The commit message argues against a counted window because N guesses at libcurl internals; the cost of the alternative chosen here is unbounded for HLS, so it may be worth bounding by the cache size the same message already cites, or at least logging the line once per origin.
Generated by Claude Code
There was a problem hiding this comment.
Fixed in 56e5b45: a busy mark now lasts BUSY_FOR = 120 s (libcurl's 118 s CURLOPT_MAXAGE_CONN default in both 7.82 and 8.23) instead of the multi's life, and the log line is once per mark. Point 2 of #1289 (comment) has why it's a time window and not a dial count.
| }; | ||
| // A key-mode handle was set `CURLOPT_FORBID_REUSE` (`keypin::apply`): its connection | ||
| // closes with it, whatever it left queued. | ||
| if left_backlog(version, self.done, self.key_pin.is_some()) { |
There was a problem hiding this comment.
A failed transfer is treated as finished. self.done is also true when the transfer ended in failure (reap sets done with failed). A failed HTTP/2 transfer only resets its stream and libcurl keeps the multiplexed connection, so it can leave a backlog that is not recorded here.
Scenario: an h2 body transfer dies mid-body (low-speed timeout rc=28, stream error rc=92); libavformat heals with a seek, stop() sees finished = true and records nothing, and the reopen is handed the same connection with the dead stream's queued bytes ahead of it. That is the slow seek this PR fixes, on the heal path.
Passing self.done && !self.failed would cover it. I have not confirmed the libcurl side on a 7.82 build.
Generated by Claude Code
There was a problem hiding this comment.
Fixed in 56e5b45: done && !failed, checked against 7.82's streamclose path. Point 3 of #1289 (comment).
| 0 => self.http_version, | ||
| v => v, | ||
| }; | ||
| // A key-mode handle was set `CURLOPT_FORBID_REUSE` (`keypin::apply`): its connection |
There was a problem hiding this comment.
stop() can judge a handle that never entered the multi, with the previous attempt's key_pin. start_attempt assigns self.easy before self.key_pin, and the Some(_) => return Err(OpenErr::Local) arm of the range match (line 1239) returns in between.
A bounded-range start with range_end < at therefore leaves a never-attached handle; the caller's stop() sees done = false, version 0 falling back to the source's last (HTTP/2) version, and the previous attempt's key_pin. After a strict previous attempt it records the hop origin busy for a request that was never sent.
Narrow, but cheap to close: compute the range before self.easy = easy, or clear key_pin in retire_attempt.
Generated by Claude Code
There was a problem hiding this comment.
Fixed in 56e5b45 with an attached flag set after curl_multi_add_handle, which covers every early return, not just this one. It also skips handles that failed before connecting. Point 4 of #1289 (comment).
| return; | ||
| } | ||
| if busy.len() >= MAX_BUSY_ORIGINS { | ||
| busy.remove(0); |
There was a problem hiding this comment.
FIFO eviction re-enables reuse of a busy connection. The oldest origin is dropped at MAX_BUSY_ORIGINS whether or not its busy connection is still cached, and an origin noted again is not refreshed.
A server that redirects each seek to a different CDN edge hostname (presigned URLs) can pass eight busy origins over a scrubbing session. The first ones go first, including the PMS origin that every chain replay hits, and its next request is handed the busy HTTP/2 connection again.
Moving a re-noted origin to the back (LRU) would keep the one that matters.
Generated by Claude Code
There was a problem hiding this comment.
Fixed in 56e5b45: eviction is now LRU, and the test checks before the server is re-noted, so it fails on FIFO. Point 5 of #1289 (comment).
| /// The loopback server speaks HTTP/1.1, so the busy HTTP/2 connection is stood in for by | ||
| /// recording its origin; each transfer is read to its end so libcurl keeps its connection | ||
| /// cached, which is what a reusing seek would take. Every later seek must dial: libcurl hands | ||
| /// a request the oldest matching idle connection, which would be the busy one. |
There was a problem hiding this comment.
No test drives the rule through a real HTTP/2 response. This test plants the origin in src.busy by hand, and the stop() test below overwrites src.http_version. The CURLINFO_HTTP_VERSION == 3 reading, and the assumption that a detached mid-body h2 handle reports its version, are unverified on host.
If a firmware libcurl answers differently for a mid-body handle, stop() never records an origin and the fix is inert on the TV while every host test stays green. A device log showing the curlio: fresh connection line after a seek against an h2 server would close this.
Generated by Claude Code
There was a problem hiding this comment.
Device run on a webOS 10.3 set (firmware libcurl 7.82, HTTP/2 default) through Traefik: the curlio: fresh connection line on a resume and on five seeks, all reopens ok. Log in point 6 of #1289 (comment). There's still no end-to-end HTTP/2 host test.
| /// origin is still busy with a cancelled HTTP/2 stream; a libcurl | ||
| /// that refuses it reuses the connection, which is today's behaviour, so the refusal is logged, never | ||
| /// fatal. | ||
| const CURLOPT_FRESH_CONNECT: c_int = 74; |
There was a problem hiding this comment.
Duplicate constant. CURLOPT_FRESH_CONNECT (74) is already declared at net.rs:135 beside CURLOPT_FORBID_REUSE for keypin::apply. Making that one pub(crate) and using it here, as this file already does for CURLOPT_CAINFO, avoids two copies with separately maintained doc comments.
Generated by Claude Code
There was a problem hiding this comment.
Fixed in 56e5b45: it uses net.rs's constant, now pub(crate), with its doc updated. Point 7 of #1289 (comment).
| // A key-mode handle was set `CURLOPT_FORBID_REUSE` (`keypin::apply`): its connection | ||
| // closes with it, whatever it left queued. | ||
| if left_backlog(version, self.done, self.key_pin.is_some()) { | ||
| if let Some(o) = conn_origin(self.hop_url.to_str().unwrap_or_default()) { |
There was a problem hiding this comment.
The hop origin is re-parsed from the URL. conn_origin(self.hop_url.to_str().unwrap_or_default()) appears here and in start_attempt, going CString → str → target_of → resolve_location each time, with a silent empty-string fallback. A redirect Hop is built from a Target that already holds the parsed Origin; storing it beside hop_url removes the parse, the helper and the fallback.
Generated by Claude Code
There was a problem hiding this comment.
Fixed in 56e5b45: Hop carries the Origin from its Target (parsed once for the first hop); conn_origin is gone. Point 8 of #1289 (comment).
…handles Review of plxnative#1289: - The version a handle detached before its response line falls back to is its ORIGIN's last, not the source's: a chain from an HTTP/1.1 server to an HTTP/2 CDN no longer marks the server busy, nor misses the CDN. - A failed transfer counts as unfinished (done && !failed). In 7.82 the error paths call streamclose, which for an h2 (PROTOPT_STREAM) handler closes the stream and keeps the connection. - stop() judges only a handle that entered the multi (an `attached` flag set after curl_multi_add_handle), closing every early return in start_attempt, not only the bounded-range one; and not one that failed before it had a connection (rc 5, 6, 7, 35, 51, 60, 90), such as a refused connect or the strict attempt that retries in key mode. Read from the CURLcode, not CURLINFO_REQUEST_SIZE, which reads 0 even for a finished transfer on 8.7.1. - A busy mark lasts BUSY_FOR (120 s), not the multi's life: libcurl refuses an idle connection older than CURLOPT_MAXAGE_CONN (118 s default in 7.82 and 8.23), and the busy one is idle from its cancel. A dial count was not used: the cache limit is 4 per attached handle in 7.82 and 2 (idle >= 1 s) in 8.23. The fresh-dial line is logged once per mark. - Origins are kept least recently used first (MAX_LEDGER_ORIGINS = 8), so the server every chain replay starts from outlives rotating CDN edges. - CURLOPT_FRESH_CONNECT is net.rs's, now pub(crate); the hop's Origin is carried on Hop from its Target instead of re-parsed from the URL. Signed-off-by: fraygox <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks for the review. All eight are addressed in CI first. The two
The decision in |
|
Thanks! |
…busy mark Review of the main merge (Fable 5.2): - A source scan pins every libcurl dynlib! table outside net.rs (curlio, connect_only) and requires each to bind from net::bundled_curl() with load_from, so a revert of the merge's connect_only fix, or a new table bound from the system candidates, fails a host test. Nothing else can catch it: the host tests never bind the bundle. - plxnative#1289's busy mark met this branch's Alt-Svc: after a cancelled h2 transfer, an origin that moves to HTTP/3 kept dialling fresh QUIC connections for the whole 120 s window. ConnLedger::saw_version now ends the mark on an HTTP/3 answer (Alt-Svc routes the origin to QUIC, which never matches the busy TCP connection); an HTTP/1.1 answer still keeps it, since it can come from a fresh connection while the busy one is cached. - Docs that named only curlio's multi table as reading bundled_curl now name connect_only's too. Signed-off-by: fraygox <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tion With the bundled curl, a seek still took 1.7x as long as over HTTP/1.1 under plxnative#1289's rule (254 against 148 ms to resume, 8 Mbit/s, ~10 ms from Traefik, webOS 5.6.2 set; that set's firmware 7.61 asked for HTTP/2 under the same rule: 152 ms). Every request after a seek already dials fresh, but up to four abandoned connections stayed open beside the new one. A bundled media transfer to an origin last heard over HTTP/2, or not yet heard from while Alt-Svc cannot route it to QUIC, is now set CURLOPT_FORBID_REUSE before it enters the multi (setting it on a transfer in progress is undefined per curl_easy_setopt), so its connection closes with it: 136 ms in the same runs, 0.92x HTTP/1.1. stop() then records no busy connection for it. Firmware libcurls, HTTP/1.1, HTTP/3, an unknown origin with Alt-Svc on, and a source reopened for HLS (its playlist and segment requests finish cleanly, and plxnative#1289's mark still covers its cancels) are unchanged. A redirect hop the rule chose closes its connection too, so its next hop dials its own. Signed-off-by: fraygox <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
A seek removes the unfinished transfer and adds a new easy handle to the same multi. libcurl closes that connection on HTTP/1.1 but keeps an HTTP/2 one, so the new request queued behind the bytes the server had already written for the cancelled stream: on an 8 Mbit/s link the seek waited about 3.5 s for its first byte instead of about 0.1 s. A source now remembers, per origin, the last HTTP version and whether a detached unfinished or failed HTTP/2 transfer left its connection busy, and sets CURLOPT_FRESH_CONNECT on requests to that origin for the next two minutes (libcurl itself stops offering an idle connection after 118 s). HTTP/1.1, HTTP/3, finished transfers, handles that never connected and key-mode handles are left alone. Ported from upstream b1bbe75 (Net: a seek that cancels an HTTP/2 transfer dials a fresh connection (plxnative#1289)).
Problem
The media transport never sets
CURLOPT_HTTP_VERSION, so a firmware libcurl of 7.62 or later negotiatesHTTP/2 with a server that offers it (the webOS 10.3 set's 7.82 does; the bundled curl in #1270 does too).
A seek removes the unfinished transfer and attaches a fresh easy handle to the same multi.
multi_donedoes not close amultiplexed connection in 7.82 or 8.x) and hands it to the next request. That request's bytes then wait
behind everything the server had already queued for the cancelled stream.
Mechanism, measured in a reproduction (not on the television): Traefik v3 in front of an nginx origin, a client about 12 ms away, a link paced to about 94 Mbit/s, with
ss -tinsampled in Traefik's network namespace and a packet capture. Each row covers the five seeks that reused the connection:tcp_wmemmax 32 MiB)tcp_wmemmax 1 MiBtcp_notsent_lowat=16384The same reproduction with nginx serving HTTP/2 directly (no Traefik) gave seek to resume of 291 ms on HTTP/2 against 86 ms on HTTP/1.1, and 71 ms on HTTP/2 with
tcp_notsent_lowatset.Fix
CurlSource::stop()judges the handle it detaches, only if it entered the multi (anattachedflag set after
curl_multi_add_handlesucceeds) and did not fail before it had a connection (aCURLcodeof 5, 6, 7, 35, 51, 60 or 90: a refused connect, a failed TLS handshake, the strictattempt that retries in key mode). It reads
CURLINFO_HTTP_VERSION, or, for a handledetached before its own response line, the last version that handle's origin answered on
(
ConnLedger, kept per origin: a chain from an HTTP/1.1 server to an HTTP/2 CDN lends neither itsversion). If the transfer was on HTTP/2 and did not finish cleanly (unfinished, or failed:
done && !failed), it marks that origin busy. Every request this source makes to a busy origin for the nextBUSY_FOR= 120 s setsCURLOPT_FRESH_CONNECT; the first one logscurlio: fresh connection …, the rest are silent. A new mark restarts the window; a rebuilt multiclears the marks.
matching idle connection, so after one fresh dial the busy connection would be handed to the next
request that did not dial fresh. It stops being offered once it has been idle longer than
CURLOPT_MAXAGE_CONN: 118 s by default in 7.82 (set->maxage_conn = 118) and 8.23(
conn_max_idle_ms = 118 * 1000), and the busy connection is idle from its cancel because nothingtakes it again. A dial count does not hold across versions: the cache evicts its oldest idle
connection past 4 per attached handle in 7.82, past 2 (and only if idle ≥ 1 s) in 8.23. (From
reading both versions' source; not measured.) For HLS, one cancel costs a handshake per request
to that origin for two minutes, then reuse resumes.
streamclose, which for an h2(
PROTOPT_STREAM) handler resets the stream and keeps the connection, as a prematuremulti_donedoes. (From source reading.)MAX_LEDGER_ORIGINS = 8(registered inci/list-caps.iniaswork), leastrecently used first, so the server every chain replay starts from outlives rotating CDN edges.
https://cdn/aandhttps://cdn:443/bare one origin,https://h/aandhttps://h:32400/bare two. A hop'sOriginis carried onHop(from theredirect's
Target, or parsed once per chain for its first URL), not re-parsed per attempt andagain in
stop().finished cleanly (nothing queued; reuse stays right for HLS segments), key mode (
keypin::applyalready sets
FRESH_CONNECTandFORBID_REUSE, so the new setopt is a no-op there).CURLOPT_FORBID_REUSEis not added. It would close the busy connection at removal, but it would haveto be set on a transfer still in progress, which
curl_easy_setopt's documentation calls undefined(from the commit message; not re-checked), and nothing measured it: the benchmarked fix set
FRESH_CONNECTalone. Adding it is conditional on a measurement of the residual below.reads as an unknown version, which never dials fresh.
CURLOPT_FRESH_CONNECTisnet.rs's constant,now
pub(crate).Evidence (measured)
A wired webOS 5.6.2 set, firmware curl 7.61.0 asked for HTTP/2 (
sysh2), through Traefik v3.7.17 about10 ms away, reverse-proxying to nginx; netem for the loss row. Seek-to-resume, per-run median, paired
by round against the same set's HTTP/1.1 baseline (
sys); ratio is arm /sys, 8 rounds, median with 95%bootstrap CI.
sysh2fcis the same client withCURLOPT_FRESH_CONNECTset on the seek requests. That isthe benchmark client's version of the change, not this PR's code running in the app.
sys(HTTP/1.1)sysh2sysh2fc(source:
analysis-play3-fc.json, 72 runs, none excluded.) Reading it:1.38x remains (CI lower bound 1.01); I have not determined whether it is the old connection's backlog
still arriving. That is the open question behind
FORBID_REUSE.sysh2fcused 0.83x (8 Mbit/s) and 0.88x (20 Mbit/s) ofsys;sysh20.98x / 0.98x.sysh2(analysis-play3.json, 266 runs) gave 2.98x [2.91, 3.52] (8 Mbit/s),2.24x [2.08, 2.41] (20 Mbit/s) and 3.22x [2.10, 9.96] (+50 ms, 1% loss, 8 Mbit/s). In that file the
fixed arm exists only at +50 ms, 1% loss, 20 Mbit/s: 1.16x [0.90, 1.66].
tcp_notsent_lowat=16384on the server (analysis-play3-srv-lowat.json,5 rounds, no added delay, 8 Mbit/s),
sysh2seeks were 0.70x [0.62, 0.71] of the HTTP/1.1 baseline. Thatneeds a server setting and does not help servers the user does not control; this PR is the client side.
On the television (this PR's code)
A debug build of the head below, on a webOS 10.3.0 set whose firmware libcurl 7.82.0
negotiates HTTP/2 by default, direct-playing a film from Plex through Traefik over HTTPS: a resume
and five manual seeks, back and forth. Every one logged a fresh connection and its reopen came back
ok=truein 214-531 ms; the film played on after each (event log, range offsets only):So on 7.82
stop()recognises a detached, unfinished transfer as HTTP/2 and the next request dialsfresh; each seek cancels a mid-body transfer, so each starts a new mark and logs once. The log does not say whether that came from the handle's own
CURLINFO_HTTP_VERSIONor fromits origin's version recorded at the response headers. This shows the rule firing, not a timing
comparison: no HTTP/1.1 or unfixed arm was run on this set.
Tests
plx_net: 333 passed, 0 failed, 1 ignored. Regression tests, one or more per rule:only_an_http2_transfer_that_did_not_finish_cleanly_leaves_its_connection_busy,stop_judges_a_failed_transfer_unfinished_and_a_failed_connect_not_at_all(the pure decision:version, clean finish vs failure, connect-phase failure, attachment, origin fallback, key mode).
the_ledger_keeps_the_last_version_per_origin,the_ledger_forgets_the_least_recently_used_origin,a_busy_mark_lasts_busy_for_and_logs_its_first_dial_only,a_fresh_connection_is_dialled_only_to_the_busy_origin_as_libcurl_reads_it.a mark or a recorded version):
requests_to_a_busy_http2_origin_dial_fresh_for_the_window_and_reuse_after_it(accept counts 2, 3, then 3 again past the window; one log line),
a_detached_unfinished_http2_request_marks_its_origin_busy_across_a_failed_chain,a_request_stopped_before_its_response_line_takes_only_its_own_origins_version,a_handle_that_never_entered_the_multi_leaves_no_busy_connection(a bounded range ending before itstarts),
a_request_that_never_connected_leaves_no_busy_connection(a refused connect, rc 7),an_unfinished_http11_transfer_leaves_no_busy_connection.Nine mutations, each run against
range_io::testsand each failing at least one test:stop()does not record the origina_detached_unfinished_http2_request_marks_its_origin_busy…a_busy_mark_lasts…,a_fresh_connection_is_dialled…,requests_to_a_busy_http2_origin…a_request_stopped_before_its_response_line_takes_only_its_own_origins_versionstop_judges_a_failed_transfer_unfinished_and_a_failed_connect…a_handle_that_never_entered_the_multi…,stop_judges…a_request_that_never_connected…,stop_judges…the_ledger_forgets_the_least_recently_used_origina_busy_mark_lasts…,requests_to_a_busy_http2_origin…a_busy_mark_lasts…,requests_to_a_busy_http2_origin…Gates
Head
56e5b45e, withmain612fc8cfmerged in, tree clean, Apple M1.make check:==== check: 127 steps — all ok ====.make check-nodef: finished, exit 0.make ipk(debug):PASS actual IPK: 8 ELF files,all packaging assertions passed.make ARM_PROFILE=release ipk, thencheck-build-budgets.py --binaryon the staged binary:17,697,584 of 20,000,000 bytes, ok.
tools/fwcompat.py --min-release 4.4.2: exit 0 on the main binary.The two failing
curlio::keymode_testsin the first CI run were the ubuntu-26.04 / libcurl 8.18 TLSsession resumption that #1297 fixed (the run tested a merge onto
8e486d1a); this branch now hasmainmerged in, which includes it. The host's libcurl (8.7.1) cannot reproduce that failure, so CI on this head is what confirms it.
Firmware compatibility: no new symbol.
CURLOPT_FRESH_CONNECTis incurl.hsince 7.7 (the controlplane already sets it),
CURLINFO_HTTP_VERSIONsince 7.50.0, below the 7.53.1 floor; both go through thealready-bound
curl_easy_setopt/curl_easy_getinfowrappers. On 7.53 and 7.61 the default is HTTP/1.1, sothe rule does not fire there.
Not verified
the option on its seek requests; the television run above shows the rule firing, not its effect.
ran on the Mac's libcurl 8.7.1 only (CI's run is pending).
the pure decision test; no failed h2 transfer was observed. A connect timeout (rc 28) cannot be told
from a mid-body low-speed timeout by its code, so it still marks an h2 origin busy (120 s of fresh
dials, never a reuse of a busy connection).
it busy, though it queued nothing; the cost is the same 120 s of fresh dials.
CURLOPT_MAXAGE_CONN, so there the 120 swindow does not guarantee the busy connection has been dropped. The firmware inventory records
sonames, not curl versions, so whether a supported firmware ships one is not known.
handshake per request inside it.
CURLOPT_FORBID_REUSE.Signed-off-by: fraygox [email protected]
🤖 Generated with Claude Code