From 0ed6114c6b2cc9d7e0c09842d19f0987e9ebbb4a Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Tue, 30 Jun 2015 20:19:42 +0200 Subject: sss_client: Use unique lock for memory cache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously the sma lock was used as for communication with responder. However it would cause a deadlock in case of re-checking memcache after acquiring the lock and before communication with responder.. Required by: https://fedorahosted.org/sssd/ticket/2581 Reviewed-by: Michal Židek --- src/sss_client/nss_mc_common.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/sss_client/nss_mc_common.c') diff --git a/src/sss_client/nss_mc_common.c b/src/sss_client/nss_mc_common.c index 89ff6b46e..707d1249f 100644 --- a/src/sss_client/nss_mc_common.c +++ b/src/sss_client/nss_mc_common.c @@ -121,7 +121,7 @@ static errno_t sss_nss_mc_init_ctx(const char *name, char *file = NULL; int ret; - sss_nss_lock(); + sss_nss_mc_lock(); /* check if ctx is initialised by previous thread. */ if (ctx->initialized != UNINITIALIZED) { ret = sss_nss_check_header(ctx); @@ -172,7 +172,7 @@ done: sss_nss_mc_destroy_ctx(ctx); } free(file); - sss_nss_unlock(); + sss_nss_mc_unlock(); return ret; } @@ -217,11 +217,11 @@ errno_t sss_nss_mc_get_ctx(const char *name, struct sss_cli_mc_ctx *ctx) } if (ctx->initialized == RECYCLED && ctx->active_threads == 0) { /* just one thread should call munmap */ - sss_nss_lock(); + sss_nss_mc_lock(); if (ctx->initialized == RECYCLED) { sss_nss_mc_destroy_ctx(ctx); } - sss_nss_unlock(); + sss_nss_mc_unlock(); } if (need_decrement) { /* In case of error, we will not touch mmapped area => decrement */ -- cgit