| 176 | |
| 177 | |
| 178 | void TraceManager::update_sessions() |
| 179 | { |
| 180 | // Let be inactive until database is creating |
| 181 | if (attachment && (attachment->att_database->dbb_flags & DBB_creating)) |
| 182 | return; |
| 183 | |
| 184 | MemoryPool& pool = *getDefaultMemoryPool(); |
| 185 | SortedArray<ULONG, InlineStorage<ULONG, 64> > liveSessions(pool); |
| 186 | HalfStaticArray<TraceSession*, 64> newSessions(pool); |
| 187 | |
| 188 | { // scope |
| 189 | ConfigStorage* storage = getStorage(); |
| 190 | |
| 191 | // don't attach going attachment to the new trace sessions, it allows |
| 192 | // to avoid problems later - when mapping uses this going attachment |
| 193 | const bool noNewSessions = attachment && (attachment->att_purge_tid); |
| 194 | |
| 195 | StorageGuard guard(storage); |
| 196 | ConfigStorage::Accessor acc(&guard); |
| 197 | |
| 198 | TraceSession session(pool); |
| 199 | while (acc.getNext(session, ConfigStorage::FLAGS)) |
| 200 | { |
| 201 | if ((session.ses_flags & trs_active) && !(session.ses_flags & trs_log_full)) |
| 202 | { |
| 203 | FB_SIZE_T pos; |
| 204 | if (trace_sessions.find(session.ses_id, pos)) |
| 205 | liveSessions.add(session.ses_id); |
| 206 | else if (!noNewSessions) |
| 207 | { |
| 208 | storage->getSession(session, ConfigStorage::ALL); |
| 209 | newSessions.add(FB_NEW_POOL(pool) TraceSession(pool, session)); |
| 210 | } |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | changeNumber = storage->getChangeNumber(); |
| 215 | } |
| 216 | |
| 217 | // remove sessions not present in storage |
| 218 | FB_SIZE_T i = 0; |
| 219 | while (i < trace_sessions.getCount()) |
| 220 | { |
| 221 | FB_SIZE_T pos; |
| 222 | if (liveSessions.find(trace_sessions[i].ses_id, pos)) { |
| 223 | i++; |
| 224 | } |
| 225 | else |
| 226 | { |
| 227 | trace_sessions[i].plugin->release(); |
| 228 | trace_sessions.remove(i); |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | // add new sessions |
| 233 | new_needs = trace_needs; |
| 234 | trace_needs = 0; |
| 235 | while (newSessions.hasData()) |
nothing calls this directly
no test coverage detected