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); }