Entry e, *ep;
ID id;
- /* set cache mutex */
- ldap_pvt_thread_mutex_lock( &cache->c_mutex );
-
e.e_dn = dn;
e.e_ndn = dn_normalize_case( ch_strdup( dn ) );
+try_again:
+ /* set cache mutex */
+ ldap_pvt_thread_mutex_lock( &cache->c_mutex );
+
if ( (ep = (Entry *) avl_find( cache->c_dntree, (caddr_t) &e,
(AVL_CMP) entry_dn_cmp )) != NULL )
{
/* free cache mutex */
ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
- return( NOID );
+ ldap_pvt_thread_yield();
+ goto try_again;
}
Debug(LDAP_DEBUG_TRACE,
e.e_id = id;
+try_again:
/* set cache mutex */
ldap_pvt_thread_mutex_lock( &cache->c_mutex );
/* free cache mutex */
ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
- return( NULL );
+ ldap_pvt_thread_yield();
+ goto try_again;
}
Debug(LDAP_DEBUG_TRACE,
}
if ( bdb2i_cache_add_entry_rw( &li->li_cache, e, rw ) != 0 ) {
+ entry_free( e );
+
+ /* see if it got added underneath us */
+ if((e = bdb2i_cache_find_entry_id( &li->li_cache, id, rw )) != NULL ) {
+ Debug( LDAP_DEBUG_TRACE,
+ "<= bdb2i_id2entry_%s( %ld ) 0x%lx (cache)\n",
+ rw ? "w" : "r", id, (unsigned long)e );
+ return( e );
+ }
+
Debug( LDAP_DEBUG_TRACE,
"<= bdb2i_id2entry_%s( %ld ) (cache add failed)\n",
rw ? "w" : "r", id, 0 );
- entry_free( e );
return( NULL );
}
Entry e, *ep;
ID id;
- /* set cache mutex */
- ldap_pvt_thread_mutex_lock( &cache->c_mutex );
-
e.e_dn = dn;
e.e_ndn = dn_normalize_case( ch_strdup( dn ) );
+try_again:
+ /* set cache mutex */
+ ldap_pvt_thread_mutex_lock( &cache->c_mutex );
+
if ( (ep = (Entry *) avl_find( cache->c_dntree, (caddr_t) &e,
(AVL_CMP) entry_dn_cmp )) != NULL )
{
/* free cache mutex */
ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
- return( NOID );
+ ldap_pvt_thread_yield();
+ goto try_again;
}
Debug(LDAP_DEBUG_TRACE,
/* free cache mutex */
ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
- return( NULL );
+ ldap_pvt_thread_yield();
+ goto try_again;
}
Debug(LDAP_DEBUG_TRACE,
}
if( cache_add_entry_rw( &li->li_cache, e, rw ) != 0 ) {
+ entry_free( e );
+
+ /* maybe the entry got added underneath us */
+ if ( (e = cache_find_entry_id( &li->li_cache, id, rw )) != NULL ) {
+ Debug( LDAP_DEBUG_TRACE, "<= id2entry_%s( %ld ) 0x%lx (cache)\n",
+ rw ? "w" : "r", id, (unsigned long) e );
+ return( e );
+ }
+
Debug( LDAP_DEBUG_TRACE, "<= id2entry_%s( %ld ) (cache add failed)\n",
rw ? "w" : "r", id, 0 );
- entry_free( e );
return NULL;
}