Close leaked connection when Stop races with reconnect

This commit is contained in:
Viktor Liu
2026-04-14 17:28:46 +02:00
parent 56a13cdece
commit 68092b1844

View File

@@ -180,6 +180,14 @@ func (c *ConnTrack) reconnect() (chan nfct.Event, chan error) {
} }
c.mux.Lock() c.mux.Lock()
if !c.started {
// Stop() ran while we were reconnecting.
c.mux.Unlock()
if closeErr := conn.Close(); closeErr != nil {
log.Debugf("close conntrack connection: %v", closeErr)
}
return nil, nil
}
c.conn = conn c.conn = conn
c.mux.Unlock() c.mux.Unlock()