Repository navigation
fix(file-updater): Bound the update request so an unreachable host cannot hold shutdown (#2672) - #2673
Conversation
…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.
|
Handed off to the coordinator.
|
zackees
left a comment
There was a problem hiding this comment.
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.
343f534bis the test and itstests.dwiring only (60 + 15 lines, no product change);30d11d9cis the fix plus the features line (7 + 8).git diff --stat origin/master...pr2673is 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, andCURLOPT_NOSIGNALis already set at:113before the two newsetoptcalls, 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.jsonentry is needed. The graph lists 266 of the 440tests.dfragments; the siblingtest_file_updater_failureand most tests added in October are not in it either, so this is the established pattern, not an omission. The new fragment joinscmocka-testsviaadd_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 80on 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
-
CURLOPT_TIMEOUTis outside the budget the smoke test enforces.CONNECTTIMEOUT=15is what covers the unreachable host and it sits inside the 30 s shutdown budget (#2671).TIMEOUT=60covers 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 unboundedpthread_joininupdate_info_destroyfor 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. -
The assertion is one-sided.
elapsed_ms >= 40000catches 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'ssuccess, 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).
|
Tier 2 evidence from run 40554582835, job 15.05 s is exactly the new |
Refs #2672 (Fixes #2672, Fixes #2671).
Problem
shared/file-updatersets no transfer deadline:do_http_request(
shared/file-updater/file-updater/file-updater.c.h:100) setsCURLOPT_FAILONERRORandCURLOPT_NOSIGNALbut neitherCURLOPT_CONNECTTIMEOUTnorCURLOPT_TIMEOUT.update_info_destroy(
:36) then joins the update thread with an unboundedpthread_join, and rtmp-services calls it fromobs_module_unload(
plugins/rtmp-services/rtmp-services-main.c.h:122) after starting theservice-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 mson the macOS runner inrun 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 totest_file_updater_failure.c) points anupdate_infocreated withupdate_info_create_single_with_doneat RFC 5737 TEST-NET-1(
192.0.2.1, guaranteed unroutable), callsupdate_info_destroy, andfails 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_destroyblocksfor the full connect timeout before the assertion ever runs.
Commit
343f534bis the RED (test + itstests.dwiring only; the fixis not in it).
GREEN
do_http_requestbounds the request:CURLOPT_NOSIGNALis already set, so the timeout is thread-safe. Anunreachable host then fails fast (at the connect bound), the update
thread ends, and
update_info_destroy's join returns promptly. The samebound also covers the twitch/dacast/amazon single-file updaters, which
share
do_http_request.Tiers
helper; there is no
libobs/ reference-model behavior to differ onand no protocol surface.
network-touching cmocka tests).
Not verified
timeout; the per-platform value is not a constant in the tree.
ENETUNREACH); that holds where it was checked, but a host thatrefuses the route immediately would make the bound assertion pass on
the unfixed build too.