summaryrefslogtreecommitdiff
path: root/src/lib/evas/cache2
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2013-10-30 15:16:21 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2013-10-30 19:48:17 +0900
commitb3b5999847a4597fbc8c127970a669d17b0b57de (patch)
tree0485f44b570d6fbaae0a407a4d6719c7a5bc2767 /src/lib/evas/cache2
parent498418bb67c1642d5ccdaa71b393eb57060f1d32 (diff)
evas/cserve2: Prevent another infinite loop (flush)
And add some error messages
Diffstat (limited to 'src/lib/evas/cache2')
-rw-r--r--src/lib/evas/cache2/evas_cache2.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/lib/evas/cache2/evas_cache2.c b/src/lib/evas/cache2/evas_cache2.c
index 921d04a364..3e0fad6724 100644
--- a/src/lib/evas/cache2/evas_cache2.c
+++ b/src/lib/evas/cache2/evas_cache2.c
@@ -528,10 +528,18 @@ evas_cache2_shutdown(Evas_Cache2 *cache)
528 EINA_INLIST_FOREACH_SAFE(cache->lru, il, im) 528 EINA_INLIST_FOREACH_SAFE(cache->lru, il, im)
529 _evas_cache2_image_entry_delete(cache, im); 529 _evas_cache2_image_entry_delete(cache, im);
530 530
531 if (cache->lru)
532 ERR("Cache2 LRU still contains %d elements after dump!",
533 eina_inlist_count(cache->lru));
534
531 /* This is mad, I am about to destroy image still alive, but we need to prevent leak. */ 535 /* This is mad, I am about to destroy image still alive, but we need to prevent leak. */
532 EINA_INLIST_FOREACH_SAFE(cache->dirty, il, im) 536 EINA_INLIST_FOREACH_SAFE(cache->dirty, il, im)
533 _evas_cache2_image_entry_delete(cache, im); 537 _evas_cache2_image_entry_delete(cache, im);
534 538
539 if (cache->dirty)
540 ERR("Cache2 dirty pool still contains %d elements after dump!",
541 eina_inlist_count(cache->dirty));
542
535 delete_list = NULL; 543 delete_list = NULL;
536 eina_hash_foreach(cache->activ, _evas_cache2_image_free_cb, &delete_list); 544 eina_hash_foreach(cache->activ, _evas_cache2_image_free_cb, &delete_list);
537 EINA_LIST_FREE(delete_list, im) 545 EINA_LIST_FREE(delete_list, im)
@@ -540,6 +548,9 @@ evas_cache2_shutdown(Evas_Cache2 *cache)
540 eina_hash_free(cache->activ); 548 eina_hash_free(cache->activ);
541 eina_hash_free(cache->inactiv); 549 eina_hash_free(cache->inactiv);
542 550
551 if (cache->usage > 0)
552 WRN("Cache2 reports %d bytes used after shutdown.", cache->usage);
553
543 free(cache); 554 free(cache);
544} 555}
545 556
@@ -1128,14 +1139,20 @@ on_error:
1128EAPI int 1139EAPI int
1129evas_cache2_flush(Evas_Cache2 *cache) 1140evas_cache2_flush(Evas_Cache2 *cache)
1130{ 1141{
1142 Eina_Inlist *cur, *prev;
1143
1131 if (cache->limit == -1) return -1; 1144 if (cache->limit == -1) return -1;
1145 if (!cache->lru) return cache->usage; // Should be 0
1132 1146
1133 while ((cache->lru) && (cache->limit < cache->usage)) 1147 //EINA_INLIST_FOREACH_REVERSE_SAFE(cache->lru, cur, prev, im)
1148 for (cur = cache->lru->last;
1149 cur && (cache->limit < cache->usage);
1150 cur = prev)
1134 { 1151 {
1135 Image_Entry *im; 1152 Image_Entry *im;
1136 1153
1137 im = (Image_Entry *)cache->lru->last; 1154 prev = cur->prev;
1138 DBG("Remove unused entry from cache."); 1155 im = EINA_INLIST_CONTAINER_GET(cur, Image_Entry);
1139 _evas_cache2_image_entry_delete(cache, im); 1156 _evas_cache2_image_entry_delete(cache, im);
1140 } 1157 }
1141 1158