Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7c73f23

Browse files
committedJun 29, 2024
modify connect() method of connPool to fix connection leak
1 parent f23bf75 commit 7c73f23

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

‎proxycore/connpool.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,17 +153,17 @@ func (p *connPool) connect() (conn *ClientConn, err error) {
153153
if errors.Is(err, context.DeadlineExceeded) {
154154
return nil, fmt.Errorf("handshake took longer than %s to complete", p.config.ConnectTimeout)
155155
}
156-
return nil, err
156+
return conn, err
157157
}
158158
if version != p.config.Version {
159159
p.logger.Error("protocol version not support", zap.Stringer("wanted", p.config.Version), zap.Stringer("got", version))
160-
return nil, ProtocolNotSupported
160+
return conn, ProtocolNotSupported
161161
}
162162

163163
if len(p.config.Keyspace) != 0 {
164164
err = conn.SetKeyspace(ctx, p.config.Version, p.config.Keyspace)
165165
if err != nil {
166-
return nil, err
166+
return conn, err
167167
}
168168
}
169169

0 commit comments

Comments
 (0)
Please sign in to comment.