MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / putConnection

Method putConnection

src/jrd/extds/ExtDS.cpp:962–1063  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

960}
961
962void ConnectionsPool::putConnection(thread_db* tdbb, Connection* conn)
963{
964 fb_assert(conn->getConnPool() == this);
965
966 Connection* oldConn = NULL;
967 Firebird::RefPtr<IdleTimer> timer;
968
969 if (m_maxCount > 0)
970 {
971 MutexLockGuard guard(m_mutex, FB_FUNCTION);
972
973 Data* item = conn->getPoolData();
974#ifdef EDS_DEBUG
975 if (!verifyPool())
976 {
977 string str;
978 str.printf("Before put Item 0x%08X into pool\n", item);
979 printPool(str);
980 gds__log("Procces ID %d: connections pool is corrupted\n%s", getpid(), str.c_str());
981 }
982#endif
983
984 if (item->m_lastUsed)
985 {
986 // Item was already put into idle list
987 fb_assert(item->m_connPool == this);
988 return;
989 }
990
991 if (m_allCount > m_maxCount)
992 {
993 Data* oldest = removeOldest();
994 if (oldest == item)
995 {
996#ifdef EDS_DEBUG
997 string str;
998 str.printf("Item 0x%08X to put into pool is oldest", item);
999 gds__log("Procces ID %d: %s", getpid(), str.c_str());
1000#endif
1001 m_allCount++;
1002 oldest = removeOldest();
1003 }
1004
1005 if (oldest)
1006 oldConn = oldest->m_conn;
1007 }
1008
1009 if (item->m_lastUsed)
1010 {
1011 FB_SIZE_T pos;
1012 fb_assert(m_idleArray.find(*item, pos));
1013
1014#ifdef EDS_DEBUG
1015 const bool ok = verifyPool();
1016 string str;
1017 str.printf("Idle item 0x%08X put back into pool. Pool is %s", item, ok ? "OK" : "corrupted\n");
1018
1019 if (!ok)

Callers 1

releaseConnectionMethod · 0.80

Calls 10

IdleTimerClass · 0.85
getPoolDataMethod · 0.80
releaseConnectionMethod · 0.80
getConnPoolMethod · 0.45
printfMethod · 0.45
c_strMethod · 0.45
findMethod · 0.45
addMethod · 0.45
getProviderMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected