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

Function SDW_rollover_to_shadow

src/jrd/sdw.cpp:731–875  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

729
730
731bool SDW_rollover_to_shadow(thread_db* tdbb, jrd_file* file, const bool inAst)
732{
733/**************************************
734 *
735 * S D W _ r o l l o v e r _ t o _ s h a d o w
736 *
737 **************************************
738 *
739 * Functional description
740 *
741 **************************************/
742 SET_TDBB(tdbb);
743 Database* dbb = tdbb->getDatabase();
744
745 PageSpace* pageSpace = dbb->dbb_page_manager.findPageSpace(DB_PAGE_SPACE);
746 if (file != pageSpace->file)
747 return true;
748
749 SyncLockGuard guard(&dbb->dbb_shadow_sync, SYNC_EXCLUSIVE, "SDW_rollover_to_shadow");
750
751 SLONG sdw_update_flags = SDW_rollover;
752
753 // If our attachment is already purged and an error comes from
754 // CCH_fini(), then consider us accessing the shadow exclusively.
755 // LCK_update_shadow locking isn't going to work anyway. The below
756 // code must be executed for valid active attachments only.
757
758 AutoPtr<Lock> update_lock;
759
760 if (tdbb->getAttachment())
761 {
762 update_lock = FB_NEW_RPT(*tdbb->getDefaultPool(), 0)
763 Lock(tdbb, sizeof(SLONG), LCK_update_shadow);
764 update_lock->setKey(-1);
765
766 LCK_lock(tdbb, update_lock, LCK_EX, LCK_NO_WAIT);
767
768 if (update_lock->lck_physical != LCK_EX ||
769 file != pageSpace->file || !SDW_lck_update(tdbb, sdw_update_flags))
770 {
771 LCK_release(tdbb, update_lock);
772 LCK_lock(tdbb, update_lock, LCK_SR, LCK_NO_WAIT);
773 while (update_lock->lck_physical != LCK_SR)
774 {
775 if (dbb->dbb_ast_flags & DBB_get_shadows)
776 break;
777 if ((file != pageSpace->file ) || !dbb->dbb_shadow_lock)
778 break;
779 LCK_lock(tdbb, update_lock, LCK_SR, LCK_NO_WAIT);
780 }
781
782 if (update_lock->lck_physical == LCK_SR)
783 LCK_release(tdbb, update_lock);
784
785 return true;
786 }
787 }
788 else

Callers 1

CCH_rollover_to_shadowFunction · 0.85

Calls 15

SET_TDBBFunction · 0.85
LCK_lockFunction · 0.85
SDW_lck_updateFunction · 0.85
LCK_releaseFunction · 0.85
LCK_write_dataFunction · 0.85
SDW_check_conditionalFunction · 0.85
SDW_notifyFunction · 0.85
CCH_unwindFunction · 0.85
SDW_dump_pagesFunction · 0.85
GdsClass · 0.85
getDatabaseMethod · 0.80
findPageSpaceMethod · 0.80

Tested by

no test coverage detected