| 2588 | // EngineCallbackGuard |
| 2589 | |
| 2590 | void EngineCallbackGuard::init(thread_db* tdbb, Connection& conn, const char* from) |
| 2591 | { |
| 2592 | m_tdbb = tdbb; |
| 2593 | m_mutex = &conn.m_mutex; |
| 2594 | m_saveConnection = NULL; |
| 2595 | |
| 2596 | if (m_tdbb && m_tdbb->getDatabase()) |
| 2597 | { |
| 2598 | jrd_tra* transaction = m_tdbb->getTransaction(); |
| 2599 | if (transaction) |
| 2600 | { |
| 2601 | if (transaction->tra_callback_count >= MAX_CALLBACKS) |
| 2602 | ERR_post(Arg::Gds(isc_exec_sql_max_call_exceeded)); |
| 2603 | |
| 2604 | transaction->tra_callback_count++; |
| 2605 | } |
| 2606 | |
| 2607 | Jrd::Attachment* attachment = m_tdbb->getAttachment(); |
| 2608 | if (attachment) |
| 2609 | { |
| 2610 | m_saveConnection = attachment->att_ext_connection; |
| 2611 | m_stable = attachment->getStable(); |
| 2612 | m_stable->getSync()->leave(); |
| 2613 | |
| 2614 | Jrd::AttSyncLockGuard guardAsync(*m_stable->getSync(true, true), FB_FUNCTION); |
| 2615 | Jrd::AttSyncLockGuard guardMain(*m_stable->getSync(), FB_FUNCTION); |
| 2616 | if (m_stable->getHandle() == attachment) |
| 2617 | attachment->att_ext_connection = &conn; |
| 2618 | } |
| 2619 | } |
| 2620 | |
| 2621 | if (m_mutex) { |
| 2622 | m_mutex->enter(from); |
| 2623 | } |
| 2624 | } |
| 2625 | |
| 2626 | EngineCallbackGuard::~EngineCallbackGuard() |
| 2627 | { |
no test coverage detected