From ca52ca7c0e8b01d45277909914b361968bf04db7 Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Mon, 8 Oct 2007 19:15:46 -0400 Subject: [PATCH] Fixed MUTEX_TRYLOCK. I misread the docs. --- src/cache.h | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/cache.h b/src/cache.h index f5385768..bb7e998d 100644 --- a/src/cache.h +++ b/src/cache.h @@ -34,18 +34,11 @@ #define MUTEX_UNLOCK_CPP #endif -/* - * pthread_mutex_trylock() doesn't like the pointer (cache_mutexp). The other - * functions seem to work. This should be fine because it won't modify the - * mutex. - */ -#define MUTEX_TRYLOCK(ctx) memcpy(&cache_mutex, shm_data + MUTEX_OFFSET, sizeof(cache_mutex)); \ - if (ctx && pthread_mutex_trylock(&cache_mutex) == EBUSY) { \ - assuan_write_status(ctx, "LOCKED", N_("Waiting for lock")); \ +#define MUTEX_TRYLOCK(ctx) if (pthread_mutex_trylock(cache_mutexp) == EBUSY) { \ + if (ctx) \ + assuan_write_status(ctx, "LOCKED", N_("Waiting for lock")); \ pthread_mutex_lock(cache_mutexp); \ - } \ - else \ - pthread_mutex_lock(cache_mutexp); + } #define MUTEX_LOCK(ctx) MUTEX_LOCK_CPP MUTEX_TRYLOCK(ctx) \ is_locked = TRUE -- 2.11.4.GIT