use the HandshakeComplete() context for accepting sessions in the server

This commit is contained in:
Marten Seemann
2019-07-06 17:37:15 +07:00
parent 3724f91f33
commit b06d7b0cba
8 changed files with 70 additions and 107 deletions

View File

@@ -292,7 +292,7 @@ func (c *client) establishSecureConnection(ctx context.Context) error {
return ctx.Err()
case err := <-errorChan:
return err
case <-c.handshakeChan:
case <-c.session.HandshakeComplete().Done():
// handshake successfully completed
return nil
}
@@ -371,13 +371,9 @@ func (c *client) createNewTLSSession(version protocol.VersionNumber) error {
c.mutex.Lock()
defer c.mutex.Unlock()
runner := &runner{
packetHandlerManager: c.packetHandlers,
onHandshakeCompleteImpl: func(_ Session) { close(c.handshakeChan) },
}
sess, err := newClientSession(
c.conn,
runner,
c.packetHandlers,
c.destConnID,
c.srcConnID,
c.config,