MCPcopy Create free account
hub / github.com/acl-dev/acl / get

Method get

lib_acl_cpp/src/connpool/connect_manager.cpp:350–397  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

348}
349
350connect_pool* connect_manager::get(const char* addr,
351 bool exclusive /* = true */, bool restore /* = false */)
352{
353 string key;
354 get_key(addr, key);
355 unsigned long id = get_id();
356
357 if (exclusive) {
358 lock_.lock();
359 }
360
361 conns_pools& pools = get_pools_by_id(id);
362
363 pools_t::iterator it = pools.pools.begin();
364 for (; it != pools.pools.end(); ++it) {
365 if (key == (*it)->get_key()) {
366 if (restore && !(*it)->aliving()) {
367 (*it)->set_alive(true);
368 }
369 if (exclusive) {
370 lock_.unlock();
371 }
372 return *it;
373 }
374 }
375
376 string buf(addr);
377 buf.lower();
378
379 std::map<string, conn_config>::const_iterator cit = addrs_.find(buf);
380 if (cit == addrs_.end()) {
381 if (exclusive) {
382 lock_.unlock();
383 }
384 logger_debug(ACL_CPP_DEBUG_CONN_MANAGER, 1,
385 "no connect pool for addr %s", addr);
386 return NULL;
387 }
388
389 connect_pool* pool = create_pool(cit->second, pools.pools.size());
390 pools.pools.push_back(pool);
391
392 if (exclusive) {
393 lock_.unlock();
394 }
395
396 return pool;
397}
398
399//////////////////////////////////////////////////////////////////////////
400

Callers 1

addr_existMethod · 0.45

Calls 12

beginMethod · 0.80
get_keyFunction · 0.50
get_idFunction · 0.50
lockMethod · 0.45
endMethod · 0.45
get_keyMethod · 0.45
alivingMethod · 0.45
set_aliveMethod · 0.45
unlockMethod · 0.45
findMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected