Skip to content

Commit

Permalink
Fixed memory leak of connection (apache#165)
Browse files Browse the repository at this point in the history
Signed-off-by: xiaolong.ran <rxl@apache.org>
  • Loading branch information
wolfstudy authored and merlimat committed Jan 6, 2020
1 parent 0a496cc commit e7b779c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pulsar/internal/connection_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ func (p *connectionPool) GetConnection(logicalAddr *url.URL, physicalAddr *url.U
}

// Try to create a new connection
newCnx, wasCached := p.pool.LoadOrStore(logicalAddr.Host,
newConnection(logicalAddr, physicalAddr, p.tlsOptions, p.connectionTimeout, p.auth))
newConnection := newConnection(logicalAddr, physicalAddr, p.tlsOptions, p.connectionTimeout, p.auth)
newCnx, wasCached := p.pool.LoadOrStore(logicalAddr.Host, newConnection)
cnx := newCnx.(*connection)
if !wasCached {
cnx.start()
} else {
newConnection.Close()
}

if err := cnx.waitUntilReady(); err != nil {
Expand Down

0 comments on commit e7b779c

Please sign in to comment.