forked from quic-go/quic-go
remove the closeCallback from the session
The closeCallback was run when a session was closed, i.e. after the run loop of the session stopped. Instead of explicitely calling this callback from the session, the caller of session.run() can just execute the code after session.run() returns.
This commit is contained in:
25
client.go
25
client.go
@@ -244,18 +244,27 @@ func (c *client) createNewSession(negotiatedVersions []protocol.VersionNumber) e
|
||||
c.version,
|
||||
c.connectionID,
|
||||
c.config.TLSConfig,
|
||||
c.closeCallback,
|
||||
c.cryptoChangeCallback,
|
||||
negotiatedVersions)
|
||||
negotiatedVersions,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
go c.session.run()
|
||||
go func() {
|
||||
// session.run() returns as soon as the session is closed
|
||||
err := c.session.run()
|
||||
if err == errCloseSessionForNewVersion {
|
||||
return
|
||||
}
|
||||
|
||||
c.mutex.Lock()
|
||||
c.listenErr = err
|
||||
c.connStateChangeOrErrCond.Signal()
|
||||
c.mutex.Unlock()
|
||||
|
||||
utils.Infof("Connection %x closed.", c.connectionID)
|
||||
c.conn.Close()
|
||||
}()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *client) closeCallback(_ protocol.ConnectionID) {
|
||||
utils.Infof("Connection %x closed.", c.connectionID)
|
||||
c.conn.Close()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user