| 47 | } |
| 48 | |
| 49 | void Replicator::flush(BatchBlock& block, FlushReason reason, ULONG flags) |
| 50 | { |
| 51 | const auto traNumber = block.header.traNumber; |
| 52 | |
| 53 | const auto length = (ULONG) (block.buffer->getCount() - sizeof(Block)); |
| 54 | fb_assert(length); |
| 55 | |
| 56 | block.header.protocol = PROTOCOL_CURRENT_VERSION; |
| 57 | block.header.flags |= flags; |
| 58 | block.header.length = length; |
| 59 | |
| 60 | // Re-write the updated header |
| 61 | |
| 62 | memcpy(block.buffer->begin(), &block.header, sizeof(Block)); |
| 63 | |
| 64 | // Pass the buffer to the replication manager and setup the new one |
| 65 | |
| 66 | const auto sync = (reason == FLUSH_SYNC); |
| 67 | const auto prepare = (reason == FLUSH_PREPARE); |
| 68 | m_manager->flush(block.buffer, sync, prepare); |
| 69 | |
| 70 | memset(&block.header, 0, sizeof(Block)); |
| 71 | block.header.traNumber = traNumber; |
| 72 | |
| 73 | block.atoms.clear(); |
| 74 | block.lastAtom = MAX_ULONG; |
| 75 | block.buffer = m_manager->getBuffer(); |
| 76 | block.flushes++; |
| 77 | } |
| 78 | |
| 79 | void Replicator::storeBlob(Transaction* transaction, ISC_QUAD blobId) |
| 80 | { |