From 7400c07728274f45b8a7e9b0bd2d61fe35073629 Mon Sep 17 00:00:00 2001 From: Jia Zhan Date: Sat, 11 Dec 2021 07:25:25 +0000 Subject: [PATCH] thrift_client_pool: close bad channel before creating a new one --- common/thrift_client_pool.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/thrift_client_pool.h b/common/thrift_client_pool.h index 65039ab6..7432e4b6 100644 --- a/common/thrift_client_pool.h +++ b/common/thrift_client_pool.h @@ -237,6 +237,11 @@ class ThriftClientPool { // good for use and it's not too soon to create a new one or we want to // be aggressive if (!channel_good && (!too_soon || aggressively)) { + // close the bad channel before establising a new one. + // This is to avoid potentially accumulating CLOSE_WAIT on the client side. + if (channel) { + channel->closeNow(); + } should_new_channel = true; } }