Skip to content

obs-util: Bound os_get_free_disk_space so a hung share can't stall obs-websocket - #2341

Merged
zackees merged 2 commits into
masterfrom
fix/1345-bounded-free-space
Oct 25, 2026
Merged

zackees merged 2 commits into
masterfrom
fix/1345-bounded-free-space

Conversation

@zackees

@zackees zackees commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

Fixes #1345

os_get_free_disk_space() runs statvfs or GetDiskFreeSpaceEx with no bound. obs-websocket's GetStats calls it once per request on a QThreadPool thread. So on a hung network share, a client polling every second fills the pool, and every request and event stops.

The plugin stays unchanged, per AGENTS.md. The fix is in Rust OBS: the export now comes from obs_util::bounded_free_space.

  • One query per path. At most one platform query per path is in flight, on a helper thread.
  • Bounded wait. A call waits up to 200 ms for it. After that it returns the path's last value, or 0 before the first. Callers already treat 0 as unknown or nonexistent (record-disk-space.h).
  • No pile-up during a hang. While a query hangs, further calls for that path start no new query and don't wait.
  • No thread available. If spawning a thread fails, the call falls back to the direct query, as before.
  • All three hosts. The Linux, macOS and Windows exports route through it. A null path keeps its old answer.

These are the defaults proposed on #1345. Neither "Decision needed" item has been answered, so they are easy to change.

Tests

  • RED (obs-util: Test a deadline…): rust/obs-util/tests/platform/bounded_free_space.rs, in the existing platform category of the suite, so no new test binary. All six cases fail against the todo!() stub:
    • a responsive volume;
    • a hung volume with no previous value;
    • a hung volume with a last value;
    • no new query or wait while a query hangs;
    • recovery;
    • independent paths.
  • GREEN: all six pass. The full obs-util suite passes (845 tests), and ./lint is clean.
  • Tier 3: for a responsive volume the value is unchanged, so the existing free-disk-space parity tests still apply.
    • The deliberate difference from C is the deadline. A hung share answers the last value instead of blocking.
  • Tier 2: there are no C test changes. test_record_disk_space uses an injected function.
  • Not run: no macOS or Windows build locally, and no reproduction against a real hung NAS.

The features ledger line is added.

todo!() stub for BoundedFreeSpace and its Tier 1 cases: a hung volume
answers 0 or its last value within the deadline, calls while a query
hangs start no new query, a recovered volume answers fresh values, and
paths don't block each other.

Refs #1345
Each path has at most one statvfs/GetDiskFreeSpaceEx in flight on a
helper thread. A call waits up to 200 ms, then answers the path's last
value (0 before the first). A hung share now costs one helper thread per
path instead of one obs-websocket pool thread per GetStats request, so
the pool never fills. The Linux, macOS and Windows exports route through
it; a failed thread spawn falls back to the direct query.

Fixes #1345
@zackees
zackees marked this pull request as ready for review October 25, 2026 04:30
@zackees
zackees enabled auto-merge October 25, 2026 04:42
@zackees
zackees added this pull request to the merge queue Oct 25, 2026
Merged via the queue into master with commit 33a8904 Oct 25, 2026
37 checks passed
@zackees
zackees deleted the fix/1345-bounded-free-space branch October 26, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

libobs: os_get_free_disk_space can block obs-websocket pool threads on a hung share (fix in Rust OBS, plugin unchanged)

1 participant