struct ldbminfo *li = (struct ldbminfo *) be->be_private;
char *pdn;
Entry *p = NULL;
- int rootlock = 0;
int rc;
Debug(LDAP_DEBUG_ARGS, "==> bdb2i_back_add: %s\n", e->e_dn, 0, 0);
- /* nobody else can add until we lock our parent */
- /* DDD ldap_pvt_thread_mutex_lock(&li->li_add_mutex); */
-
if ( ( bdb2i_dn2id( be, e->e_ndn ) ) != NOID ) {
- /* DDD ldap_pvt_thread_mutex_unlock(&li->li_add_mutex); */
entry_free( e );
send_ldap_result( conn, op, LDAP_ALREADY_EXISTS, "", "" );
return( -1 );
}
if ( global_schemacheck && oc_schema_check( e ) != 0 ) {
- /* DDD ldap_pvt_thread_mutex_unlock(&li->li_add_mutex); */
-
Debug( LDAP_DEBUG_TRACE, "entry failed schema check\n",
0, 0, 0 );
/* get parent with writer lock */
if ( (p = bdb2i_dn2entry_w( be, pdn, &matched )) == NULL ) {
- /* DDD ldap_pvt_thread_mutex_unlock(&li->li_add_mutex); */
Debug( LDAP_DEBUG_TRACE, "parent does not exist\n", 0,
0, 0 );
send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT,
return -1;
}
- /* don't need the add lock anymore */
- /* DDD ldap_pvt_thread_mutex_unlock(&li->li_add_mutex); */
-
free(pdn);
if ( matched != NULL ) {
} else {
/* no parent, must be adding entry to root */
if ( ! be_isroot( be, op->o_ndn ) ) {
- /* DDD ldap_pvt_thread_mutex_unlock(&li->li_add_mutex); */
Debug( LDAP_DEBUG_TRACE, "no parent & not root\n", 0,
0, 0 );
send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
entry_free( e );
return -1;
}
-
- /*
- * no parent, acquire the root write lock
- * and release the add lock.
- */
- /* DDD ldap_pvt_thread_mutex_lock(&li->li_root_mutex); */
- rootlock = 1;
- /* DDD ldap_pvt_thread_mutex_unlock(&li->li_add_mutex); */
}
e->e_id = bdb2i_next_id( be );
bdb2i_cache_return_entry_w( &li->li_cache, p );
}
- if ( rootlock ) {
- /* release root lock */
- /* DDD ldap_pvt_thread_mutex_unlock(&li->li_root_mutex); */
- }
-
Debug( LDAP_DEBUG_ANY, "cache_add_entry_lock failed\n", 0, 0,
0 );
}
- if ( rootlock ) {
- /* release root lock */
- /* DDD ldap_pvt_thread_mutex_unlock(&li->li_root_mutex); */
- }
-
/* free entry and writer lock */
bdb2i_cache_return_entry_w( &li->li_cache, e );
/* LDBM backend specific entry info -- visible only to the cache */
struct ldbm_entry_info {
- ldap_pvt_thread_rdwr_t lei_rdwr; /* reader/writer lock */
-
/*
- * remaining fields require backend cache lock to access
* These items are specific to the LDBM backend and should
* be hidden.
*/
static void lru_print(struct cache *cache);
#endif
-static int
-cache_entry_rdwr_lock(Entry *e, int rw)
-{
- Debug( LDAP_DEBUG_ARGS, "entry_rdwr_%slock: ID: %ld\n",
- rw ? "w" : "r", e->e_id, 0);
-
- if (rw)
- return ldap_pvt_thread_rdwr_wlock(&LEI(e)->lei_rdwr);
- else
- return ldap_pvt_thread_rdwr_rlock(&LEI(e)->lei_rdwr);
-}
-
-static int
-cache_entry_rdwr_trylock(Entry *e, int rw)
-{
- Debug( LDAP_DEBUG_ARGS, "entry_rdwr_%strylock: ID: %ld\n",
- rw ? "w" : "r", e->e_id, 0);
-
- if (rw)
- return ldap_pvt_thread_rdwr_wtrylock(&LEI(e)->lei_rdwr);
- else
- return ldap_pvt_thread_rdwr_rtrylock(&LEI(e)->lei_rdwr);
-}
-
-static int
-cache_entry_rdwr_unlock(Entry *e, int rw)
-{
- Debug( LDAP_DEBUG_ARGS, "entry_rdwr_%sunlock: ID: %ld\n",
- rw ? "w" : "r", e->e_id, 0);
-
- if (rw)
- return ldap_pvt_thread_rdwr_wunlock(&LEI(e)->lei_rdwr);
- else
- return ldap_pvt_thread_rdwr_runlock(&LEI(e)->lei_rdwr);
-}
-
-static int
-cache_entry_rdwr_init(Entry *e)
-{
- return ldap_pvt_thread_rdwr_init( &LEI(e)->lei_rdwr );
-}
-
-static int
-cache_entry_rdwr_destroy(Entry *e)
-{
- return ldap_pvt_thread_rdwr_destroy( &LEI(e)->lei_rdwr );
-}
-
static int
cache_entry_private_init( Entry*e )
{
e->e_private = ch_calloc(1, sizeof(struct ldbm_entry_info));
- /* DDD if( cache_entry_rdwr_init( e ) != 0 ) { */
- /* DDD free( LEI(e) ); */
- /* DDD e->e_private = NULL; */
- /* DDD return 1; */
- /* DDD } */
-
return 0;
}
assert( e->e_private );
#endif
- /* DDD cache_entry_rdwr_destroy( e ); */
-
free( e->e_private );
e->e_private = NULL;
return 0;
void
bdb2i_cache_return_entry_rw( struct cache *cache, Entry *e, int rw )
{
- /* set cache mutex */
- /* DDD ldap_pvt_thread_mutex_lock( &cache->c_mutex ); */
-
#ifdef LDAP_DEBUG
assert( e->e_private );
#endif
- /* DDD cache_entry_rdwr_unlock(e, rw); */
-
LEI(e)->lei_refcnt--;
if ( LEI(e)->lei_state == CACHE_ENTRY_CREATING ) {
"====> bdb2i_cache_return_entry_%s( %ld ): returned (%d)\n",
rw ? "w" : "r", e->e_id, LEI(e)->lei_refcnt);
}
-
- /* free cache mutex */
- /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
}
#define LRU_DELETE( cache, e ) { \
int rw
)
{
- int i, rc;
+ int i;
Entry *ee;
- /* set cache mutex */
- /* DDD ldap_pvt_thread_mutex_lock( &cache->c_mutex ); */
-
#ifdef LDAP_DEBUG
assert( e->e_private == NULL );
#endif
cache_entry_private_destroy(e);
- /* free cache mutex */
- /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
return( 1 );
}
cache_entry_private_destroy(e);
- /* free cache mutex */
- /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
return( -1 );
}
- /* DDD cache_entry_rdwr_lock( e, rw ); */
-
/* put the entry into 'CREATING' state */
/* will be marked after when entry is returned */
LEI(e)->lei_state = CACHE_ENTRY_CREATING;
e = cache->c_lrutail;
/* delete from cache and lru q */
- /* XXX do we need rc ? */
- rc = cache_delete_entry_internal( cache, e );
+ cache_delete_entry_internal( cache, e );
cache_entry_private_destroy( e );
entry_free( e );
}
}
- /* free cache mutex */
- /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
return( 0 );
}
Entry *e
)
{
- int i, rc;
+ int i;
Entry *ee;
- /* set cache mutex */
- /* DDD ldap_pvt_thread_mutex_lock( &cache->c_mutex ); */
-
#ifdef LDAP_DEBUG
assert( e->e_private );
#endif
"====> bdb2i_cache_add_entry( %ld ): \"%s\": already in dn cache\n",
e->e_id, e->e_dn, 0 );
- /* free cache mutex */
- /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
return( 1 );
}
0, 0, 0 );
}
- /* free cache mutex */
- /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
return( -1 );
}
e = cache->c_lrutail;
/* delete from cache and lru q */
- /* XXX do we need rc ? */
- rc = cache_delete_entry_internal( cache, e );
+ cache_delete_entry_internal( cache, e );
cache_entry_private_destroy( e );
entry_free( e );
}
}
- /* free cache mutex */
- /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
return( 0 );
}
Entry e, *ep;
ID id;
- /* set cache mutex */
- /* DDD ldap_pvt_thread_mutex_lock( &cache->c_mutex ); */
-
e.e_dn = dn;
e.e_ndn = dn_normalize_case( ch_strdup( dn ) );
"====> bdb2i_cache_find_entry_dn2id(\"%s\"): %ld (not ready) %d\n",
dn, ep->e_id, LEI(ep)->lei_state);
- /* free cache mutex */
- /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
return( NOID );
}
/* save id */
id = ep->e_id;
- /* free cache mutex */
- /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
-
return( id );
}
free(e.e_ndn);
- /* free cache mutex */
- /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
-
return( NOID );
}
e.e_id = id;
try_again:
- /* set cache mutex */
- /* DDD ldap_pvt_thread_mutex_lock( &cache->c_mutex ); */
-
if ( (ep = (Entry *) avl_find( cache->c_idtree, (caddr_t) &e,
entry_id_cmp )) != NULL )
{
"====> bdb2i_cache_find_entry_id( %ld ): %ld (not ready) %d\n",
id, ep->e_id, LEI(ep)->lei_state);
- /* free cache mutex */
- /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
return( NULL );
}
"====> bdb2i_cache_find_entry_id( %ld, %s ) \"%s\" (found)\n",
id, rw ? "w" : "r", ep->e_dn);
- /* acquire reader lock */
- /* DDD if ( cache_entry_rdwr_trylock(ep, rw) == LDAP_PVT_THREAD_EBUSY ) { */
- /* could not acquire entry lock...
- * owner cannot free as we have the cache locked.
- * so, unlock the cache, yield, and try again.
- */
-
- /* free cache mutex */
- /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
- /* DDD ldap_pvt_thread_yield(); */
- /* DDD goto try_again; */
- /* DDD } */
-
/* lru */
LRU_DELETE( cache, ep );
LRU_ADD( cache, ep );
LEI(ep)->lei_refcnt++;
- /* free cache mutex */
- /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
-
return( ep );
}
- /* free cache mutex */
- /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
-
return( NULL );
}
{
int rc;
- /* set cache mutex */
- /* DDD ldap_pvt_thread_mutex_lock( &cache->c_mutex ); */
-
#ifdef LDAP_DEBUG
assert( e->e_private );
#endif
rc = cache_delete_entry_internal( cache, e );
- /* free cache mutex */
- /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
return( rc );
}
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
ID id;
- /* DDD ldap_pvt_thread_mutex_lock( &li->li_nextid_mutex ); */
-
/* first time in here since startup - try to read the nexid */
if ( li->li_nextid == NOID ) {
li->li_nextid = next_id_read( be );
(void) next_id_write( be, li->li_nextid );
#endif
- /* DDD ldap_pvt_thread_mutex_unlock( &li->li_nextid_mutex ); */
return( id );
}
#ifdef SLAPD_NEXTID_RETURN
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
- /* DDD ldap_pvt_thread_mutex_lock( &li->li_nextid_mutex ); */
-
if ( id != li->li_nextid - 1 ) {
- /* DDD ldap_pvt_thread_mutex_unlock( &li->li_nextid_mutex ); */
return;
}
#if !( SLAPD_NEXTID_CHUCK > 1 )
(void) next_id_write( be, li->li_nextid );
#endif
-
- /* DDD ldap_pvt_thread_mutex_unlock( &li->li_nextid_mutex ); */
#endif
}
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
ID id;
- /* DDD ldap_pvt_thread_mutex_lock( &li->li_nextid_mutex ); */
-
/* first time in here since startup - try to read the nexid */
if ( li->li_nextid == NOID ) {
li->li_nextid = next_id_read( be );
id = li->li_nextid;
- /* DDD ldap_pvt_thread_mutex_unlock( &li->li_nextid_mutex ); */
-
return( id );
}