Fix panic while server shutdown
This commit is contained in:
parent
79ecff7b42
commit
f8f7edd124
1 changed files with 3 additions and 1 deletions
|
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue