MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / init_database_lock

Function init_database_lock

src/jrd/jrd.cpp:7628–7668  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7626
7627
7628static 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
7671static void prepare_tra(thread_db* tdbb, jrd_tra* transaction, USHORT length, const UCHAR* msg)

Callers 2

internalAttachMethod · 0.85
createDatabaseMethod · 0.85

Calls 6

SET_TDBBFunction · 0.85
LCK_lockFunction · 0.85
init_statusFunction · 0.85
check_single_maintenanceFunction · 0.85
getDatabaseMethod · 0.80
LockClass · 0.70

Tested by

no test coverage detected