From: Pierangelo Masarati Date: Mon, 28 Apr 2008 23:26:45 +0000 (+0000) Subject: avoid potential deadlock? X-Git-Tag: LOCKER_IDS~196 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2fe411e33775a5614dca6872cf194ed94d177182;p=openldap avoid potential deadlock? --- 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; }