/* $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.
*
*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;
}
}
}
- 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 );
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 );
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 );
+}