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> |
||
|---|---|---|
| .. | ||
| bootstrap | ||
| debug | ||
| env | ||
| errors | ||
| lb | ||
| logger | ||
| proxy | ||
| redisclient | ||
| rtmp | ||
| signal | ||
| sync | ||
| utils | ||
| version | ||