Skip to content

fix(file-updater): Bound the update request so an unreachable host cannot hold shutdown (#2672) - #2673

Merged
zackees merged 2 commits into
masterfrom
fix/2672-file-updater-connect-timeout
Oct 27, 2026
Merged

zackees merged 2 commits into
masterfrom
fix/2672-file-updater-connect-timeout

Conversation

@zackees

@zackees zackees commented Oct 27, 2026

Copy link
Copy Markdown
Member

Refs #2672 (Fixes #2672, Fixes #2671).

Problem

shared/file-updater sets no transfer deadline: do_http_request
(shared/file-updater/file-updater/file-updater.c.h:100) sets
CURLOPT_FAILONERROR and CURLOPT_NOSIGNAL but neither
CURLOPT_CONNECTTIMEOUT nor CURLOPT_TIMEOUT. update_info_destroy
(:36) then joins the update thread with an unbounded
pthread_join, and rtmp-services calls it from obs_module_unload
(plugins/rtmp-services/rtmp-services-main.c.h:122) after starting the
service-list fetch at module load (:104).

So when the update host is unreachable, quitting the application while
that fetch is in flight blocks the exit for the kernel's TCP connect
timeout — measured 75005 ms on the macOS runner in
run 40529110726,
where the packaged-startup smoke test's 30 s shutdown budget expires
first (#2671).

RED

test/cmocka/test_file_updater_timeout.c (Tier 2 cmocka, next to
test_file_updater_failure.c) points an update_info created with
update_info_create_single_with_done at RFC 5737 TEST-NET-1
(192.0.2.1, guaranteed unroutable), calls update_info_destroy, and
fails when the join held shutdown for 40 s or more.

On master the test does not return for the OS connect timeout —
tcp_syn_retries=6, ~130 s on Linux, i.e. update_info_destroy blocks
for the full connect timeout before the assertion ever runs.
Commit 343f534b is the RED (test + its tests.d wiring only; the fix
is not in it).

GREEN

do_http_request bounds the request:

curl_easy_setopt(info->curl, CURLOPT_CONNECTTIMEOUT, 15L);
curl_easy_setopt(info->curl, CURLOPT_TIMEOUT, 60L);

CURLOPT_NOSIGNAL is already set, so the timeout is thread-safe. An
unreachable host then fails fast (at the connect bound), the update
thread ends, and update_info_destroy's join returns promptly. The same
bound also covers the twitch/dacast/amazon single-file updaters, which
share do_http_request.

Tiers

  • Tier 1/3/4: not applicable — this is a liveness fix in a CI/shared
    helper; there is no libobs / reference-model behavior to differ on
    and no protocol surface.
  • Tier 2: the new cmocka case above (Linux, like the other
    network-touching cmocka tests).

Not verified

  • The RED run's wall time here (~130 s) is this host's kernel connect
    timeout; the per-platform value is not a constant in the tree.
  • The test relies on the runner blackholing TEST-NET-1 (no fast
    ENETUNREACH); that holds where it was checked, but a host that
    refuses the route immediately would make the bound assertion pass on
    the unfixed build too.

…2672)

RED for #2672. update_info_destroy joins the update thread, and
do_http_request installs no CURLOPT_CONNECTTIMEOUT, so a fetch to an
unroutable host blocks the exit for the kernel's TCP connect timeout
(tcp_syn_retries=6, ~130 s here). The test points an update_info at
RFC 5737 TEST-NET-1 and fails when destroy takes longer than 40 s.
…nnot hold shutdown (#2672)

GREEN for #2672. do_http_request set no transfer deadline, so a fetch to
an unreachable update host blocked on the kernel's TCP connect timeout
(~75 s on macOS, longer on Linux), and update_info_destroy's unbounded
pthread_join waited it out -- on the exit path, because rtmp-services
unloads the module on shutdown.

Set CURLOPT_CONNECTTIMEOUT (15 s) and CURLOPT_TIMEOUT (60 s).
CURLOPT_NOSIGNAL is already set, so the timeout is thread-safe.

Ledger line in docs/features.md (Fixed upstream bugs / Stability): the
missing deadline is upstream's too.
@zackees

zackees commented Oct 27, 2026

Copy link
Copy Markdown
Member Author

Handed off to the coordinator.

  • Branch rebased on origin/master at open; git diff origin/master --stat is the 4 intended files, no submodule pointer change.
  • Auto-merge on (gh pr merge 2673 --auto). CI so far: Format ✅, Validate Data ✅, Event Data ✅, CI Mode ✅; Tier 2 Linux (build + tests) still running — the new cmocka case is the Tier 2 evidence.
  • Not stamped with the local gate: this checkout (obs-studio5) has no warm Tier 2 build volume, so a cold full build was not worth starting; PR CI is the gate.

@zackees zackees left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Review (coordinator tick)

Verdict: no blocking findings. The fix and the RED/GREEN split hold up; two non-blocking observations below. Queuing waits on the one remaining job anyway (Rust Tier 2 Linux (tests ON)), and auto-merge is already on, so this review does not gate the landing.

Verified

  • RED then GREEN is clean. 343f534b is the test and its tests.d wiring only (60 + 15 lines, no product change); 30d11d9c is the fix plus the features line (7 + 8). git diff --stat origin/master...pr2673 is the four intended files, no submodule pointer.
  • The bound lands where all four updaters share it. do_http_request (shared/file-updater/file-updater/file-updater.c.h:100) is the common path for the service-list, twitch, dacast and amazon fetches, and CURLOPT_NOSIGNAL is already set at :113 before the two new setopt calls, so libcurl's timer path is the thread-safe one — the comment's claim is accurate rather than hopeful.
  • Ledger line is in the right place and the right form. docs/features.md §Stability, *All*, pending merge., matching the 66 existing pending entries.
  • No test/cmocka/build/test-graph.json entry is needed. The graph lists 266 of the 440 tests.d fragments; the sibling test_file_updater_failure and most tests added in October are not in it either, so this is the established pattern, not an omission. The new fragment joins cmocka-tests via add_dependencies, which is what the Tier 2 validators build.
  • The test's premise holds in a container, not just on the host. docker run --rm alpine nc -w 20 192.0.2.1 80 on default bridge networking times out at 20 s instead of failing fast, so TEST-NET-1 blackholes the SYN the way the RED needs. That answers the first of the two "Not verified" items for the CI environment; the runner's own routing is still only provable from the Tier 2 log.

Non-blocking observations

  1. CURLOPT_TIMEOUT is outside the budget the smoke test enforces. CONNECTTIMEOUT=15 is what covers the unreachable host and it sits inside the 30 s shutdown budget (#2671). TIMEOUT=60 covers the connected but silent case, and 60 s is past that budget: a host that completes the TCP handshake and then never answers still holds the unbounded pthread_join in update_info_destroy for up to a minute. If "shutdown never exceeds the budget" is the goal, either the transfer bound wants to be under 30 s, or the join wants a bound of its own (a timed join, or aborting the handle from the exiting thread) instead of relying solely on curl's timeout. If the goal is only "unreachable host", the in-code comment could say so, so the 60 s is not read as a shutdown guarantee.

  2. The assertion is one-sided. elapsed_ms >= 40000 catches the blackhole and misses the environment where the route is refused outright: there the unfixed build also returns in milliseconds, so the test goes green while guarding nothing. Cheap hardening — take the outcome from the done callback's success, and cmocka-skip() when the attempt ended in under a second — makes "this host refused the route" visible evidence instead of a pass. As written, the PR already discloses the risk under "Not verified"; the skip would make it self-reporting.

Posting as a comment review because this is the maintainer's own PR (GitHub will not accept an approval from the author's account).

@zackees

zackees commented Oct 27, 2026

Copy link
Copy Markdown
Member Author

Tier 2 evidence from run 40554582835, job Rust Tier 2 Linux 🐧 (tests ON):

300/578 Test  #51: test_file_updater_failure ... Passed  0.05 sec
578/578 Test  #52: test_file_updater_timeout ... Passed 15.05 sec

15.05 s is exactly the new CURLOPT_CONNECTTIMEOUT (15 s) — the fetch now ends at the connect deadline instead of the kernel's ~130 s default (the ~75 s the macOS smoke test measured). All checks green, CI Gate ✅, mergeStateStatus CLEAN; queued with auto-merge.

@zackees
zackees added this pull request to the merge queue Oct 27, 2026
Merged via the queue into master with commit 42ed9b2 Oct 27, 2026
36 checks passed
@zackees
zackees deleted the fix/2672-file-updater-connect-timeout branch October 27, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

1 participant