Fix panic while server shutdown

This commit is contained in:
Julien Salleyron 2019-03-21 15:54:07 +01:00 committed by Traefiker Bot
parent 79ecff7b42
commit f8f7edd124

View file

@ -312,11 +312,13 @@ func (c *connectionTracker) Shutdown(ctx context.Context) error {
// Close close all the connections in the tracked connections list // Close close all the connections in the tracked connections list
func (c *connectionTracker) Close() { func (c *connectionTracker) Close() {
c.lock.Lock()
defer c.lock.Unlock()
for conn := range c.conns { for conn := range c.conns {
if err := conn.Close(); err != nil { if err := conn.Close(); err != nil {
log.WithoutContext().Errorf("Error while closing connection: %v", err) log.WithoutContext().Errorf("Error while closing connection: %v", err)
} }
c.RemoveConnection(conn) delete(c.conns, conn)
} }
} }