| 886 | } |
| 887 | |
| 888 | void TipCache::remapSnapshots(bool sync) |
| 889 | { |
| 890 | // Can only be called on initialized TipCache |
| 891 | fb_assert(m_tpcHeader); |
| 892 | |
| 893 | SnapshotList* snapshots = m_snapshots->getHeader(); |
| 894 | |
| 895 | if (snapshots->slots_allocated.load(std::memory_order_acquire) != |
| 896 | (m_snapshots->sh_mem_length_mapped - offsetof(SnapshotList, slots[0])) / sizeof(SnapshotData)) |
| 897 | { |
| 898 | SharedMutexGuard guard(m_snapshots, false); |
| 899 | if (sync) |
| 900 | guard.lock(); |
| 901 | |
| 902 | LocalStatus ls; |
| 903 | CheckStatusWrapper localStatus(&ls); |
| 904 | if (!m_snapshots->remapFile(&localStatus, |
| 905 | static_cast<ULONG>( |
| 906 | snapshots->slots_allocated.load(std::memory_order_relaxed) * sizeof(SnapshotData) + |
| 907 | offsetof(SnapshotList, slots[0])), false)) |
| 908 | { |
| 909 | status_exception::raise(&localStatus); |
| 910 | } |
| 911 | } |
| 912 | } |
| 913 | |
| 914 | |
| 915 | SnapshotHandle TipCache::beginSnapshot(thread_db* tdbb, AttNumber attachmentId, CommitNumber& commitNumber) |