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

Function CCH_flush_ast

src/jrd/cch.cpp:1297–1339  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1295}
1296
1297void CCH_flush_ast(thread_db* tdbb)
1298{
1299/**************************************
1300 *
1301 * C C H _ f l u s h _ a s t
1302 *
1303 **************************************
1304 *
1305 * Functional description
1306 * Flush all buffers coming from database file.
1307 * Should be called from AST
1308 *
1309 **************************************/
1310 SET_TDBB(tdbb);
1311
1312 Database* dbb = tdbb->getDatabase();
1313 BufferControl* bcb = dbb->dbb_bcb;
1314
1315 if (bcb->bcb_flags & BCB_exclusive)
1316 CCH_flush(tdbb, FLUSH_ALL, 0);
1317 else
1318 {
1319 SyncLockGuard bcbSync(&bcb->bcb_syncObject, SYNC_SHARED, FB_FUNCTION);
1320
1321 // Do some fancy footwork to make sure that pages are
1322 // not removed from the btc tree at AST level. Then
1323 // restore the flag to whatever it was before.
1324 const bool keep_pages = bcb->bcb_flags & BCB_keep_pages;
1325 bcb->bcb_flags |= BCB_keep_pages;
1326
1327 for (auto blk : bcb->bcb_bdbBlocks)
1328 {
1329 for (BufferDesc* bdb = blk.m_bdbs; bdb < blk.m_bdbs + blk.m_count; bdb++)
1330 {
1331 if (bdb->bdb_flags & (BDB_dirty | BDB_db_dirty))
1332 down_grade(tdbb, bdb, 1);
1333 }
1334 }
1335
1336 if (!keep_pages)
1337 bcb->bcb_flags &= ~BCB_keep_pages;
1338 }
1339}
1340
1341bool CCH_free_page(thread_db* tdbb)
1342{

Callers 1

blockingAstHandlerMethod · 0.85

Calls 4

SET_TDBBFunction · 0.85
CCH_flushFunction · 0.85
down_gradeFunction · 0.85
getDatabaseMethod · 0.80

Tested by

no test coverage detected