]> git.sur5r.net Git - openldap/commitdiff
Fix potential deadlock
authorQuanah Gibson-Mount <quanah@openldap.org>
Thu, 1 May 2008 23:25:42 +0000 (23:25 +0000)
committerQuanah Gibson-Mount <quanah@openldap.org>
Thu, 1 May 2008 23:25:42 +0000 (23:25 +0000)
servers/slapd/back-monitor/cache.c

index 3de1ce279a9a1fe5b581d18e32f83269f706ec44..339e2bb4a8004a9865074c5c75b95ca727ebb0a8 100644 (file)
@@ -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;
        }