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

Function SDW_notify

src/jrd/sdw.cpp:674–728  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

672
673
674void SDW_notify(thread_db* tdbb)
675{
676/**************************************
677 *
678 * S D W _ n o t i f y
679 *
680 **************************************
681 *
682 * Functional description
683 * Notify other processes that there has been
684 * a shadow added.
685 *
686 **************************************/
687 SET_TDBB(tdbb);
688 Database* dbb = tdbb->getDatabase();
689 CHECK_DBB(dbb);
690
691 SyncLockGuard guard(&dbb->dbb_shadow_sync, SYNC_EXCLUSIVE, "SDW_notify");
692
693 // get current shadow lock count from database header page --
694 // note that since other processes need the header page to issue locks
695 // on the shadow count, this is effectively an uninterruptible operation
696
697 WIN window(HEADER_PAGE_NUMBER);
698 header_page* header = (header_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_header);
699 CCH_MARK_MUST_WRITE(tdbb, &window);
700
701 // get an exclusive lock on the current shadowing semaphore to
702 // notify other processes to find my shadow -- if we have a shared
703 // on it already, convert to exclusive
704
705 Lock* lock = dbb->dbb_shadow_lock;
706
707 if (lock->lck_physical == LCK_SR)
708 {
709 if (lock->getKey() != header->hdr_shadow_count)
710 BUGCHECK(162); // msg 162 shadow lock not synchronized properly
711 LCK_convert(tdbb, lock, LCK_EX, LCK_WAIT);
712 }
713 else
714 {
715 lock->setKey(header->hdr_shadow_count);
716 LCK_lock(tdbb, lock, LCK_EX, LCK_WAIT);
717 }
718
719 LCK_release(tdbb, lock);
720
721 // now get a shared lock on the incremented shadow count to ensure that
722 // we will get notification of the next shadow add
723
724 lock->setKey(++header->hdr_shadow_count);
725 LCK_lock(tdbb, lock, LCK_SR, LCK_WAIT);
726
727 CCH_RELEASE(tdbb, &window);
728}
729
730
731bool SDW_rollover_to_shadow(thread_db* tdbb, jrd_file* file, const bool inAst)

Callers 3

CCH_write_all_shadowsFunction · 0.85
SDW_checkFunction · 0.85
SDW_rollover_to_shadowFunction · 0.85

Calls 11

SET_TDBBFunction · 0.85
CHECK_DBBFunction · 0.85
CCH_FETCHFunction · 0.85
CCH_MARK_MUST_WRITEFunction · 0.85
LCK_convertFunction · 0.85
LCK_lockFunction · 0.85
LCK_releaseFunction · 0.85
CCH_RELEASEFunction · 0.85
getDatabaseMethod · 0.80
getKeyMethod · 0.45
setKeyMethod · 0.45

Tested by

no test coverage detected