Commit e522dbee authored by jan.koester's avatar jan.koester
Browse files

test

parent 4edc7c59
Loading
Loading
Loading
Loading
Loading
+10 −0
Changes for client/client.cpp: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -1267,7 +1267,15 @@ ConnectionPool::ConnectionPool(const std::string& url,

ConnectionPool::~ConnectionPool() = default;

void ConnectionPool::setTlsVerify(bool verify) {
    std::lock_guard<std::mutex> lk(_Mutex);
    _TlsVerify = verify;
    for (auto& entry : _Idle)
        entry.con->setTlsVerify(verify);
}

PooledConnection ConnectionPool::acquire() {
    bool tls_verify = true;
    {
        std::lock_guard<std::mutex> lk(_Mutex);
        if (!_Idle.empty()) {
@@ -1275,12 +1283,14 @@ PooledConnection ConnectionPool::acquire() {
            _Idle.pop_front();
            return PooledConnection(this, std::move(entry.con), std::move(entry.clt));
        }
        tls_verify = _TlsVerify;
    }
    // Create new connection
    auto con = std::make_unique<ClientConnection>();
    con->setUrl(_Url);
    con->setClientName(_CltName);
    con->setClientSecret(_CltSecret);
    con->setTlsVerify(tls_verify);
    auto clt = std::make_unique<Client>(*con);
    return PooledConnection(this, std::move(con), std::move(clt));
}
+5 −0
Changes for client/client.h: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -215,6 +215,10 @@ namespace authdb {
            ConnectionPool(const ConnectionPool&) = delete;
            ConnectionPool& operator=(const ConnectionPool&) = delete;

            // Configure TLS peer verification for connections created by the
            // pool. Applied before Client construction opens the socket.
            void setTlsVerify(bool verify);

            // Acquire a ready-to-use connection (creates new if pool empty)
            PooledConnection acquire();

@@ -227,6 +231,7 @@ namespace authdb {
            std::string _CltName;
            std::string _CltSecret;
            std::size_t _MaxIdle;
            bool        _TlsVerify = true;
            std::mutex  _Mutex;

            struct IdleEntry {