From ca4ba26b9dd288300a4bf4ff52a64d82bd7638ae Mon Sep 17 00:00:00 2001 From: Max Leske Date: Tue, 27 Sep 2022 07:11:54 +0200 Subject: [PATCH] fix: Close net.Conn before setting up a new one --- ftwhttp/client.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ftwhttp/client.go b/ftwhttp/client.go index ce83823..729b78b 100644 --- a/ftwhttp/client.go +++ b/ftwhttp/client.go @@ -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