]> git.sur5r.net Git - openldap/commitdiff
Elimination of entry- and cache-level locking in back-bdb2.
authorKurt Spanier <ksp@openldap.org>
Wed, 17 Feb 1999 11:13:22 +0000 (11:13 +0000)
committerKurt Spanier <ksp@openldap.org>
Wed, 17 Feb 1999 11:13:22 +0000 (11:13 +0000)
Slight adaption of concurrency-test to enable even more writers/readers.

servers/slapd/back-bdb2/add.c
servers/slapd/back-bdb2/back-bdb2.h
servers/slapd/back-bdb2/cache.c
servers/slapd/back-bdb2/delete.c
servers/slapd/back-bdb2/init.c
servers/slapd/back-bdb2/modrdn.c
servers/slapd/back-bdb2/nextid.c
tests/scripts/test008-concurrency
tests/slapd-addel.c
tests/slapd-read.c
tests/slapd-search.c

index c4e5147f682f006810fa556144af1bb66a0dacb4..1fc5d82f7808fac7505633b1a82b7d32e99b4d1d 100644 (file)
@@ -28,17 +28,17 @@ bdb2i_back_add_internal(
        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 );
@@ -60,7 +60,7 @@ bdb2i_back_add_internal(
 
                /* 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,
@@ -76,7 +76,7 @@ bdb2i_back_add_internal(
                }
 
                /* 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);
 
@@ -102,7 +102,7 @@ bdb2i_back_add_internal(
        } 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,
@@ -116,9 +116,9 @@ bdb2i_back_add_internal(
                 * 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 );
@@ -136,7 +136,7 @@ bdb2i_back_add_internal(
 
                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,
@@ -216,7 +216,7 @@ return_results:;
 
        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 */
index 126c2fb6ce4256bcb536f67aa43c39f6ec3f2d40..0a7bdc1d5b10132274d81be257cba2295e661784 100644 (file)
@@ -79,7 +79,7 @@ struct cache {
        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
@@ -182,9 +182,9 @@ struct ldbminfo {
        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;
index 9581ef5194be28d5e80c9d808a4736c4c6f8dc9b..b17aadab2dc9b9e430da65a52e3c537645d03ec9 100644 (file)
@@ -102,11 +102,11 @@ cache_entry_private_init( Entry*e )
 
        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;
 }
@@ -120,7 +120,7 @@ cache_entry_private_destroy( Entry*e )
        assert( e->e_private );
 #endif
 
-       cache_entry_rdwr_destroy( e );
+       /* DDD cache_entry_rdwr_destroy( e ); */
 
        free( e->e_private );
        e->e_private = NULL;
@@ -131,13 +131,13 @@ void
 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--;
 
@@ -170,7 +170,7 @@ bdb2i_cache_return_entry_rw( struct cache *cache, Entry *e, int rw )
        }
 
        /* 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 ) { \
@@ -215,7 +215,7 @@ bdb2i_cache_add_entry_rw(
        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 );
@@ -238,7 +238,7 @@ bdb2i_cache_add_entry_rw(
                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 );
        }
 
@@ -261,11 +261,11 @@ bdb2i_cache_add_entry_rw(
                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 */
@@ -311,7 +311,7 @@ bdb2i_cache_add_entry_rw(
        }
 
        /* free cache mutex */
-       ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+       /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
        return( 0 );
 }
 
@@ -331,7 +331,7 @@ bdb2i_cache_update_entry(
        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 );
@@ -345,7 +345,7 @@ bdb2i_cache_update_entry(
                    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 );
        }
 
@@ -366,7 +366,7 @@ bdb2i_cache_update_entry(
                }
 
                /* free cache mutex */
-               ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+               /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
                return( -1 );
        }
 
@@ -413,7 +413,7 @@ bdb2i_cache_update_entry(
        }
 
        /* free cache mutex */
-       ldap_pvt_thread_mutex_unlock( &cache->c_mutex );
+       /* DDD ldap_pvt_thread_mutex_unlock( &cache->c_mutex ); */
        return( 0 );
 }
 
@@ -433,7 +433,7 @@ bdb2i_cache_find_entry_dn2id(
        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 ) );
@@ -464,7 +464,7 @@ bdb2i_cache_find_entry_dn2id(
                                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 );
                }
 
@@ -480,7 +480,7 @@ bdb2i_cache_find_entry_dn2id(
                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 );
        }
@@ -488,7 +488,7 @@ bdb2i_cache_find_entry_dn2id(
        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 );
 }
@@ -511,7 +511,7 @@ bdb2i_cache_find_entry_id(
 
 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 )
@@ -532,7 +532,7 @@ try_again:
                                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 );
                }
 
@@ -541,17 +541,17 @@ try_again:
                        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 );
@@ -560,13 +560,13 @@ try_again:
                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 );
 }
@@ -591,7 +591,7 @@ bdb2i_cache_delete_entry(
        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 );
@@ -603,7 +603,7 @@ bdb2i_cache_delete_entry(
        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 );
 }
 
index d7fdb3cefa038bc8c1ef59588458c6f149ea823c..a47c32e88ad6d9ceb9e9a8b4f53cedcffe7aae55 100644 (file)
@@ -94,7 +94,7 @@ bdb2i_back_delete_internal(
                        goto return_results;
                }
 
-               ldap_pvt_thread_mutex_lock(&li->li_root_mutex);
+               /* DDD ldap_pvt_thread_mutex_lock(&li->li_root_mutex); */
                rootlock = 1;
        }
 
@@ -138,7 +138,7 @@ return_results:;
 
        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 */
index 5f0c8cd3d1229a3d5af852cc667523883983a50e..115573f7105160937b25698c57b959c41e6c4a12 100644 (file)
@@ -173,10 +173,10 @@ bdb2i_back_db_init_internal(
        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 )
index 1cd85cb5d69c9b1f1432da2864c061dca7b275dd..3f6d077c0626169ca797e137c0df1bfeeff34592 100644 (file)
@@ -107,7 +107,7 @@ bdb2i_back_modrdn_internal(
                        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 );
@@ -182,7 +182,7 @@ return_results:
 
        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 */
index 129221e31efc9327cd653a0f3de72cf662403e25..9b7937508f5c73e8dfa671c6f0407141a14c3ec2 100644 (file)
@@ -98,7 +98,7 @@ bdb2i_next_id( BackendDB *be )
        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 ) {
@@ -124,7 +124,7 @@ bdb2i_next_id( BackendDB *be )
        (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 );
 }
 
@@ -134,10 +134,10 @@ bdb2i_next_id_return( BackendDB *be, ID 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;
        }
 
@@ -147,7 +147,7 @@ bdb2i_next_id_return( BackendDB *be, ID id )
        (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
 }
 
@@ -157,7 +157,7 @@ bdb2i_next_id_get( BackendDB *be )
        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 ) {
@@ -174,7 +174,7 @@ bdb2i_next_id_get( BackendDB *be )
 
        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 );
 }
index 815cdaf79e894980102773ee4662922003679c2f..eca68fa2dc43dc58e951678e05ace95715ab04c9 100755 (executable)
@@ -35,7 +35,7 @@ echo "Waiting 5 seconds for slapd to start..."
 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
index a6c723837819d882a454668d2ecd8126c3d6886b..03b66ed1e478388d2d70d172e7668d7dc8cb463e 100644 (file)
@@ -232,6 +232,7 @@ do_addel(
 {
        LDAP    *ld;
        int     i;
+       pid_t   pid = getpid();
 
        if (( ld = ldap_init( host, port )) == NULL ) {
                perror( "ldap_init" );
@@ -245,7 +246,8 @@ do_addel(
        }
 
 
-       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++ ) {
 
@@ -270,6 +272,8 @@ do_addel(
 
        }
 
+       fprintf( stderr, " PID=%ld - Add/Delete done.\n", pid );
+
        ldap_unbind( ld );
 }
 
index da7c9df22cecd3735824c55a8834316d10d7fb4d..b94ec3e70522ab3a42780a5d2424379ec15e61e9 100644 (file)
@@ -70,7 +70,7 @@ main( int argc, char **argv )
 
        }
 
-       do_read( host, port, entry, loops );
+       do_read( host, port, entry, ( 4 * loops ));
 
        exit( 0 );
 }
@@ -83,6 +83,7 @@ do_read( char *host, int port, char *entry, int maxloop )
        int     i;
        char    *attrs[] = { "cn", "sn", NULL };
        char    *filter = "(objectclass=*)";
+       pid_t   pid = getpid();
 
        if (( ld = ldap_init( host, port )) == NULL ) {
                perror( "ldap_init" );
@@ -95,22 +96,27 @@ do_read( char *host, int port, char *entry, int maxloop )
        }
 
 
-       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 );
 }
 
index 559e3bca2b72632651dc6bd7b5f7f5be29ef08b3..27fc421be488c14c19b611794f9b59c3d0c1c348 100644 (file)
@@ -75,7 +75,7 @@ main( int argc, char **argv )
 
        }
 
-       do_search( host, port, sbase, filter, loops );
+       do_search( host, port, sbase, filter, ( 4 * loops ));
 
        exit( 0 );
 }
@@ -87,6 +87,7 @@ do_search( char *host, int port, char *sbase, char *filter, int maxloop )
        LDAP    *ld;
        int     i;
        char    *attrs[] = { "cn", "sn", NULL };
+       pid_t   pid = getpid();
 
        if (( ld = ldap_init( host, port )) == NULL ) {
                perror( "ldap_init" );
@@ -99,23 +100,27 @@ do_search( char *host, int port, char *sbase, char *filter, int maxloop )
        }
 
 
-       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 );
 }