]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-monitor/cache.c
Cleanup ISO C compatibility for recent commits
[openldap] / servers / slapd / back-monitor / cache.c
index 3639dd11a6cc52c8deed40e8a6123bdf047f8cab..fa4d72ab07f16759b71c1ccf18b2b7e84b1a1e21 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2001-2006 The OpenLDAP Foundation.
+ * Copyright 2001-2011 The OpenLDAP Foundation.
  * Portions Copyright 2001-2003 Pierangelo Masarati.
  * All rights reserved.
  *
@@ -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;
        }
 
@@ -264,7 +269,10 @@ retry:;
                        }
 
                }
-               monitor_cache_release( mi, mc->mc_e );
+
+               if ( mc ) {
+                       monitor_cache_release( mi, mc->mc_e );
+               }
        }
 
        ldap_pvt_thread_mutex_unlock( &mi->mi_cache_mutex );
@@ -402,7 +410,7 @@ monitor_entry_destroy( void *v_mc )
                                monitor_callback_t      *next = cb->mc_next;
 
                                if ( cb->mc_free ) {
-                                       cb->mc_free( mc->mc_e, cb->mc_private );
+                                       (void)cb->mc_free( mc->mc_e, &cb->mc_private );
                                }
                                ch_free( mp->mp_cb );
 
@@ -431,3 +439,11 @@ monitor_cache_destroy(
        return 0;
 }
 
+int monitor_back_release(
+       Operation *op,
+       Entry *e,
+       int rw )
+{
+       monitor_info_t  *mi = ( monitor_info_t * )op->o_bd->be_private;
+       return monitor_cache_release( mi, e );
+}