Merge pull request #2375 from monkey92t/defer-releaseConn

fix(conn): releaseConn should be executed correctly
This commit is contained in:
Vladimir Mihailenco 2023-01-30 08:51:46 +02:00 committed by GitHub
commit 2b9bd23c4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 9 deletions

View File

@ -1287,9 +1287,13 @@ func (c *ClusterClient) processPipelineNode(
return err return err
} }
err = c.processPipelineNodeConn(ctx, node, cn, cmds, failedCmds) var processErr error
node.Client.releaseConn(ctx, cn, err) defer func() {
return err node.Client.releaseConn(ctx, cn, processErr)
}()
processErr = c.processPipelineNodeConn(ctx, node, cn, cmds, failedCmds)
return processErr
}) })
} }
@ -1464,9 +1468,13 @@ func (c *ClusterClient) processTxPipelineNode(
return err return err
} }
err = c.processTxPipelineNodeConn(ctx, node, cn, cmds, failedCmds) var processErr error
node.Client.releaseConn(ctx, cn, err) defer func() {
return err node.Client.releaseConn(ctx, cn, processErr)
}()
processErr = c.processTxPipelineNodeConn(ctx, node, cn, cmds, failedCmds)
return processErr
}) })
} }

View File

@ -342,9 +342,14 @@ func (c *baseClient) withConn(
return err return err
} }
err = fn(ctx, cn) var fnErr error
c.releaseConn(ctx, cn, err) defer func() {
return err c.releaseConn(ctx, cn, fnErr)
}()
fnErr = fn(ctx, cn)
return fnErr
} }
func (c *baseClient) dial(ctx context.Context, network, addr string) (net.Conn, error) { func (c *baseClient) dial(ctx context.Context, network, addr string) (net.Conn, error) {