From a718ba72f2fff7f7ad8c667d69a98f80f71a8dc0 Mon Sep 17 00:00:00 2001 From: raster Date: Sun, 1 May 2011 13:25:23 +0000 Subject: [PATCH] and fix up lock goop to work right with improved eina lock goop. i hope i nixed this bug. git-svn-id: http://svn.enlightenment.org/svn/e/trunk/evas@59086 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/cache/evas_cache_image.c | 9 +++-- src/lib/engines/common/evas_image_scalecache.c | 50 +++++++++++++++++++++++--- 2 files changed, 51 insertions(+), 8 deletions(-) diff --git a/src/lib/cache/evas_cache_image.c b/src/lib/cache/evas_cache_image.c index 0e4c264..c34a580 100644 --- a/src/lib/cache/evas_cache_image.c +++ b/src/lib/cache/evas_cache_image.c @@ -629,7 +629,10 @@ evas_cache_image_shutdown(Evas_Cache_Image *cache) { evas_async_events_process(); LKL(wakeup); - if (cache->pending) pthread_cond_wait(&cond_wakeup, &wakeup); + // the lazy bum who did eain threads and converted this code + // didnt bother to worry about Eina_Lock being a different type + // to a pthread mutex. + if (cache->pending) pthread_cond_wait(&cond_wakeup, &(wakeup.mutex)); LKU(wakeup); } #endif @@ -1139,7 +1142,7 @@ evas_cache_image_load_data(Image_Entry *im) LKL(wakeup); while (im->preload) { - pthread_cond_wait(&cond_wakeup, &wakeup); + pthread_cond_wait(&cond_wakeup, &(wakeup.mutex)); LKU(wakeup); evas_async_events_process(); LKL(wakeup); @@ -1175,7 +1178,7 @@ evas_cache_image_unload_data(Image_Entry *im) evas_cache_image_preload_cancel(im, NULL); #ifdef BUILD_ASYNC_PRELOAD LKL(im->lock_cancel); - if (LKT(im->lock) != 0) /* can't get image lock - busy async load */ + if (LKT(im->lock) == EINA_FALSE) /* can't get image lock - busy async load */ { im->unload_cancel = EINA_TRUE; LKU(im->lock_cancel); diff --git a/src/lib/engines/common/evas_image_scalecache.c b/src/lib/engines/common/evas_image_scalecache.c index 202528b..b200f20 100644 --- a/src/lib/engines/common/evas_image_scalecache.c +++ b/src/lib/engines/common/evas_image_scalecache.c @@ -398,19 +398,59 @@ evas_common_rgba_image_scalecache_prepare(Image_Entry *ie, RGBA_Image *dst __UNU int dst_region_w, int dst_region_h) { #ifdef SCALECACHE + int locked = 0; + Eina_Bool ret; RGBA_Image *im = (RGBA_Image *)ie; Scaleitem *sci; if (!im->image.data) return; if ((dst_region_w == 0) || (dst_region_h == 0) || (src_region_w == 0) || (src_region_h == 0)) return; - LKL(im->cache.lock); + // was having major lock issues here - LKL was deadlocking. what was + // going on? it may have been an eina treads badness but this will stay here + // for now for debug +#if 1 + ret = LKT(im->cache.lock); + if (ret == EINA_FALSE) /* can't get image lock */ + { + useconds_t slp = 1, slpt = 0; + + while (slpt < 500000) + { + usleep(slp); + slpt += slp; + slp++; + ret = LKT(im->cache.lock); + if (ret == 2) // MAGIC for now + { + printf("WARNING: DEADLOCK on image %p (%s)\n", im, ie->file); + } + else + { + locked = 1; + break; + } + } + if (ret == EINA_FALSE) + { + printf("WARNING: lock still there after %i usec\n", slpt); + printf("WARNING: stucklock on image %p (%s)\n", im, ie->file); + LKDBG(im->cache.lock); + } + } + else if (ret == 2) // MAGIC for now + { + printf("WARNING: DEADLOCK on image %p (%s)\n", im, ie->file); + } + else locked = 1; +#endif + if (!locked) { LKL(im->cache.lock); locked = 1; } use_counter++; if ((src_region_w == dst_region_w) && (src_region_h == dst_region_h)) { // 1:1 scale. im->cache.orig_usage++; im->cache.usage_count = use_counter; - LKU(im->cache.lock); + if (locked) LKU(im->cache.lock); return; } if ((!im->cache_entry.flags.alpha) && (!smooth)) @@ -419,7 +459,7 @@ evas_common_rgba_image_scalecache_prepare(Image_Entry *ie, RGBA_Image *dst __UNU // or in some cases faster not cached im->cache.orig_usage++; im->cache.usage_count = use_counter; - LKU(im->cache.lock); + if (locked) LKU(im->cache.lock); return; } LKL(cache_lock); @@ -429,7 +469,7 @@ evas_common_rgba_image_scalecache_prepare(Image_Entry *ie, RGBA_Image *dst __UNU if (!sci) { LKU(cache_lock); - LKU(im->cache.lock); + if (locked) LKU(im->cache.lock); return; } // INF("%10i | %4i %4i %4ix%4i -> %4i %4i %4ix%4i | %i", @@ -466,7 +506,7 @@ evas_common_rgba_image_scalecache_prepare(Image_Entry *ie, RGBA_Image *dst __UNU if (sci->usage_count > im->cache.newest_usage_count) im->cache.newest_usage_count = sci->usage_count; // INF(" -------------- used %8i#, %8i@", (int)sci->usage, (int)sci->usage_count); - LKU(im->cache.lock); + if (locked) LKU(im->cache.lock); #endif } -- 2.7.4