Collect pages modified by given or system transaction and write it to disk. See also comments in flushPages.
| 2672 | // Collect pages modified by given or system transaction and write it to disk. |
| 2673 | // See also comments in flushPages. |
| 2674 | static void flushDirty(thread_db* tdbb, SLONG transaction_mask, const bool sys_only) |
| 2675 | { |
| 2676 | SET_TDBB(tdbb); |
| 2677 | Database* dbb = tdbb->getDatabase(); |
| 2678 | BufferControl* bcb = dbb->dbb_bcb; |
| 2679 | Firebird::HalfStaticArray<BufferDesc*, 1024> flush; |
| 2680 | |
| 2681 | { // dirtySync scope |
| 2682 | Sync dirtySync(&bcb->bcb_syncDirtyBdbs, "flushDirty"); |
| 2683 | dirtySync.lock(SYNC_EXCLUSIVE); |
| 2684 | |
| 2685 | QUE que_inst = bcb->bcb_dirty.que_forward, next; |
| 2686 | for (; que_inst != &bcb->bcb_dirty; que_inst = next) |
| 2687 | { |
| 2688 | next = que_inst->que_forward; |
| 2689 | BufferDesc* bdb = BLOCK(que_inst, BufferDesc, bdb_dirty); |
| 2690 | |
| 2691 | if (!(bdb->bdb_flags & BDB_dirty)) |
| 2692 | { |
| 2693 | removeDirty(bcb, bdb); |
| 2694 | continue; |
| 2695 | } |
| 2696 | |
| 2697 | if ((transaction_mask & bdb->bdb_transactions) || |
| 2698 | (bdb->bdb_flags & BDB_system_dirty) || |
| 2699 | (!transaction_mask && !sys_only) || |
| 2700 | (!bdb->bdb_transactions)) |
| 2701 | { |
| 2702 | flush.add(bdb); |
| 2703 | } |
| 2704 | } |
| 2705 | } |
| 2706 | |
| 2707 | flushPages(tdbb, FLUSH_TRAN, flush.begin(), flush.getCount()); |
| 2708 | } |
| 2709 | |
| 2710 | |
| 2711 | // Collect pages modified by garbage collector or all dirty pages or release page |
no test coverage detected