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

Method grant_or_que

src/lock/lock.cpp:2184–2238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2182
2183
2184bool LockManager::grant_or_que(thread_db* tdbb, lrq* request, lbl* lock, SSHORT lck_wait)
2185{
2186/**************************************
2187 *
2188 * g r a n t _ o r _ q u e
2189 *
2190 **************************************
2191 *
2192 * Functional description
2193 * There is a request against an existing lock. If the request
2194 * is compatible with the lock, grant it. Otherwise lock_srq it.
2195 * If the lock is lock_srq-ed, set up the machinery to do a deadlock
2196 * scan in awhile.
2197 *
2198 **************************************/
2199 request->lrq_lock = SRQ_REL_PTR(lock);
2200
2201 // Compatible requests are easy to satify. Just post the request to the lock,
2202 // update the lock state, release the data structure, and we're done.
2203
2204 if (compatibility[request->lrq_requested][lock->lbl_state])
2205 {
2206 if (request->lrq_requested == LCK_null || lock->lbl_pending_lrq_count == 0)
2207 {
2208 grant(request, lock);
2209 post_pending(lock);
2210 return true;
2211 }
2212 }
2213
2214 // The request isn't compatible with the current state of the lock.
2215 // If we haven't be asked to wait for the lock, return now.
2216
2217 if (lck_wait)
2218 {
2219 const SRQ_PTR request_offset = SRQ_REL_PTR(request);
2220
2221 wait_for_request(tdbb, request, lck_wait);
2222
2223 request = (lrq*) SRQ_ABS_PTR(request_offset);
2224
2225 if (!(request->lrq_flags & LRQ_rejected))
2226 return true;
2227 }
2228
2229 post_history(his_deny, request->lrq_owner, request->lrq_lock, SRQ_REL_PTR(request), true);
2230 ASSERT_ACQUIRED;
2231 ++(m_sharedMemory->getHeader()->lhb_denies);
2232 if (lck_wait < 0)
2233 ++(m_sharedMemory->getHeader()->lhb_timeouts);
2234
2235 release_request(request);
2236
2237 return false;
2238}
2239
2240
2241bool LockManager::init_owner_block(CheckStatusWrapper* statusVector, own* owner, UCHAR owner_type,

Callers

nothing calls this directly

Calls 2

release_requestFunction · 0.50
getHeaderMethod · 0.45

Tested by

no test coverage detected