On delete, always set promotions == -2 and node == nil

Also, item.promotions doesn't need to be loaded/stored using atomic. Once upon a
time it did. Cache was updated long ago to not use atomic operations on it, but
LayeredCache wasn't. They are both consistent now (they don't use atomic
operations).

Fixes: https://github.com/karlseguin/ccache/issues/76
This commit is contained in:
Karl Seguin
2022-12-13 20:33:58 +08:00
parent 3452e4e261
commit ece93bf87d
4 changed files with 9 additions and 5 deletions

View File

@@ -394,6 +394,8 @@ func (c *Cache[T]) doDelete(item *Item[T]) {
c.onDelete(item)
}
c.list.Remove(item.node)
item.node = nil
item.promotions = -2
}
}