Beispiel #1
0
 DBClientBase * PoolForHost::get() {
     
     time_t now = time(0);
     
     while ( ! _pool.empty() ){
         StoredConnection sc = _pool.top();
         _pool.pop();
         if ( sc.ok( now ) )
             return sc.conn;
         delete sc.conn;
     }
     
     return NULL;
 }
Beispiel #2
0
void PoolForHost::getStaleConnections(vector<DBClientBase*>& stale) {
    time_t now = time(0);

    vector<StoredConnection> all;
    while (!_pool.empty()) {
        StoredConnection c = _pool.top();
        _pool.pop();

        if (c.ok(now))
            all.push_back(c);
        else
            stale.push_back(c.conn);
    }

    for (size_t i = 0; i < all.size(); i++) {
        _pool.push(all[i]);
    }
}
Beispiel #3
0
DBClientBase* PoolForHost::get(DBConnectionPool* pool, double socketTimeout) {
    time_t now = time(0);

    while (!_pool.empty()) {
        StoredConnection sc = _pool.top();
        _pool.pop();

        if (!sc.ok(now)) {
            pool->onDestroy(sc.conn);
            delete sc.conn;
            continue;
        }

        verify(sc.conn->getSoTimeout() == socketTimeout);

        return sc.conn;
    }

    return NULL;
}