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

Method enqueue

src/lock/lock.cpp:452–602  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

450
451
452SRQ_PTR LockManager::enqueue(thread_db* tdbb,
453 CheckStatusWrapper* statusVector,
454 SRQ_PTR prior_request,
455 const USHORT series,
456 const UCHAR* value,
457 const USHORT length,
458 UCHAR type,
459 lock_ast_t ast_routine,
460 void* ast_argument,
461 LOCK_DATA_T data,
462 SSHORT lck_wait,
463 SRQ_PTR owner_offset)
464{
465/**************************************
466 *
467 * e n q u e u e
468 *
469 **************************************
470 *
471 * Functional description
472 * Enque on a lock. If the lock can't be granted immediately,
473 * return an event count on which to wait. If the lock can't
474 * be granted because of deadlock, return NULL.
475 *
476 **************************************/
477 LOCK_TRACE(("LM::enqueue (%ld)\n", owner_offset));
478
479 if (!owner_offset)
480 return 0;
481
482 LockTableGuard guard(this, FB_FUNCTION, owner_offset);
483
484 own* owner = (own*) SRQ_ABS_PTR(owner_offset);
485 if (!owner->own_count)
486 return 0;
487
488 ASSERT_ACQUIRED;
489 ++(m_sharedMemory->getHeader()->lhb_enqs);
490
491#ifdef VALIDATE_LOCK_TABLE
492 if ((m_sharedMemory->getHeader()->lhb_enqs % 50) == 0)
493 validate_lhb(m_sharedMemory->getHeader());
494#endif
495
496 if (prior_request)
497 internal_dequeue(prior_request);
498
499 // Allocate or reuse a lock request block
500
501 lrq* request;
502
503 ASSERT_ACQUIRED;
504 if (SRQ_EMPTY(m_sharedMemory->getHeader()->lhb_free_requests))
505 {
506 if (!(request = (lrq*) alloc(sizeof(lrq), statusVector)))
507 return 0;
508
509 owner = (own*) SRQ_ABS_PTR(owner_offset);

Callers

nothing calls this directly

Calls 4

internal_dequeueFunction · 0.85
GdsClass · 0.85
getHeaderMethod · 0.45
copyToMethod · 0.45

Tested by

no test coverage detected