File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -312,7 +312,17 @@ func (c *baseClient) onAuthenticationErr(poolCn *pool.Conn) func(err error) {
312312 return func (err error ) {
313313 if err != nil {
314314 if isBadConn (err , false , c .opt .Addr ) {
315- c .connPool .CloseConn (poolCn )
315+ // Close the connection to force a reconnection.
316+ err := c .connPool .CloseConn (poolCn )
317+ if err != nil {
318+ internal .Logger .Printf (context .Background (), "redis: failed to close connection: %v" , err )
319+ // try to close the network connection directly
320+ // so that no resource is leaked
321+ err := poolCn .Close ()
322+ if err != nil {
323+ internal .Logger .Printf (context .Background (), "redis: failed to close network connection: %v" , err )
324+ }
325+ }
316326 }
317327 internal .Logger .Printf (context .Background (), "redis: re-authentication failed: %v" , err )
318328 }
You can’t perform that action at this time.
0 commit comments