Slight adaption of concurrency-test to enable even more writers/readers.
Debug(LDAP_DEBUG_ARGS, "==> bdb2i_back_add: %s\n", e->e_dn, 0, 0);
/* nobody else can add until we lock our parent */
- ldap_pvt_thread_mutex_lock(&li->li_add_mutex);
+ /* DDD ldap_pvt_thread_mutex_lock(&li->li_add_mutex); */
if ( ( bdb2i_dn2id( be, e->e_ndn ) ) != NOID ) {
- ldap_pvt_thread_mutex_unlock(&li->li_add_mutex);
+ /* 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 ) {
- ldap_pvt_thread_mutex_unlock(&li->li_add_mutex);
+ /* 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 ) {
- ldap_pvt_thread_mutex_unlock(&li->li_add_mutex);
+ /* 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,
}
/* don't need the add lock anymore */
- ldap_pvt_thread_mutex_unlock(&li->li_add_mutex);
+ /* DDD ldap_pvt_thread_mutex_unlock(&li->li_add_mutex); */
free(pdn);
} else {
/* no parent, must be adding entry to root */
if ( ! be_isroot( be, op->o_ndn ) ) {
- ldap_pvt_thread_mutex_unlock(&li->li_add_mutex);
+ /* 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,
* no parent, acquire the root write lock
* and release the add lock.
*/
- ldap_pvt_thread_mutex_lock(&li->li_root_mutex);
+ /* DDD ldap_pvt_thread_mutex_lock(&li->li_root_mutex); */
rootlock = 1;
- ldap_pvt_thread_mutex_unlock(&li->li_add_mutex);
+ /* DDD ldap_pvt_thread_mutex_unlock(&li->li_add_mutex); */
}
e->e_id = bdb2i_next_id( be );
if ( rootlock ) {
/* release root lock */
- ldap_pvt_thread_mutex_unlock(&li->li_root_mutex);
+ /* DDD ldap_pvt_thread_mutex_unlock(&li->li_root_mutex); */
}
Debug( LDAP_DEBUG_ANY, "cache_add_entry_lock failed\n", 0, 0,
if ( rootlock ) {
/* release root lock */
- ldap_pvt_thread_mutex_unlock(&li->li_root_mutex);
+ /* DDD ldap_pvt_thread_mutex_unlock(&li->li_root_mutex); */
}
/* free entry and writer lock */
Avlnode *c_idtree;
Entry *c_lruhead; /* lru - add accessed entries here */
Entry *c_lrutail; /* lru - rem lru entries from here */
- ldap_pvt_thread_mutex_t c_mutex;
+ /* DDD ldap_pvt_thread_mutex_t c_mutex; */
};
#define CACHE_READ_LOCK 1
ID li_nextid_wrote;
#endif
char *li_nextid_file;
- ldap_pvt_thread_mutex_t li_root_mutex;
- ldap_pvt_thread_mutex_t li_add_mutex;
- ldap_pvt_thread_mutex_t li_nextid_mutex;
+ /* DDD ldap_pvt_thread_mutex_t li_root_mutex; */
+ /* DDD ldap_pvt_thread_mutex_t li_add_mutex; */
+ /* DDD ldap_pvt_thread_mutex_t li_nextid_mutex; */
int li_mode;
char *li_directory;
struct cache li_cache;
e->e_private = ch_calloc(1, sizeof(struct ldbm_entry_info));
- if( cache_entry_rdwr_init( e ) != 0 ) {
- free( LEI(e) );
- e->e_private = NULL;
- return 1;
- }
+ /* 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
- cache_entry_rdwr_destroy( e );
+ /* DDD cache_entry_rdwr_destroy( e ); */
free( e->e_private );
e->e_private = NULL;
bdb2i_cache_return_entry_rw( struct cache *cache, Entry *e, int rw )
{
/* set cache mutex */
- ldap_pvt_thread_mutex_lock( &cache->c_mutex );
+ /* DDD ldap_pvt_thread_mutex_lock( &cache->c_mutex ); */
#ifdef LDAP_DEBUG
assert( e->e_private );
#endif
- cache_entry_rdwr_unlock(e, rw);
+ /* DDD cache_entry_rdwr_unlock(e, rw); */
LEI(e)->lei_refcnt--;
}
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
}
#define LRU_DELETE( cache, e ) { \
Entry *ee;
/* set cache mutex */
- ldap_pvt_thread_mutex_lock( &cache->c_mutex );
+ /* DDD ldap_pvt_thread_mutex_lock( &cache->c_mutex ); */
#ifdef LDAP_DEBUG
assert( e->e_private == NULL );
cache_entry_private_destroy(e);
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
return( 1 );
}
cache_entry_private_destroy(e);
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
return( -1 );
}
- cache_entry_rdwr_lock( e, rw );
+ /* DDD cache_entry_rdwr_lock( e, rw ); */
/* put the entry into 'CREATING' state */
/* will be marked after when entry is returned */
}
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
return( 0 );
}
Entry *ee;
/* set cache mutex */
- ldap_pvt_thread_mutex_lock( &cache->c_mutex );
+ /* DDD ldap_pvt_thread_mutex_lock( &cache->c_mutex ); */
#ifdef LDAP_DEBUG
assert( e->e_private );
e->e_id, e->e_dn, 0 );
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
return( 1 );
}
}
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
return( -1 );
}
}
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
return( 0 );
}
ID id;
/* set cache mutex */
- ldap_pvt_thread_mutex_lock( &cache->c_mutex );
+ /* DDD ldap_pvt_thread_mutex_lock( &cache->c_mutex ); */
e.e_dn = dn;
e.e_ndn = dn_normalize_case( ch_strdup( dn ) );
dn, ep->e_id, LEI(ep)->lei_state);
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
return( NOID );
}
id = ep->e_id;
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
return( id );
}
free(e.e_ndn);
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
return( NOID );
}
try_again:
/* set cache mutex */
- ldap_pvt_thread_mutex_lock( &cache->c_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 )
id, ep->e_id, LEI(ep)->lei_state);
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
return( NULL );
}
id, rw ? "w" : "r", ep->e_dn);
/* acquire reader lock */
- if ( cache_entry_rdwr_trylock(ep, rw) == LDAP_PVT_THREAD_EBUSY ) {
+ /* 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 */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
- ldap_pvt_thread_yield();
- goto try_again;
- }
+ /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
+ /* DDD ldap_pvt_thread_yield(); */
+ /* DDD goto try_again; */
+ /* DDD } */
/* lru */
LRU_DELETE( cache, ep );
LEI(ep)->lei_refcnt++;
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
return( ep );
}
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
return( NULL );
}
int rc;
/* set cache mutex */
- ldap_pvt_thread_mutex_lock( &cache->c_mutex );
+ /* DDD ldap_pvt_thread_mutex_lock( &cache->c_mutex ); */
#ifdef LDAP_DEBUG
assert( e->e_private );
rc = cache_delete_entry_internal( cache, e );
/* free cache mutex */
- ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+ /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
return( rc );
}
goto return_results;
}
- ldap_pvt_thread_mutex_lock(&li->li_root_mutex);
+ /* DDD ldap_pvt_thread_mutex_lock(&li->li_root_mutex); */
rootlock = 1;
}
if ( rootlock ) {
/* release root lock */
- ldap_pvt_thread_mutex_unlock(&li->li_root_mutex);
+ /* DDD ldap_pvt_thread_mutex_unlock(&li->li_root_mutex); */
}
/* free entry and writer lock */
free( argv[ 1 ] );
/* initialize various mutex locks & condition variables */
- ldap_pvt_thread_mutex_init( &li->li_root_mutex );
- ldap_pvt_thread_mutex_init( &li->li_add_mutex );
- ldap_pvt_thread_mutex_init( &li->li_cache.c_mutex );
- ldap_pvt_thread_mutex_init( &li->li_nextid_mutex );
+ /* DDD ldap_pvt_thread_mutex_init( &li->li_root_mutex ); */
+ /* DDD ldap_pvt_thread_mutex_init( &li->li_add_mutex ); */
+ /* DDD ldap_pvt_thread_mutex_init( &li->li_cache.c_mutex ); */
+ /* DDD ldap_pvt_thread_mutex_init( &li->li_nextid_mutex ); */
/* initialize the TP file head */
if ( bdb2i_txn_head_init( &li->li_txn_head ) != 0 )
goto return_results;
}
- ldap_pvt_thread_mutex_lock(&li->li_root_mutex);
+ /* DDD ldap_pvt_thread_mutex_lock(&li->li_root_mutex); */
rootlock = 1;
new_dn = ch_strdup( newrdn );
if ( rootlock ) {
/* release root writer lock */
- ldap_pvt_thread_mutex_unlock(&li->li_root_mutex);
+ /* DDD ldap_pvt_thread_mutex_unlock(&li->li_root_mutex); */
}
/* free entry and writer lock */
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
ID id;
- ldap_pvt_thread_mutex_lock( &li->li_nextid_mutex );
+ /* 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 ) {
(void) next_id_write( be, li->li_nextid );
#endif
- ldap_pvt_thread_mutex_unlock( &li->li_nextid_mutex );
+ /* DDD ldap_pvt_thread_mutex_unlock( &li->li_nextid_mutex ); */
return( id );
}
#ifdef SLAPD_NEXTID_RETURN
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
- ldap_pvt_thread_mutex_lock( &li->li_nextid_mutex );
+ /* DDD ldap_pvt_thread_mutex_lock( &li->li_nextid_mutex ); */
if ( id != li->li_nextid - 1 ) {
- ldap_pvt_thread_mutex_unlock( &li->li_nextid_mutex );
+ /* DDD ldap_pvt_thread_mutex_unlock( &li->li_nextid_mutex ); */
return;
}
(void) next_id_write( be, li->li_nextid );
#endif
- ldap_pvt_thread_mutex_unlock( &li->li_nextid_mutex );
+ /* DDD ldap_pvt_thread_mutex_unlock( &li->li_nextid_mutex ); */
#endif
}
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
ID id;
- ldap_pvt_thread_mutex_lock( &li->li_nextid_mutex );
+ /* 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 ) {
id = li->li_nextid;
- ldap_pvt_thread_mutex_unlock( &li->li_nextid_mutex );
+ /* DDD ldap_pvt_thread_mutex_unlock( &li->li_nextid_mutex ); */
return( id );
}
sleep 5
echo "Using tester for concurrent server access..."
-$SLAPDTESTER -b "$BASEDN" -d "$DATADIR" -h localhost -p $PORT -D "$MANAGERDN" -w $PASSWD -l 100
+$SLAPDTESTER -b "$BASEDN" -d "$DATADIR" -h localhost -p $PORT -D "$MANAGERDN" -w $PASSWD -l 50
RC=$?
if [ $RC != 0 ]; then
{
LDAP *ld;
int i;
+ pid_t pid = getpid();
if (( ld = ldap_init( host, port )) == NULL ) {
perror( "ldap_init" );
}
- fprintf( stderr, "Add/Delete(%d): entry=\"%s\".\n", maxloop, entry );
+ fprintf( stderr, "PID=%ld - Add/Delete(%d): entry=\"%s\".\n",
+ pid, maxloop, entry );
for ( i = 0; i < maxloop; i++ ) {
}
+ fprintf( stderr, " PID=%ld - Add/Delete done.\n", pid );
+
ldap_unbind( ld );
}
}
- do_read( host, port, entry, loops );
+ do_read( host, port, entry, ( 4 * loops ));
exit( 0 );
}
int i;
char *attrs[] = { "cn", "sn", NULL };
char *filter = "(objectclass=*)";
+ pid_t pid = getpid();
if (( ld = ldap_init( host, port )) == NULL ) {
perror( "ldap_init" );
}
- fprintf( stderr, "Read(%d): entry=\"%s\".\n", maxloop, entry );
+ fprintf( stderr, "PID=%ld - Read(%d): entry=\"%s\".\n",
+ pid, maxloop, entry );
for ( i = 0; i < maxloop; i++ ) {
- LDAPMessage *res;
+ LDAPMessage *res;
+ int rc;
- if ( ldap_search_s( ld, entry, LDAP_SCOPE_BASE,
- filter, attrs, 0, &res ) != LDAP_SUCCESS ) {
+ if (( rc = ldap_search_s( ld, entry, LDAP_SCOPE_BASE,
+ filter, attrs, 0, &res )) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_read" );
- break;
+ if ( rc != LDAP_NO_SUCH_OBJECT ) break;
+ continue;
}
ldap_msgfree( res );
}
+ fprintf( stderr, " PID=%ld - Read done.\n", pid );
+
ldap_unbind( ld );
}
}
- do_search( host, port, sbase, filter, loops );
+ do_search( host, port, sbase, filter, ( 4 * loops ));
exit( 0 );
}
LDAP *ld;
int i;
char *attrs[] = { "cn", "sn", NULL };
+ pid_t pid = getpid();
if (( ld = ldap_init( host, port )) == NULL ) {
perror( "ldap_init" );
}
- fprintf( stderr, "Search(%d): base=\"%s\", filter=\"%s\".\n",
- maxloop, sbase, filter );
+ fprintf( stderr, "PID=%ld - Search(%d): base=\"%s\", filter=\"%s\".\n",
+ pid, maxloop, sbase, filter );
for ( i = 0; i < maxloop; i++ ) {
- LDAPMessage *res;
+ LDAPMessage *res;
+ int rc;
- if ( ldap_search_s( ld, sbase, LDAP_SCOPE_SUBTREE,
- filter, attrs, 0, &res ) != LDAP_SUCCESS ) {
+ if (( rc = ldap_search_s( ld, sbase, LDAP_SCOPE_SUBTREE,
+ filter, attrs, 0, &res )) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_search" );
- break;
+ if ( rc != LDAP_NO_SUCH_OBJECT ) break;
+ continue;
}
ldap_msgfree( res );
}
+ fprintf( stderr, " PID=%ld - Search done.\n", pid );
+
ldap_unbind( ld );
}