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

Function CCH_flush

src/jrd/cch.cpp:1181–1295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1179
1180
1181void CCH_flush(thread_db* tdbb, USHORT flush_flag, TraNumber tra_number)
1182{
1183/**************************************
1184 *
1185 * C C H _ f l u s h
1186 *
1187 **************************************
1188 *
1189 * Functional description
1190 * Flush all buffers. If the release flag is set,
1191 * release all locks.
1192 *
1193 **************************************/
1194 SET_TDBB(tdbb);
1195 Database* dbb = tdbb->getDatabase();
1196
1197 // note that some of the code for btc_flush()
1198 // replicates code in the for loop
1199 // to minimize call overhead -- changes should be made in both places
1200
1201 if (flush_flag & (FLUSH_TRAN | FLUSH_SYSTEM))
1202 {
1203 const ULONG transaction_mask = tra_number ? 1L << (tra_number & (BITS_PER_LONG - 1)) : 0;
1204 bool sys_only = false;
1205 if (!transaction_mask && (flush_flag & FLUSH_SYSTEM))
1206 sys_only = true;
1207
1208#ifdef SUPERSERVER_V2
1209 BufferControl* bcb = dbb->dbb_bcb;
1210 //if (!dbb->dbb_wal && A && B) becomes
1211 //if (true && A && B) then finally (A && B)
1212 if (!(dbb->dbb_flags & DBB_force_write) && transaction_mask)
1213 {
1214 dbb->dbb_flush_cycle |= transaction_mask;
1215 if (!(bcb->bcb_flags & BCB_writer_active))
1216 bcb->bcb_writer_sem.release();
1217 }
1218 else
1219#endif
1220 flushDirty(tdbb, transaction_mask, sys_only);
1221 }
1222 else
1223 flushAll(tdbb, flush_flag);
1224
1225 //
1226 // Check if flush needed
1227 //
1228 const int max_unflushed_writes = dbb->dbb_config->getMaxUnflushedWrites();
1229 const time_t max_unflushed_write_time = dbb->dbb_config->getMaxUnflushedWriteTime();
1230 bool max_num = (max_unflushed_writes >= 0);
1231 bool max_time = (max_unflushed_write_time >= 0);
1232
1233 bool doFlush = false;
1234
1235 PageSpace* pageSpaceID = dbb->dbb_page_manager.findPageSpace(DB_PAGE_SPACE);
1236 jrd_file* main_file = pageSpaceID->file;
1237
1238 // Avoid flush while creating and restoring database

Callers 11

createDatabaseMethod · 0.85
CCH_flush_astFunction · 0.85
CCH_shutdownFunction · 0.85
StateWriteGuardMethod · 0.85
endBackupMethod · 0.85
garbage_collectorMethod · 0.85
INF_database_infoFunction · 0.85
runMethod · 0.85
TRA_sweepFunction · 0.85
transaction_flushFunction · 0.85
fast_loadFunction · 0.85

Calls 12

SET_TDBBFunction · 0.85
flushDirtyFunction · 0.85
flushAllFunction · 0.85
SDW_checkFunction · 0.85
getDatabaseMethod · 0.80
findPageSpaceMethod · 0.80
isShutDownMethod · 0.80
flushDifferenceMethod · 0.80
PIO_flushFunction · 0.50
releaseMethod · 0.45
getAttachmentMethod · 0.45
getStateMethod · 0.45

Tested by

no test coverage detected