From 5a29b47c6cf683ed66ca670264031d739652dda1 Mon Sep 17 00:00:00 2001 From: fasiondog Date: Wed, 5 Aug 2020 22:37:04 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E6=B1=A0=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=9C=80=E5=A4=A7=E8=BF=9E=E6=8E=A5=E6=95=B0=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hikyuu_cpp/hikyuu/utilities/ConnectPool.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hikyuu_cpp/hikyuu/utilities/ConnectPool.h b/hikyuu_cpp/hikyuu/utilities/ConnectPool.h index 4859c8c1..b34324e7 100644 --- a/hikyuu_cpp/hikyuu/utilities/ConnectPool.h +++ b/hikyuu_cpp/hikyuu/utilities/ConnectPool.h @@ -35,7 +35,7 @@ public: * @param maxIdleConnect 运行的最大空闲连接数,为 0 表示不限制 */ explicit ConnectPool(const Parameter ¶m, size_t maxConnect = 0, size_t maxIdleConnect = 0) - : m_maxConnectSize(0), + : m_maxConnectSize(maxConnect), m_maxIdelSize(maxIdleConnect), m_count(0), m_param(param), @@ -60,10 +60,10 @@ public: /** 获取可用连接,如超出允许的最大连接数将返回空指针 */ ConnectPtr getConnect() noexcept { std::lock_guard lock(m_mutex); - if (m_maxConnectSize > 0 && m_count > m_maxConnectSize) { - return ConnectPtr(); - } if (m_connectList.empty()) { + if (m_maxConnectSize > 0 && m_count >= m_maxConnectSize) { + return ConnectPtr(); + } m_count++; return ConnectPtr(new ConnectType(m_param), m_closer); }