-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
HLS/DASH: Fix dispose() to cleanup files after unpublish #4618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
When a stream is unpublished, on_unpublish() sets enabled_ to false. Later when dispose() is called by cycle() after hls_dispose timeout, the early return on !enabled_ prevents controller_->dispose() from being called, leaving HLS/DASH files on disk. This fix ensures controller_->dispose() always runs when hls_dispose is configured, while still preventing duplicate on_unpublish() calls. Fixes the regression introduced in commit 550760f.
e3c2fa5 to
9503f5f
Compare
|
I believe this PR make sense. |
|
One more thing, Let the utest to cover this case. e.g. srs/trunk/src/utest/srs_utest_ai17.cpp Lines 1381 to 1387 in 93c5d72
To cover when dash/hls is |
|
Thanks for the review feedback! I've added the test case for DASH to cover However, I noticed there's no equivalent lifecycle/dispose test for HLS like Question: Should I create a new |
I think the independent My suggest put the code in the |
HLS/DASH: Fix dispose() to cleanup files after unpublish
Summary
Fixes a bug where HLS/DASH files are not deleted after the configured
hls_dispose/dash_disposetimeout.Problem
When a stream is unpublished:
on_unpublish()is called and setsenabled_ = falsecycle()callsdispose()dispose()immediately returns due toif (!enabled_)check at line 2722 (HLS) and line 891 (DASH)controller_->dispose()is never calledObserved behavior:
dispose()called at 11:33:14 (after 30s timeout)Root Cause
Commit 550760f introduced an early return in
dispose()when!enabled_, which prevents file cleanup afteron_unpublish()has already been called and setenabled_to false.Solution
Reorder the logic in
dispose()to:on_unpublish()only ifenabled_is still true (prevents duplicate calls)controller_->dispose()to cleanup files when dispose timeout occursThis ensures files are properly cleaned up while still preventing duplicate
on_unpublish()calls.Changes Made
Testing Recommendation
To verify the fix:
Start RTMP stream to
/live/test:Wait for HLS segments to be created:
Stop the stream (Ctrl+C)
Wait for
hls_disposetimeout (default 120s, or 30s with your config):# Watch logs for "hls cycle to dispose hls" and "gracefully dispose hls" tail -f srs.logVerify files are deleted:
ls -la /path/to/hls/live/test/ # Should be empty or directory removedExpected results:
Impact
Checklist
Related Issues