Skip to content

Commit

Permalink
Merge branch 'jv-cache-manager' of git://github.com/jacobvosmaer/MPD
Browse files Browse the repository at this point in the history
Works around assertion failure in the boost::intrusive::set class
because we modified the container between insert_check() and
insert_commit().

Closes #691
  • Loading branch information
MaxKellermann committed Dec 22, 2019
2 parents a72878c + 83acbe1 commit 57b8e7f
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/input/cache/Manager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,9 @@ InputCacheManager::Get(const char *uri, bool create)
if (!PathTraitsUTF8::IsAbsolute(uri))
return {};

UriMap::insert_commit_data hint;
auto result = items_by_uri.insert_check(uri, items_by_uri.key_comp(),
hint);
if (!result.second) {
auto &item = *result.first;
auto iter = items_by_uri.find(uri, items_by_uri.key_comp());
if (iter != items_by_uri.end()) {
auto &item = *iter;

/* refresh */
items_by_time.erase(items_by_time.iterator_to(item));
Expand All @@ -112,7 +110,7 @@ InputCacheManager::Get(const char *uri, bool create)
while (total_size > max_total_size && EvictOldestUnused()) {}

auto *item = new InputCacheItem(std::move(is));
items_by_uri.insert_commit(*item, hint);
items_by_uri.insert(*item);
items_by_time.push_back(*item);

return InputCacheLease(*item);
Expand Down

0 comments on commit 57b8e7f

Please sign in to comment.