From 541e894507f896307af00c23de1dd985bfd6daf5 Mon Sep 17 00:00:00 2001 From: bogle Date: Sat, 26 May 2018 15:38:41 +0800 Subject: [PATCH] just update the pool configuration if the options changed, because recreating the pool,existed idleconnection, if any, will be dropped without closing --- client/rpc_client.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/client/rpc_client.go b/client/rpc_client.go index 1ceef41c..1b37155c 100644 --- a/client/rpc_client.go +++ b/client/rpc_client.go @@ -202,9 +202,12 @@ func (r *rpcClient) Init(opts ...Option) error { o(&r.opts) } - // recreate the pool if the options changed + // update pool configuration if the options changed if size != r.opts.PoolSize || ttl != r.opts.PoolTTL { - r.pool = newPool(r.opts.PoolSize, r.opts.PoolTTL) + r.pool.Lock() + r.pool.size = r.opts.PoolSize + r.pool.ttl = int64(r.opts.PoolTTL.Seconds()) + r.pool.Unlock() } return nil