From 2fe411e33775a5614dca6872cf194ed94d177182 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Mon, 28 Apr 2008 23:26:45 +0000 Subject: [PATCH] avoid potential deadlock? --- servers/slapd/back-monitor/cache.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/servers/slapd/back-monitor/cache.c b/servers/slapd/back-monitor/cache.c index 3de1ce279a..339e2bb4a8 100644 --- a/servers/slapd/back-monitor/cache.c +++ b/servers/slapd/back-monitor/cache.c @@ -154,13 +154,18 @@ monitor_cache_get( *ep = NULL; tmp_mc.mc_ndn = *ndn; +retry:; ldap_pvt_thread_mutex_lock( &mi->mi_cache_mutex ); mc = ( monitor_cache_t * )avl_find( mi->mi_cache, ( caddr_t )&tmp_mc, monitor_cache_cmp ); if ( mc != NULL ) { /* entry is returned with mutex locked */ - monitor_cache_lock( mc->mc_e ); + if ( monitor_cache_trylock( mc->mc_e ) ) { + ldap_pvt_thread_mutex_unlock( &mi->mi_cache_mutex ); + ldap_pvt_thread_yield(); + goto retry; + } *ep = mc->mc_e; } -- 2.39.5