forked from enlightenment/efl
evas/cserve2: Prevent another infinite loop (flush)
And add some error messages
This commit is contained in:
parent
498418bb67
commit
b3b5999847
|
@ -528,10 +528,18 @@ evas_cache2_shutdown(Evas_Cache2 *cache)
|
||||||
EINA_INLIST_FOREACH_SAFE(cache->lru, il, im)
|
EINA_INLIST_FOREACH_SAFE(cache->lru, il, im)
|
||||||
_evas_cache2_image_entry_delete(cache, im);
|
_evas_cache2_image_entry_delete(cache, im);
|
||||||
|
|
||||||
|
if (cache->lru)
|
||||||
|
ERR("Cache2 LRU still contains %d elements after dump!",
|
||||||
|
eina_inlist_count(cache->lru));
|
||||||
|
|
||||||
/* This is mad, I am about to destroy image still alive, but we need to prevent leak. */
|
/* This is mad, I am about to destroy image still alive, but we need to prevent leak. */
|
||||||
EINA_INLIST_FOREACH_SAFE(cache->dirty, il, im)
|
EINA_INLIST_FOREACH_SAFE(cache->dirty, il, im)
|
||||||
_evas_cache2_image_entry_delete(cache, im);
|
_evas_cache2_image_entry_delete(cache, im);
|
||||||
|
|
||||||
|
if (cache->dirty)
|
||||||
|
ERR("Cache2 dirty pool still contains %d elements after dump!",
|
||||||
|
eina_inlist_count(cache->dirty));
|
||||||
|
|
||||||
delete_list = NULL;
|
delete_list = NULL;
|
||||||
eina_hash_foreach(cache->activ, _evas_cache2_image_free_cb, &delete_list);
|
eina_hash_foreach(cache->activ, _evas_cache2_image_free_cb, &delete_list);
|
||||||
EINA_LIST_FREE(delete_list, im)
|
EINA_LIST_FREE(delete_list, im)
|
||||||
|
@ -540,6 +548,9 @@ evas_cache2_shutdown(Evas_Cache2 *cache)
|
||||||
eina_hash_free(cache->activ);
|
eina_hash_free(cache->activ);
|
||||||
eina_hash_free(cache->inactiv);
|
eina_hash_free(cache->inactiv);
|
||||||
|
|
||||||
|
if (cache->usage > 0)
|
||||||
|
WRN("Cache2 reports %d bytes used after shutdown.", cache->usage);
|
||||||
|
|
||||||
free(cache);
|
free(cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1128,14 +1139,20 @@ on_error:
|
||||||
EAPI int
|
EAPI int
|
||||||
evas_cache2_flush(Evas_Cache2 *cache)
|
evas_cache2_flush(Evas_Cache2 *cache)
|
||||||
{
|
{
|
||||||
if (cache->limit == -1) return -1;
|
Eina_Inlist *cur, *prev;
|
||||||
|
|
||||||
while ((cache->lru) && (cache->limit < cache->usage))
|
if (cache->limit == -1) return -1;
|
||||||
|
if (!cache->lru) return cache->usage; // Should be 0
|
||||||
|
|
||||||
|
//EINA_INLIST_FOREACH_REVERSE_SAFE(cache->lru, cur, prev, im)
|
||||||
|
for (cur = cache->lru->last;
|
||||||
|
cur && (cache->limit < cache->usage);
|
||||||
|
cur = prev)
|
||||||
{
|
{
|
||||||
Image_Entry *im;
|
Image_Entry *im;
|
||||||
|
|
||||||
im = (Image_Entry *)cache->lru->last;
|
prev = cur->prev;
|
||||||
DBG("Remove unused entry from cache.");
|
im = EINA_INLIST_CONTAINER_GET(cur, Image_Entry);
|
||||||
_evas_cache2_image_entry_delete(cache, im);
|
_evas_cache2_image_entry_delete(cache, im);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue