consul: do not clear connection cache on RPC errors

This commit is contained in:
Armon Dadgar 2015-04-07 14:17:20 -07:00
parent 0ad25ece43
commit 5f921653cd
1 changed files with 7 additions and 2 deletions

View File

@ -44,6 +44,11 @@ type StreamClient struct {
client *rpc.Client
}
func (sc *StreamClient) Close() {
sc.stream.Close()
sc.client.Close()
}
// Conn is a pooled connection to a Consul server
type Conn struct {
refCount int32
@ -106,7 +111,7 @@ func (c *Conn) returnClient(client *StreamClient) {
}
c.clientLock.Unlock()
if !didSave {
client.stream.Close()
client.Close()
}
}
@ -345,7 +350,7 @@ func (p *ConnPool) RPC(addr net.Addr, version int, method string, args interface
// Make the RPC call
err = sc.client.Call(method, args, reply)
if err != nil {
p.clearConn(conn)
sc.Close()
p.releaseConn(conn)
return fmt.Errorf("rpc error: %v", err)
}