| 1179 | |
| 1180 | |
| 1181 | void 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 |
no test coverage detected