srs/internal/proxy
winlin fbcc43cdb0 Proxy: Fix RTC/SRT reader goroutine leak; reuse UDP receive buffers.
In rtcConnection.HandlePacket the backend->client reader goroutine was
spawned unconditionally on every inbound client packet, which leaked
goroutines under steady-state WHEP load (STUN keepalives + RTCP feedback).
Guard the spawn with sync.Once so it runs exactly once per connection.

In SRTConnection.handleHandshake apply the same sync.Once guard so a
client retry of handshake 2 (because our handshake 3 was dropped) does
not race a second reader on backendUDP.Read.

In both Run loops, hoist the 4096-byte receive buffer out of the read
loop; callers consume the slice synchronously and the kernel copies on
Write/sendto, so no caller retains the slice past the call. To keep this
safe for SRT, clone ExtraData in SRTHandshakePacket.UnmarshalBinary so
decoded handshakes do not alias the reused receive buffer.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-17 20:59:29 -04:00
..
proxyfakes Proxy: Refactor for testability; add SRT/WHIP E2E and unit tests. v7.0.148 (#4675) 2026-05-17 12:09:07 -04:00
api_test.go Proxy: Refactor for testability; add SRT/WHIP E2E and unit tests. v7.0.148 (#4675) 2026-05-17 12:09:07 -04:00
api.go Proxy: Refactor for testability; add SRT/WHIP E2E and unit tests. v7.0.148 (#4675) 2026-05-17 12:09:07 -04:00
gen.go Proxy: Refactor for testability; add SRT/WHIP E2E and unit tests. v7.0.148 (#4675) 2026-05-17 12:09:07 -04:00
http_test.go Proxy: Refactor for testability; add SRT/WHIP E2E and unit tests. v7.0.148 (#4675) 2026-05-17 12:09:07 -04:00
http.go Proxy: Refactor for testability; add SRT/WHIP E2E and unit tests. v7.0.148 (#4675) 2026-05-17 12:09:07 -04:00
rtc_test.go Proxy: Unwrap legacy /rtc/v1/play/ JSON envelope for ICE parsing. 2026-05-17 17:52:07 -04:00
rtc.go Proxy: Fix RTC/SRT reader goroutine leak; reuse UDP receive buffers. 2026-05-17 20:59:29 -04:00
rtmp_test.go Proxy: Refactor for testability; add SRT/WHIP E2E and unit tests. v7.0.148 (#4675) 2026-05-17 12:09:07 -04:00
rtmp.go Proxy: Refactor for testability; add SRT/WHIP E2E and unit tests. v7.0.148 (#4675) 2026-05-17 12:09:07 -04:00
srt_test.go Proxy: Refactor for testability; add SRT/WHIP E2E and unit tests. v7.0.148 (#4675) 2026-05-17 12:09:07 -04:00
srt.go Proxy: Fix RTC/SRT reader goroutine leak; reuse UDP receive buffers. 2026-05-17 20:59:29 -04:00