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

Function CCH_fake

src/jrd/cch.cpp:679–771  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

677
678
679pag* CCH_fake(thread_db* tdbb, WIN* window, int wait)
680{
681/**************************************
682 *
683 * C C H _ f a k e
684 *
685 **************************************
686 *
687 * Functional description
688 * Fake a fetch to a page. Rather than reading it, however,
689 * zero it in memory. This is used when allocating a new page.
690 *
691 * input
692 * wait: 1 => Wait as long as necessary to get the latch.
693 * This can cause deadlocks of course.
694 * 0 => If the latch can't be acquired immediately,
695 * or an IO would be necessary, then give
696 * up and return 0.
697 * <negative number> => Latch timeout interval in seconds.
698 *
699 * return
700 * pag pointer if successful.
701 * NULL pointer if timeout occurred (only possible if wait <> 1).
702 * NULL pointer if wait=0 and the faked page would have to be
703 * before reuse.
704 *
705 **************************************/
706 SET_TDBB(tdbb);
707 Database* const dbb = tdbb->getDatabase();
708 BufferControl *bcb = dbb->dbb_bcb;
709
710 CCH_TRACE(("FAKE %d:%06d", window->win_page.getPageSpaceID(), window->win_page.getPageNum()));
711
712 // if there has been a shadow added recently, go out and
713 // find it before we grant any more write locks
714
715 if (dbb->dbb_ast_flags & DBB_get_shadows)
716 SDW_get_shadows(tdbb);
717
718 BufferDesc* bdb = get_buffer(tdbb, window->win_page, SYNC_EXCLUSIVE, wait);
719 if (!bdb)
720 return NULL; // latch timeout occurred
721
722 fb_assert(bdb->bdb_page == window->win_page);
723
724 // If a dirty orphaned page is being reused - better write it first
725 // to clear current precedences and checkpoint state. This would also
726 // update the bcb_free_pages field appropriately.
727
728 if (bdb->bdb_flags & (BDB_dirty | BDB_db_dirty))
729 {
730 // If the caller didn't want to wait at all, then
731 // return 'try to fake an other page' to the caller.
732
733 if (!wait)
734 {
735 bdb->release(tdbb, true);
736 return NULL;

Callers 5

PAG_add_fileFunction · 0.85
PAG_allocate_pagesFunction · 0.85
ensureDiskSpaceFunction · 0.85
PAG_format_headerFunction · 0.85
PAG_format_pipFunction · 0.85

Calls 14

SET_TDBBFunction · 0.85
SDW_get_shadowsFunction · 0.85
get_bufferFunction · 0.85
write_bufferFunction · 0.85
CCH_unwindFunction · 0.85
QUE_NOT_EMPTYFunction · 0.85
clear_precedenceFunction · 0.85
lock_bufferFunction · 0.85
CCH_MARKFunction · 0.85
getDatabaseMethod · 0.80
getPageSpaceIDMethod · 0.80
getPageNumMethod · 0.80

Tested by

no test coverage detected