1
0
mirror of https://github.com/ossrs/srs.git synced 2026-10-24 09:59:20 +03:00

1 Commits

Author SHA1 Message Date
Winlin
08cc7a15b1 Fix failed live source crash, ST source of truth, testability. v8.0.54 (#4758)
A crash fix for a failed live source, State Threads moved to its own
source of truth with new feature tests, and the next round of
testability refactors.

## Bug fix

- **Live: Drop a live source whose initialize failed. v8.0.52**
`SrsLiveSourceManager::fetch_or_create()` adds a new source to the pool
before `initialize()`, and left it there when `initialize()` failed. The
next client for that stream got the half-built source as if it were
ready. With an unknown `dvr_plan`, which `check_config` accepts,
`SrsDvr::initialize()` fails with `plan_` NULL but `actived_` set. The
first RTMP publish was refused with 3083, and the second crashed SRS in
`SrsDvr::on_publish()`. Now a failed `initialize()` removes the source
from the pool, if the pool still holds that same source, so the next
client creates a new one. With `SRS_VHOST_DVR_DVR_PLAN=foo`, both
publishes are now refused with 3083 and the server stays up.

## State Threads

- `state-threads/` (a symlink to `../state-threads`) is now the source
of truth for ST. Changes start there, then sync into
`trunk/3rdparty/st-srs/`.
- `scripts/copy-from-st.sh` copies `state-threads/` into the mirror, and
`scripts/copy-to-st.sh` copies the other way. Both skip ST-only files
(`.github`, `.run`, `ide`, `gtest-fit`) and remove files that no longer
exist in the source.
- `trunk/3rdparty/st-srs/` is synced from State Threads 86c0e69
(v1.9.0):
- Feature tests for keys, TCP and UDP I/O, the scheduler, sync, epoll,
select and stacks.
- Fixes two missed switch callbacks and the restore of a randomized
stack's guard page.
  - Retries blocking I/O on `EINTR`.
- Marks allocation failures and debugger code as excluded from coverage.
- Moves the change list to `CHANGELOG.md` and drops the old CentOS
Dockerfiles.

## Testability refactors (no behavior change)

- `SrsServer`: creates its RTC UDP listeners and SRT acceptors through
the app factory. Its HTTP server, ingester, signal manager, RTC session
manager, pid-file locker and SRT event loop are now typed as interfaces.
The libsrt log setup moves into `SrsSrtEventLoop`.
- Clocks and random generators are injected or captured in the live,
RTC, SRT and RTSP sources, the statistic stream, client and vhost, the
RTMP handshake blocks (`SrsKeyBlock`, `SrsDigestBlock`, `SrsC2S2`) and
`SrsRtcPlayerNegotiator`'s SSRC generator.
- Config reads go through a captured `ISrsAppConfig` in `SrsStatistic`,
`SrsStatisticVhost`, `SrsCoWorkers`, the summaries,
`SrsDtlsCertificate`, `SrsRtcBlackhole`, `SrsRtcPublishStream` and
`SrsRtcFrameBuilder`. `SrsRtcRecvTrack` reads its circuit breaker
through a captured `ISrsCircuitBreaker`.
- `assemble()` now does the construction work for the live, RTC, SRT and
RTSP source managers' timers, `SrsResourceManager`'s condition variable,
`SrsSharedTimer`'s fast timers, the SRT and HTTP receive threads,
`SrsUdpMuxListener`, `SrsSignalManager`, `SrsExecutorCoroutine`,
`SrsDynamicHttpConn`, `SrsGbMediaTcpConn`, `SrsGbSession`,
`SrsClockWallMonitor`, `SrsSrtFrameBuilder`, `SrsSrtConnection`,
`SrsSrtListener`, `SrsOriginHub`'s DVR and `SrsRtcRtpBuilder`'s audio
transcoder.
- `SrsHttpHeartbeat` reaches the statistic, and `SrsServer` reaches the
heartbeat, through interfaces. `SrsGbListener` takes the API server
owner in its constructor.

## AI skills

- A State Threads code map and docs route, a State Threads workflow in
`develop-code.md`, and ST version and changelog rules.
- SRS issue Truth Records condensed to one short format.

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-10-02 12:16:27 -04:00