never block when calling the onHandshakeComplete callback

This commit is contained in:
Marten Seemann
2018-12-28 23:32:41 +07:00
parent 8ac77be934
commit 1301610a54
2 changed files with 34 additions and 2 deletions

View File

@@ -149,7 +149,7 @@ func listen(conn net.PacketConn, tlsConf *tls.Config, config *Config) (*server,
tlsConf: tlsConf,
config: config,
sessionHandler: sessionHandler,
sessionQueue: make(chan Session, 5),
sessionQueue: make(chan Session),
errorChan: make(chan struct{}),
newSession: newSession,
logger: utils.DefaultLogger.WithPrefix("server"),
@@ -164,7 +164,7 @@ func listen(conn net.PacketConn, tlsConf *tls.Config, config *Config) (*server,
func (s *server) setup() error {
s.sessionRunner = &runner{
onHandshakeCompleteImpl: func(sess Session) { s.sessionQueue <- sess },
onHandshakeCompleteImpl: func(sess Session) { go func() { s.sessionQueue <- sess }() },
retireConnectionIDImpl: s.sessionHandler.Retire,
removeConnectionIDImpl: s.sessionHandler.Remove,
}