| 1063 | } |
| 1064 | |
| 1065 | void ConnectionsPool::addConnection(thread_db* tdbb, Connection* conn, ULONG hash) |
| 1066 | { |
| 1067 | Data* item = conn->getPoolData(); |
| 1068 | item->m_hash = hash; |
| 1069 | item->m_lastUsed = 0; |
| 1070 | item->setConnPool(this); |
| 1071 | |
| 1072 | Connection* oldConn = NULL; |
| 1073 | { // scope |
| 1074 | MutexLockGuard guard(m_mutex, FB_FUNCTION); |
| 1075 | |
| 1076 | #ifdef EDS_DEBUG |
| 1077 | if (!verifyPool()) |
| 1078 | { |
| 1079 | string str; |
| 1080 | printPool(str); |
| 1081 | str.printf("Before add Item 0x%08X into pool\n", item); |
| 1082 | gds__log("Procces ID %d: connections pool is corrupted\n%s", getpid(), str.c_str()); |
| 1083 | } |
| 1084 | #endif |
| 1085 | if (m_allCount >= m_maxCount) |
| 1086 | { |
| 1087 | Data* oldest = removeOldest(); |
| 1088 | if (oldest) |
| 1089 | oldConn = oldest->m_conn; |
| 1090 | } |
| 1091 | |
| 1092 | addToList(&m_activeList, item); |
| 1093 | m_allCount++; |
| 1094 | |
| 1095 | #ifdef EDS_DEBUG |
| 1096 | if (!verifyPool()) |
| 1097 | { |
| 1098 | string str; |
| 1099 | printPool(str); |
| 1100 | str.printf("After add Item 0x%08X into pool\n", item); |
| 1101 | gds__log("Procces ID %d: connections pool is corrupted\n%s", getpid(), str.c_str()); |
| 1102 | } |
| 1103 | #endif |
| 1104 | } |
| 1105 | |
| 1106 | if (oldConn) |
| 1107 | oldConn->getProvider()->releaseConnection(tdbb, *oldConn, false); |
| 1108 | } |
| 1109 | |
| 1110 | void ConnectionsPool::delConnection(thread_db* tdbb, Connection* conn, bool destroy) |
| 1111 | { |
no test coverage detected