mirror of
https://github.com/ossrs/srs.git
synced 2026-10-24 09:59:20 +03:00
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>
57 lines
1.4 KiB
Bash
Executable File
57 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
#
|
|
# Copy from State Threads to the SRS mirror trunk/3rdparty/st-srs.
|
|
#
|
|
|
|
SRS_WORK_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
|
|
SRS_ST="$SRS_WORK_DIR/trunk/3rdparty/st-srs"
|
|
ST_DIR="$SRS_WORK_DIR/state-threads"
|
|
|
|
# Files that only State Threads owns, never copied into the mirror.
|
|
st_only() {
|
|
case "$1" in
|
|
.gitignore|.github/*|.run/*|ide/*|utest/gtest-fit/*) return 0 ;;
|
|
*) return 1 ;;
|
|
esac
|
|
}
|
|
|
|
if [[ ! -f "$SRS_ST/public.h" ]]; then
|
|
echo "no st-srs in $SRS_ST"
|
|
exit -1
|
|
fi
|
|
|
|
if [[ ! -f "$ST_DIR/public.h" ]]; then
|
|
echo "no State Threads project in $ST_DIR"
|
|
exit -1
|
|
fi
|
|
|
|
SOURCES=$(mktemp) && TARGETS=$(mktemp)
|
|
trap 'rm -f "$SOURCES" "$TARGETS"' EXIT
|
|
|
|
git -C "$ST_DIR" ls-files --cached --others --exclude-standard | sort -u | while read -r name; do
|
|
st_only "$name" || [[ ! -f "$ST_DIR/$name" ]] || echo "$name"
|
|
done > "$SOURCES"
|
|
(cd "$SRS_ST" && git ls-files --cached --others --exclude-standard) | sort -u | while read -r name; do
|
|
st_only "$name" || echo "$name"
|
|
done > "$TARGETS"
|
|
|
|
while read -r name; do
|
|
if ! (mkdir -p "$(dirname "$SRS_ST/$name")" && cp "$ST_DIR/$name" "$SRS_ST/$name"); then
|
|
echo "copy $name failed"
|
|
exit -1
|
|
fi
|
|
done < "$SOURCES" || exit -1
|
|
echo "Copy files success"
|
|
|
|
comm -13 "$SOURCES" "$TARGETS" | while read -r name; do
|
|
if ! rm -f "$SRS_ST/$name"; then
|
|
echo "remove $name failed"
|
|
exit -1
|
|
fi
|
|
echo "Removed $name"
|
|
done || exit -1
|
|
echo "Remove stale files success"
|
|
|
|
echo "Done"
|