Merge branch 'jk/clear-delta-base-cache-fix'

A crashing bug introduced in v2.11 timeframe has been found (it is
triggerable only in fast-import) and fixed.

* jk/clear-delta-base-cache-fix:
  clear_delta_base_cache(): don't modify hashmap while iterating
This commit is contained in:
Junio C Hamano 2017-01-31 13:14:58 -08:00
commit c54ba283fa
2 changed files with 7 additions and 6 deletions

View File

@ -188,7 +188,9 @@ Returns the removed entry, or NULL if not found.
`void *hashmap_iter_next(struct hashmap_iter *iter)`:: `void *hashmap_iter_next(struct hashmap_iter *iter)`::
`void *hashmap_iter_first(struct hashmap *map, struct hashmap_iter *iter)`:: `void *hashmap_iter_first(struct hashmap *map, struct hashmap_iter *iter)`::
Used to iterate over all entries of a hashmap. Used to iterate over all entries of a hashmap. Note that it is
not safe to add or remove entries to the hashmap while
iterating.
+ +
`hashmap_iter_init` initializes a `hashmap_iter` structure. `hashmap_iter_init` initializes a `hashmap_iter` structure.
+ +

View File

@ -2371,11 +2371,10 @@ static inline void release_delta_base_cache(struct delta_base_cache_entry *ent)
void clear_delta_base_cache(void) void clear_delta_base_cache(void)
{ {
struct hashmap_iter iter; struct list_head *lru, *tmp;
struct delta_base_cache_entry *entry; list_for_each_safe(lru, tmp, &delta_base_cache_lru) {
for (entry = hashmap_iter_first(&delta_base_cache, &iter); struct delta_base_cache_entry *entry =
entry; list_entry(lru, struct delta_base_cache_entry, lru);
entry = hashmap_iter_next(&iter)) {
release_delta_base_cache(entry); release_delta_base_cache(entry);
} }
} }