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

Function get_buffer

src/jrd/cch.cpp:3778–3988  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3776
3777
3778static BufferDesc* get_buffer(thread_db* tdbb, const PageNumber page, SyncType syncType, int wait)
3779{
3780/**************************************
3781 *
3782 * g e t _ b u f f e r
3783 *
3784 **************************************
3785 *
3786 * Functional description
3787 * Get a buffer. If possible, get a buffer already assigned
3788 * to the page. Otherwise get one from the free list or pick
3789 * the least recently used buffer to be reused.
3790 *
3791 * input
3792 * page: page to get
3793 * syncType: type of lock to acquire on the page.
3794 * wait: 1 => Wait as long as necessary to get the lock.
3795 * This can cause deadlocks of course.
3796 * 0 => If the lock can't be acquired immediately,
3797 * give up and return 0;
3798 * <negative number> => Latch timeout interval in seconds.
3799 *
3800 * return
3801 * BufferDesc pointer if successful.
3802 * NULL pointer if timeout occurred (only possible is wait <> 1).
3803 * if cache manager doesn't have any pages to write anymore.
3804 *
3805 **************************************/
3806 SET_TDBB(tdbb);
3807 Database* dbb = tdbb->getDatabase();
3808 BufferControl* bcb = dbb->dbb_bcb;
3809 Attachment* att = tdbb->getAttachment();
3810
3811 if (att && att->att_bdb_cache)
3812 {
3813 if (BufferDesc* bdb = att->att_bdb_cache->get(page))
3814 {
3815 if (bdb->addRef(tdbb, syncType, wait))
3816 {
3817 if (bdb->bdb_page == page)
3818 {
3819 recentlyUsed(bdb);
3820 tdbb->bumpStats(RuntimeStatistics::PAGE_FETCHES);
3821 return bdb;
3822 }
3823
3824 bdb->release(tdbb, true);
3825 att->att_bdb_cache->remove(page);
3826 }
3827 else
3828 {
3829 fb_assert(wait <= 0);
3830 if (bdb->bdb_page == page)
3831 return nullptr;
3832 }
3833 }
3834 }
3835

Callers 3

CCH_fakeFunction · 0.85
CCH_fetch_lockFunction · 0.85
prefetch_prologueFunction · 0.85

Calls 15

SET_TDBBFunction · 0.85
recentlyUsedFunction · 0.85
cacheBufferFunction · 0.85
QUE_NOT_EMPTYFunction · 0.85
QUE_DELETEFunction · 0.85
QUE_INITFunction · 0.85
get_oldest_bufferFunction · 0.85
QUE_INSERTFunction · 0.85
getDatabaseMethod · 0.80
bumpStatsMethod · 0.80
yieldClass · 0.50
getAttachmentMethod · 0.45

Tested by

no test coverage detected