| 2590 | |
| 2591 | |
| 2592 | static int blocking_ast_bdb(void* ast_object) |
| 2593 | { |
| 2594 | /************************************** |
| 2595 | * |
| 2596 | * b l o c k i n g _ a s t _ b d b |
| 2597 | * |
| 2598 | ************************************** |
| 2599 | * |
| 2600 | * Functional description |
| 2601 | * Blocking AST for buffer control blocks. This is called at |
| 2602 | * AST (signal) level to indicate that a lock is blocking another |
| 2603 | * process. If the BufferDesc* is in use, set a flag indicating that the |
| 2604 | * lock is blocking and return. When the BufferDesc is released at normal |
| 2605 | * level the lock will be down graded. If the BufferDesc* is not in use, |
| 2606 | * write the page if dirty then downgrade lock. Things would be |
| 2607 | * much hairier if UNIX supported asynchronous IO, but it doesn't. |
| 2608 | * WHEW! |
| 2609 | * |
| 2610 | **************************************/ |
| 2611 | // CVC: I assume we need the function call but not the variable. |
| 2612 | /*ThreadSync* const thread = */ThreadSync::getThread("blocking_ast_bdb"); |
| 2613 | |
| 2614 | BufferDesc* const bdb = static_cast<BufferDesc*>(ast_object); |
| 2615 | |
| 2616 | try |
| 2617 | { |
| 2618 | BufferControl* const bcb = bdb->bdb_bcb; |
| 2619 | fb_assert(!(bcb->bcb_flags & BCB_exclusive)); |
| 2620 | |
| 2621 | Database* const dbb = bcb->bcb_database; |
| 2622 | fb_assert(dbb); |
| 2623 | |
| 2624 | AsyncContextHolder tdbb(dbb, FB_FUNCTION); |
| 2625 | |
| 2626 | // Do some fancy footwork to make sure that pages are |
| 2627 | // not removed from the btc tree at AST level. Then |
| 2628 | // restore the flag to whatever it was before. |
| 2629 | |
| 2630 | const bool keep_pages = (bcb->bcb_flags & BCB_keep_pages) != 0; |
| 2631 | bcb->bcb_flags |= BCB_keep_pages; |
| 2632 | |
| 2633 | down_grade(tdbb, bdb); |
| 2634 | |
| 2635 | if (!keep_pages) |
| 2636 | bcb->bcb_flags &= ~BCB_keep_pages; |
| 2637 | |
| 2638 | if (tdbb->tdbb_status_vector->getState() & IStatus::STATE_ERRORS) |
| 2639 | iscDbLogStatus(dbb->dbb_filename.c_str(), tdbb->tdbb_status_vector); |
| 2640 | } |
| 2641 | catch (const Firebird::Exception&) |
| 2642 | { |
| 2643 | return -1; |
| 2644 | } // no-op |
| 2645 | |
| 2646 | return 0; |
| 2647 | } |
| 2648 | |
| 2649 |
nothing calls this directly
no test coverage detected