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

Method downgrade

src/lock/lock.cpp:651–714  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

649
650
651UCHAR LockManager::downgrade(thread_db* tdbb,
652 CheckStatusWrapper* statusVector,
653 const SRQ_PTR request_offset)
654{
655/**************************************
656 *
657 * d o w n g r a d e
658 *
659 **************************************
660 *
661 * Functional description
662 * Downgrade an existing lock returning
663 * its new state.
664 *
665 **************************************/
666 LOCK_TRACE(("LM::downgrade (%ld)\n", request_offset));
667
668 LockTableGuard guard(this, FB_FUNCTION, DUMMY_OWNER);
669
670 lrq* const request = get_request(request_offset);
671 const SRQ_PTR owner_offset = request->lrq_owner;
672 guard.setOwner(owner_offset);
673
674 own* const owner = (own*) SRQ_ABS_PTR(owner_offset);
675 if (!owner->own_count)
676 return LCK_none;
677
678 ++(m_sharedMemory->getHeader()->lhb_downgrades);
679
680 const lbl* lock = (lbl*) SRQ_ABS_PTR(request->lrq_lock);
681 UCHAR pending_state = LCK_none;
682
683 // Loop thru requests looking for pending conversions
684 // and find the highest requested state
685
686 srq* lock_srq;
687 SRQ_LOOP(lock->lbl_requests, lock_srq)
688 {
689 const lrq* const pending = (lrq*) ((UCHAR*) lock_srq - offsetof(lrq, lrq_lbl_requests));
690 if ((pending->lrq_flags & LRQ_pending) && pending != request)
691 {
692 pending_state = MAX(pending->lrq_requested, pending_state);
693 if (pending_state == LCK_EX)
694 break;
695 }
696 }
697
698 UCHAR state = request->lrq_state;
699 while (state > LCK_none && !compatibility[pending_state][state])
700 --state;
701
702 if (state == LCK_none || state == LCK_null)
703 {
704 internal_dequeue(request_offset);
705 state = LCK_none;
706 }
707 else
708 {

Callers

nothing calls this directly

Calls 3

internal_dequeueFunction · 0.85
setOwnerMethod · 0.45
getHeaderMethod · 0.45

Tested by

no test coverage detected