Skip to content

Commit

Permalink
Merge pull request #84 from theseion/close-connection-when-reusing
Browse files Browse the repository at this point in the history
fix: Close net.Conn before setting up a new one
  • Loading branch information
fzipi authored Sep 27, 2022
2 parents d61210f + ca4ba26 commit 536b896
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ftwhttp/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,16 @@ func (c *Client) NewOrReusedConnection(d Destination) error {
if c.Transport == nil {
return c.NewConnection(d)
}
if err := c.Transport.connection.Close(); err != nil {
return err
}

netConn, err := c.dial(d)
if err == nil {
c.Transport.connection = netConn
}
return err

return err
}

// dial tries to establish a connection
Expand Down

0 comments on commit 536b896

Please sign in to comment.