perf(tcp): смерть smux-сессии без поллинга

This commit is contained in:
samosvalishe committed 2026-09-22 20:04:05 +03:00
1 parent b0e3cfe20a
commit 5b6ac18332
2 files changed
+12 -15

No files matched your search

+8 -15
View File
@@ -31,7 +31,6 @@ const (
setupRetryJitter = 4 * time.Second
providerBackoffDelay = 60 * time.Second
reconnectDelay = 2 * time.Second
sessionPollDelay = time.Second
minAcceptBackoff = 5 * time.Millisecond
maxAcceptBackoff = time.Second
)
@@ -330,20 +329,14 @@ func retryDelay(auth AuthHandler, err error) time.Duration {
// awaitDead: false - вышли по отмене ctx, а не по смерти сессии.
func awaitDead(ctx context.Context, log logx.Logger, s *session, id int) bool {
t := time.NewTicker(sessionPollDelay)
defer t.Stop()
for {
select {
case <-ctx.Done():
return false
case <-s.permDead:
log.Warnf("[session %d] TURN channel-bind умер - рецикл allocation", id)
return true
case <-t.C:
if s.smux.IsClosed() {
return true
}
}
select {
case <-ctx.Done():
return false
case <-s.permDead:
log.Warnf("[session %d] TURN channel-bind умер - рецикл allocation", id)
return true
case <-s.smux.CloseChan():
return true
}
}