| 462 | } |
| 463 | |
| 464 | void Provider::releaseConnection(thread_db* tdbb, Connection& conn, bool inPool) |
| 465 | { |
| 466 | ConnectionsPool* connPool = conn.getConnPool(); |
| 467 | Attachment* att = conn.getBoundAtt(); |
| 468 | |
| 469 | { // m_mutex scope |
| 470 | MutexLockGuard guard(m_mutex, FB_FUNCTION); |
| 471 | |
| 472 | bool found = false; |
| 473 | AttToConnMap::Accessor acc(&m_connections); |
| 474 | if (acc.locate(AttToConn(att, &conn))) |
| 475 | { |
| 476 | Connection* test = acc.current().m_conn; |
| 477 | fb_assert(test == &conn); |
| 478 | |
| 479 | found = true; |
| 480 | acc.fastRemove(); |
| 481 | }; |
| 482 | |
| 483 | fb_assert(found); |
| 484 | conn.setBoundAtt(NULL); |
| 485 | |
| 486 | if (inPool && connPool) |
| 487 | m_connections.add(AttToConn(NULL, &conn)); |
| 488 | } |
| 489 | |
| 490 | FbLocalStatus resetError; |
| 491 | inPool = inPool && connPool && connPool->getMaxCount() && |
| 492 | conn.isConnected() && conn.hasValidCryptCallback(); |
| 493 | |
| 494 | if (inPool) |
| 495 | { |
| 496 | inPool = conn.resetSession(tdbb); |
| 497 | |
| 498 | // Check if reset of external session failed when parent (local) attachment |
| 499 | // is resetting or run ON DISCONNECT trigger. |
| 500 | |
| 501 | const auto status = tdbb->tdbb_status_vector; |
| 502 | if (!inPool && status->hasData()) |
| 503 | { |
| 504 | if (att->att_flags & ATT_resetting) |
| 505 | resetError.loadFrom(status); |
| 506 | else |
| 507 | { |
| 508 | auto req = tdbb->getRequest(); |
| 509 | while (req) |
| 510 | { |
| 511 | if (req->req_trigger_action == TRIGGER_DISCONNECT) |
| 512 | { |
| 513 | resetError.loadFrom(status); |
| 514 | break; |
| 515 | } |
| 516 | req = req->req_caller; |
| 517 | } |
| 518 | } |
| 519 | } |
| 520 | } |
| 521 |
no test coverage detected