| 7626 | |
| 7627 | |
| 7628 | static void init_database_lock(thread_db* tdbb) |
| 7629 | { |
| 7630 | /************************************** |
| 7631 | * |
| 7632 | * i n i t _ d a t a b a s e _ l o c k |
| 7633 | * |
| 7634 | ************************************** |
| 7635 | * |
| 7636 | * Functional description |
| 7637 | * Initialize the main database lock. |
| 7638 | * |
| 7639 | **************************************/ |
| 7640 | SET_TDBB(tdbb); |
| 7641 | Database* const dbb = tdbb->getDatabase(); |
| 7642 | |
| 7643 | // Main database lock |
| 7644 | |
| 7645 | Lock* const lock = FB_NEW_RPT(*dbb->dbb_permanent, 0) |
| 7646 | Lock(tdbb, 0, LCK_database, dbb, CCH_down_grade_dbb); |
| 7647 | dbb->dbb_lock = lock; |
| 7648 | |
| 7649 | // Try to get an exclusive lock on database. |
| 7650 | // If this fails, insist on at least a shared lock. |
| 7651 | |
| 7652 | dbb->dbb_flags |= DBB_exclusive; |
| 7653 | if (!LCK_lock(tdbb, lock, LCK_EX, LCK_NO_WAIT)) |
| 7654 | { |
| 7655 | // Clean status vector from lock manager error code |
| 7656 | fb_utils::init_status(tdbb->tdbb_status_vector); |
| 7657 | |
| 7658 | dbb->dbb_flags &= ~DBB_exclusive; |
| 7659 | |
| 7660 | while (!LCK_lock(tdbb, lock, LCK_SW, -1)) |
| 7661 | { |
| 7662 | fb_utils::init_status(tdbb->tdbb_status_vector); |
| 7663 | |
| 7664 | // If we are in a single-threaded maintenance mode then clean up and stop waiting |
| 7665 | check_single_maintenance(tdbb); |
| 7666 | } |
| 7667 | } |
| 7668 | } |
| 7669 | |
| 7670 | |
| 7671 | static void prepare_tra(thread_db* tdbb, jrd_tra* transaction, USHORT length, const UCHAR* msg) |
no test coverage detected