That way, even empty slots can be identified as 'changed' compared to some older index even if they are empty. This makes it consistent, as indices refer to occupied slots only and protect themselves from changes using the generation flag, which usually comes first.
Unified · Split
| @@ -157,7 +157,7 @@ impl super::Store { · 156 unmodified lines | |||
| 157 | 157 | ||
| 158 | /// refresh and possibly clear out our existing data structures, causing all pack ids to be invalidated. | 158 | /// refresh and possibly clear out our existing data structures, causing all pack ids to be invalidated. |
| 159 | /// `load_new_index` is an optimization to at least provide one newly loaded pack after refreshing the slot map. | 159 | /// `load_new_index` is an optimization to at least provide one newly loaded pack after refreshing the slot map. |
| 160 | fn consolidate_with_disk_state(&self, load_new_index: bool) -> Result<Option<Snapshot>, Error> { | 160 | pub(crate) fn consolidate_with_disk_state(&self, load_new_index: bool) -> Result<Option<Snapshot>, Error> { |
| 161 | let index = self.index.load(); | 161 | let index = self.index.load(); |
| 162 | let previous_index_state = Arc::as_ptr(&index) as usize; | 162 | let previous_index_state = Arc::as_ptr(&index) as usize; |
| 163 | 163 | ||
| @@ -372,8 +372,8 @@ impl super::Store { · 208 unmodified lines | |||
| 372 | }; | 372 | }; |
| 373 | slot.files.store(files); | 373 | slot.files.store(files); |
| 374 | if !needs_stable_indices { | 374 | if !needs_stable_indices { |
| 375 | // Not racy due to lock, generation must be set after unsetting the value AND storing it. | 375 | // Not racy due to lock, generation must be set after unsetting the slot value AND storing it. |
| 376 | slot.generation.store(0, Ordering::SeqCst); | 376 | slot.generation.store(generation, Ordering::SeqCst); |
| 377 | } | 377 | } |
| 378 | } | 378 | } |
| 379 | 379 | ||