From d25287c7b2c067932ea68aa521f2d0565ba3cd1b Mon Sep 17 00:00:00 2001 From: Bo Liu Date: Fri, 18 Sep 2020 06:20:08 +0000 Subject: [PATCH] [thrift_client_pool] proactively close connections --- common/thrift_client_pool.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/common/thrift_client_pool.h b/common/thrift_client_pool.h index d903c7fe..6c558776 100644 --- a/common/thrift_client_pool.h +++ b/common/thrift_client_pool.h @@ -311,9 +311,15 @@ class ThriftClientPool { // won't keep a !good() channels for a long period of time. if (itor->second.first.use_count() == 0) { itor = channels_.erase(itor); - } else { - ++itor; + continue; + } + + auto c = itor->second.first.lock(); + if (c && !(itor->second.second->is_good.load())) { + c->closeNow(); } + + ++itor; } } }