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

Function SDW_lck_update

src/jrd/sdw.cpp:620–671  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

618
619
620bool SDW_lck_update(thread_db* tdbb, SLONG sdw_update_flags)
621{
622/**************************************
623 *
624 * S D W _ l c k _ u p d a t e
625 *
626 **************************************
627 *
628 * Functional description
629 * update the Lock struct with the flag
630 * The update type flag indicates the type of corrective action
631 * to be taken by the ASTs of other procs attached to this DB.
632 *
633 * A non zero sdw_update_flag is passed, it indicates error handling
634 * Two processes may encounter the Shadow array at the same time
635 * and both will want to perform corrective action. Only one should
636 * be allowed. For that,
637 * check if current data is zero, else return
638 * write the pid into the lock data, read back to verify
639 * if pid is different, another process has updated behind you, so
640 * let him handle it and return
641 * Update the data with sdw_update_flag passed to the function
642 *
643 **************************************/
644 Database* dbb = GET_DBB();
645
646 SyncLockGuard guard(&dbb->dbb_shadow_sync, SYNC_EXCLUSIVE, "SDW_lck_update");
647
648 Lock* lock = dbb->dbb_shadow_lock;
649 if (!lock)
650 return false;
651
652 if (lock->lck_physical != LCK_SR)
653 {
654 // fb_assert (lock->lck_physical == LCK_none);
655 return false;
656 }
657
658 if (!sdw_update_flags) {
659 return !LCK_read_data(tdbb, lock);
660 }
661
662 if (LCK_read_data(tdbb, lock))
663 return false;
664
665 LCK_write_data(tdbb, lock, lock->lck_id);
666 if (LCK_read_data(tdbb, lock) != lock->lck_id)
667 return false;
668
669 LCK_write_data(tdbb, lock, sdw_update_flags);
670 return true;
671}
672
673
674void SDW_notify(thread_db* tdbb)

Callers 3

CCH_write_all_shadowsFunction · 0.85
SDW_checkFunction · 0.85
SDW_rollover_to_shadowFunction · 0.85

Calls 3

GET_DBBFunction · 0.85
LCK_read_dataFunction · 0.85
LCK_write_dataFunction · 0.85

Tested by

no test coverage detected