Skip to content

Commit

Permalink
server: make call to ReleaseConnID idempotent. (#45676)
Browse files Browse the repository at this point in the history
close #45675
  • Loading branch information
pingyu authored Jul 31, 2023
1 parent fd50df6 commit 35e654e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion server/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,14 @@ func (cc *clientConn) Close() error {
return closeConn(cc, connections)
}

// closeConn should be idempotent.
// It will be called on the same `clientConn` more than once to avoid connection leak.
func closeConn(cc *clientConn, connections int) error {
metrics.ConnGauge.Set(float64(connections))
cc.server.dom.ReleaseConnID(cc.connectionID)
if cc.connectionID > 0 {
cc.server.dom.ReleaseConnID(cc.connectionID)
cc.connectionID = 0
}
if cc.bufReadConn != nil {
err := cc.bufReadConn.Close()
if err != nil {
Expand Down

0 comments on commit 35e654e

Please sign in to comment.