Skip to content

Commit 3dc7b40

Browse files
ossrs-aiwinlinvip
authored andcommitted
AI: HTTP-FLV: Enforce minimum 10ms sleep to prevent CPU busy-wait when mw_latency=0. v7.0.110 (#3963)
1 parent 547b0c0 commit 3dc7b40

File tree

5 files changed

+11
-3
lines changed

5 files changed

+11
-3
lines changed

trunk/doc/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ The changelog for SRS.
77
<a name="v7-changes"></a>
88

99
## SRS 7.0 Changelog
10+
* v7.0, 2025-10-27, AI: HTTP-FLV: Enforce minimum 10ms sleep to prevent CPU busy-wait when mw_latency=0. v7.0.110 (#3963)
1011
* v7.0, 2025-10-26, AI: Edge: Fix stream names with dots being incorrectly truncated in source URL generation. v7.0.109 (#4011)
1112
* v7.0, 2025-10-26, AI: HTTPS: Handle SSL_ERROR_ZERO_RETURN as graceful connection closure. v7.0.108 (#4036)
1213
* v7.0, 2025-10-26, AI: API: Add clients field to on_play/on_stop webhooks and total field to HTTP API. v7.0.107 (#4147)

trunk/src/app/srs_app_http_stream.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,13 @@ srs_error_t SrsLiveStream::do_serve_http(SrsLiveSource *source, ISrsLiveConsumer
851851
}
852852

853853
srs_utime_t mw_sleep = config_->get_mw_sleep(req_->vhost_);
854+
855+
// For HTTP FLV, we must wait for some milliseconds to avoid the spin.
856+
// See https://github.com/ossrs/srs/issues/3963 for more details.
857+
if (mw_sleep == 0) {
858+
mw_sleep = 10 * SRS_UTIME_MILLISECONDS;
859+
}
860+
854861
srs_trace("FLV %s, encoder=%s, mw_sleep=%dms, cache=%d, msgs=%d, dinm=%d, guess_av=%d/%d/%d",
855862
entry_->pattern.c_str(), enc_desc.c_str(), srsu2msi(mw_sleep), enc->has_cache(), msgs.max_, drop_if_not_match,
856863
has_audio, has_video, guess_has_av);

trunk/src/core/srs_core_version7.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99

1010
#define VERSION_MAJOR 7
1111
#define VERSION_MINOR 0
12-
#define VERSION_REVISION 109
12+
#define VERSION_REVISION 110
1313

1414
#endif

trunk/src/utest/srs_utest_manual_protocol2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5009,7 +5009,7 @@ VOID TEST(ProtocolKbpsTest, StreamIdentifyWithDotsInName_Issue4011)
50095009
// Case 3: Different streams with same prefix should be different
50105010
std::string backup1 = srs_net_url_encode_sid("", "live", "test.backup.stream");
50115011
std::string backup2 = srs_net_url_encode_sid("", "live", "test.backup.stream2");
5012-
EXPECT_STRNE(backup1.c_str(), backup2.c_str()); // Should be different
5012+
EXPECT_STRNE(backup1.c_str(), backup2.c_str()); // Should be different
50135013

50145014
// Case 4: The intended behavior - stripping ONLY known extensions
50155015
// These should work correctly (strip .flv and .m3u8)

trunk/src/utest/srs_utest_workflow_http_conn.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ VOID TEST(BasicWorkflowHttpConnTest, ManuallyVerifyForHttpStream)
184184
live_stream->hooks_ = mock_hooks.get();
185185

186186
// Do not wait for utest, consume messages immediately. Remove this when HTTP stream use cond signal.
187-
mock_config->mw_sleep_ = 0;
187+
mock_config->mw_sleep_ = 100; // 0.1ms
188188

189189
mock_entry->enabled = true;
190190
mock_entry->pattern = "/live/livestream.flv";

0 commit comments

Comments
 (0)