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

Function expand_buffers

src/jrd/cch.cpp:3576–3612  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3574
3575
3576static bool expand_buffers(thread_db* tdbb, ULONG number)
3577{
3578/**************************************
3579 *
3580 * e x p a n d _ b u f f e r s
3581 *
3582 **************************************
3583 *
3584 * Functional description
3585 * Expand the cache to at least a given number of buffers.
3586 * If it's already that big, don't do anything.
3587 *
3588 **************************************/
3589 SET_TDBB(tdbb);
3590 Database* const dbb = tdbb->getDatabase();
3591 BufferControl* const bcb = dbb->dbb_bcb;
3592
3593 if (number <= bcb->bcb_count || number > MAX_PAGE_BUFFERS)
3594 return false;
3595
3596 SyncLockGuard syncBcb(&bcb->bcb_syncObject, SYNC_EXCLUSIVE, FB_FUNCTION);
3597
3598 if (number <= bcb->bcb_count)
3599 return false;
3600
3601 // Expand hash table only if there is no concurrent attachments
3602 if ((tdbb->getAttachment()->att_flags & ATT_exclusive) || !(bcb->bcb_flags & BCB_exclusive))
3603 bcb->bcb_hashTable->resize(number);
3604
3605 SyncLockGuard syncEmpty(&bcb->bcb_syncEmpty, SYNC_EXCLUSIVE, FB_FUNCTION);
3606 ULONG allocated = memory_init(tdbb, bcb, number - bcb->bcb_count);
3607
3608 bcb->bcb_count += allocated;
3609 bcb->bcb_free_minimum = (SSHORT) MIN(bcb->bcb_count / 4, 128); // 25% clean page reserve
3610
3611 return true;
3612}
3613
3614
3615static BufferDesc* get_dirty_buffer(thread_db* tdbb)

Callers 1

CCH_expandFunction · 0.85

Calls 5

SET_TDBBFunction · 0.85
memory_initFunction · 0.85
getDatabaseMethod · 0.80
getAttachmentMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected