[Spice-devel] patch (RFC) - remove redundant calls to EngAcquireSemaphore/EngReleaseSemaphore in Windows' QXL display/res.c

Submitted by Yaniv Kaul on July 31, 2011, 10:30 p.m.

Details

Message ID 4E357528.7080205@redhat.com
State New, archived
Headers show

Not browsing as part of any series.

Commit Message

Yaniv Kaul July 31, 2011, 10:30 p.m.
As correctly documented before the function, it is only called when the 
semaphore is held, therefore no need to acquire nor release it:





(note: not even compile tested - haven't managed to compile on Windows yet).

[ykaul@ykaul qxl]$ grep ImageCacheAdd\(pdev -A 2 -B 8 display/res.c
         EngAcquireSemaphore(pdev->Res->image_cache_sem);
         cache_image = AllocCacheImage(pdev);
         ImageCacheRemove(pdev, cache_image);
         cache_image->key = key;
         cache_image->image = NULL;
         cache_image->format = format;
         cache_image->width = surf->sizlBitmap.cx;
         cache_image->height = surf->sizlBitmap.cy;
         ImageCacheAdd(pdev, cache_image);
         RingAdd(pdev, &pdev->Res->cache_image_lru, &cache_image->lru_link);
         EngReleaseSemaphore(pdev->Res->image_cache_sem);
--
         EngAcquireSemaphore(pdev->Res->image_cache_sem);
         cache_image = AllocCacheImage(pdev);
         ImageCacheRemove(pdev, cache_image);
         cache_image->key = key;
         cache_image->image = NULL;
         cache_image->format = SPICE_BITMAP_FMT_RGBA;
         cache_image->width = surf->sizlBitmap.cx;
         cache_image->height = surf->sizlBitmap.cy;
         ImageCacheAdd(pdev, cache_image);
         RingAdd(pdev, &pdev->Res->cache_image_lru, &cache_image->lru_link);
         EngReleaseSemaphore(pdev->Res->image_cache_sem);


Y.

Patch hide | download patch | download mbox

diff --git a/display/res.c b/display/res.c
index 5d28184..df0ddba 100644
--- a/display/res.c
+++ b/display/res.c
@@ -1510,12 +1510,10 @@  static void ImageCacheAdd(PDev *pdev, CacheImage 
*cache_image)
  {
      int key;

-    EngAcquireSemaphore(pdev->Res->image_cache_sem);
      key = IMAGE_HASH_VAL(cache_image->key);
      cache_image->next = pdev->Res->image_cache[key];
      cache_image->hits = 1;
      pdev->Res->image_cache[key] = cache_image;
-    EngReleaseSemaphore(pdev->Res->image_cache_sem);
  }