|
@@ -168,7 +168,7 @@ func (p *policyConnPool) SetHosts(hosts []*HostInfo) {
|
|
|
for addr := range toRemove {
|
|
for addr := range toRemove {
|
|
|
pool := p.hostConnPools[addr]
|
|
pool := p.hostConnPools[addr]
|
|
|
delete(p.hostConnPools, addr)
|
|
delete(p.hostConnPools, addr)
|
|
|
- pool.Close()
|
|
|
|
|
|
|
+ go pool.Close()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// update the policy
|
|
// update the policy
|
|
@@ -279,7 +279,7 @@ func (p *policyConnPool) removeHost(addr string) {
|
|
|
delete(p.hostConnPools, addr)
|
|
delete(p.hostConnPools, addr)
|
|
|
p.mu.Unlock()
|
|
p.mu.Unlock()
|
|
|
|
|
|
|
|
- pool.Close()
|
|
|
|
|
|
|
+ go pool.Close()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (p *policyConnPool) hostUp(host *HostInfo) {
|
|
func (p *policyConnPool) hostUp(host *HostInfo) {
|
|
@@ -381,8 +381,7 @@ func (pool *hostConnPool) Close() {
|
|
|
}
|
|
}
|
|
|
pool.closed = true
|
|
pool.closed = true
|
|
|
|
|
|
|
|
- // drain, but don't wait
|
|
|
|
|
- go pool.drain()
|
|
|
|
|
|
|
+ pool.drainLocked()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Fill the connection pool
|
|
// Fill the connection pool
|
|
@@ -569,14 +568,10 @@ func (pool *hostConnPool) HandleError(conn *Conn, err error, closed bool) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// removes and closes all connections from the pool
|
|
|
|
|
-func (pool *hostConnPool) drain() {
|
|
|
|
|
- pool.mu.Lock()
|
|
|
|
|
- defer pool.mu.Unlock()
|
|
|
|
|
-
|
|
|
|
|
|
|
+func (pool *hostConnPool) drainLocked() {
|
|
|
// empty the pool
|
|
// empty the pool
|
|
|
conns := pool.conns
|
|
conns := pool.conns
|
|
|
- pool.conns = pool.conns[:0:0]
|
|
|
|
|
|
|
+ pool.conns = nil
|
|
|
|
|
|
|
|
// update the policy
|
|
// update the policy
|
|
|
pool.policy.SetConns(nil)
|
|
pool.policy.SetConns(nil)
|
|
@@ -586,3 +581,10 @@ func (pool *hostConnPool) drain() {
|
|
|
conn.Close()
|
|
conn.Close()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+// removes and closes all connections from the pool
|
|
|
|
|
+func (pool *hostConnPool) drain() {
|
|
|
|
|
+ pool.mu.Lock()
|
|
|
|
|
+ defer pool.mu.Unlock()
|
|
|
|
|
+ pool.drainLocked()
|
|
|
|
|
+}
|