Fix flaky TestManagerCtxDoneCloseSessions

This commit is contained in:
MoofMonkey 2022-10-04 03:16:12 +03:00
parent 1d68ad253f
commit c053c1e8c4
1 changed files with 4 additions and 2 deletions

View File

@ -2,6 +2,7 @@ package datagramsession
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"io" "io"
"time" "time"
@ -87,9 +88,10 @@ func (m *manager) shutdownSessions(err error) {
} }
closeSessionErr := &errClosedSession{ closeSessionErr := &errClosedSession{
message: err.Error(), message: err.Error(),
// Usually connection with remote has been closed, so set this to true to skip unregistering from remote
byRemote: true,
} }
// Usually connection with remote has been closed, so set this to true to skip unregistering from remote
// context.Canceled is an exception because that means session is being closed by our side
closeSessionErr.byRemote = !errors.Is(err, context.Canceled)
for _, s := range m.sessions { for _, s := range m.sessions {
s.close(closeSessionErr) s.close(closeSessionErr)
} }