forked from quic-go/quic-go
Merge pull request #937 from lucas-clemente/fix-server-close-race
fix race condition when closing the server
This commit is contained in:
@@ -194,11 +194,11 @@ func (s *server) Close() error {
|
|||||||
for _, session := range s.sessions {
|
for _, session := range s.sessions {
|
||||||
if session != nil {
|
if session != nil {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func(sess packetHandler) {
|
||||||
// session.Close() blocks until the CONNECTION_CLOSE has been sent and the run-loop has stopped
|
// session.Close() blocks until the CONNECTION_CLOSE has been sent and the run-loop has stopped
|
||||||
_ = session.Close(nil)
|
_ = sess.Close(nil)
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}()
|
}(session)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.sessionsMutex.Unlock()
|
s.sessionsMutex.Unlock()
|
||||||
|
|||||||
Reference in New Issue
Block a user