mirror of
https://github.com/fosrl/gerbil.git
synced 2026-09-27 16:29:06 +02:00
The UDPProxyServer.Stop() method was being called twice on every clean shutdown — once via defer proxyRelay.Stop() in main() and once from the shutdown errgroup goroutine — causing a 'close of closed channel' panic. The old guard using a bare select on s.ctx.Done() was ineffective: by the second call the context was already cancelled, so both code paths fell through unconditionally to close(s.packetChan), panicking. Fix: wrap the entire Stop() body in a sync.Once so that all cleanup (cancel, conn close, packetChan close) runs at most once regardless of how many times or from how many goroutines Stop() is called. Fixes #51