summaryrefslogtreecommitdiff
path: root/lib/go/thrift/socket_conn.go
diff options
context:
space:
mode:
Diffstat (limited to 'lib/go/thrift/socket_conn.go')
-rw-r--r--lib/go/thrift/socket_conn.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/go/thrift/socket_conn.go b/lib/go/thrift/socket_conn.go
index 5619d9626..bbb5b7d15 100644
--- a/lib/go/thrift/socket_conn.go
+++ b/lib/go/thrift/socket_conn.go
@@ -20,6 +20,7 @@
package thrift
import (
+ "errors"
"net"
"sync/atomic"
)
@@ -83,7 +84,17 @@ func (sc *socketConn) IsOpen() bool {
if !sc.isValid() {
return false
}
- return sc.checkConn() == nil
+ if err := sc.checkConn(); err != nil {
+ if !errors.Is(err, net.ErrClosed) {
+ // The connectivity check failed and the error is not
+ // that the connection is already closed, we need to
+ // close the connection explicitly here to avoid
+ // connection leaks.
+ sc.Close()
+ }
+ return false
+ }
+ return true
}
// Read implements io.Reader.