Make Control safe to stop and wait on from any lifecycle state (#1794)

This commit is contained in:
Nate Brown
2026-07-10 10:35:17 -05:00
committed by GitHub
parent 5ecdd4eaa9
commit ab736e4c6b
10 changed files with 441 additions and 58 deletions
+11
View File
@@ -130,6 +130,17 @@ func Main(c *config.C, configTest bool, buildVersion string, l *slog.Logger, dev
udpConns := make([]udp.Conn, routines)
port := c.GetInt("listen.port", 0)
// Callers get no handle to these until the Control is returned, release them on any error.
defer func() {
if reterr != nil {
for _, u := range udpConns {
if u != nil {
_ = u.Close()
}
}
}
}()
if !configTest {
rawListenHost := c.GetString("listen.host", "0.0.0.0")
var listenHost netip.Addr