connect() now closes c.link.conn upon an error.

This commit is contained in:
scruzin 2019-01-20 09:50:51 +10:30
parent 04ad1fec25
commit a362d1d2ab
1 changed files with 7 additions and 0 deletions

View File

@ -174,6 +174,13 @@ func connect(c *Conn) error {
return err
}
c.log(DebugLevel, pkg+"connected")
defer func() {
if err != nil {
c.link.conn.Close()
}
}()
err = handshake(c)
if err != nil {
c.log(WarnLevel, pkg+"handshake failed", "error", err.Error())