]> git.sur5r.net Git - openldap/commitdiff
Sync with HEAD
authorKurt Zeilenga <kurt@openldap.org>
Wed, 16 Nov 2005 18:42:30 +0000 (18:42 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Wed, 16 Nov 2005 18:42:30 +0000 (18:42 +0000)
servers/slapd/back-bdb/tools.c
servers/slapd/back-ldap/search.c
servers/slapd/overlays/syncprov.c
tests/scripts/test032-chain

index 39ff2d728a2140a677ba49977ebb6f44efb0348b..09d25571ae0812c668d661fa39a83299656c7d1f 100644 (file)
@@ -64,7 +64,7 @@ static bdb_tool_idl_cache_entry *bdb_tool_idl_free_list;
 
 static ID bdb_tool_ix_id;
 static Operation *bdb_tool_ix_op;
-static volatile int *bdb_tool_index_threads;
+static int *bdb_tool_index_threads, bdb_tool_index_tcount;
 static void *bdb_tool_index_rec;
 static struct bdb_info *bdb_tool_info;
 static ldap_pvt_thread_mutex_t bdb_tool_index_mutex;
@@ -100,12 +100,12 @@ int bdb_tool_entry_open(
                        ldap_pvt_thread_cond_init( &bdb_tool_index_cond );
                        bdb_tool_index_threads = ch_malloc( slap_tool_thread_max * sizeof( int ));
                        bdb_tool_index_rec = ch_malloc( bdb->bi_nattrs * sizeof( IndexRec ));
+                       bdb_tool_index_tcount = slap_tool_thread_max - 1;
                        for (i=1; i<slap_tool_thread_max; i++) {
                                int *ptr = ch_malloc( sizeof( int ));
                                *ptr = i;
                                ldap_pvt_thread_pool_submit( &connection_pool,
                                        bdb_tool_index_task, ptr );
-                               ldap_pvt_thread_yield();
                        }
                }
                bdb_tool_info = bdb;
@@ -120,6 +120,7 @@ int bdb_tool_entry_close(
        if ( bdb_tool_info ) {
                slapd_shutdown = 1;
                ldap_pvt_thread_mutex_lock( &bdb_tool_index_mutex );
+               bdb_tool_index_tcount = slap_tool_thread_max - 1;
                ldap_pvt_thread_cond_broadcast( &bdb_tool_index_cond );
                ldap_pvt_thread_mutex_unlock( &bdb_tool_index_mutex );
        }
@@ -406,8 +407,15 @@ bdb_tool_index_add(
                bdb_tool_ix_id = e->e_id;
                bdb_tool_ix_op = op;
                ldap_pvt_thread_mutex_lock( &bdb_tool_index_mutex );
+               /* Wait for all threads to be ready */
+               while ( bdb_tool_index_tcount ) {
+                       ldap_pvt_thread_mutex_unlock( &bdb_tool_index_mutex );
+                       ldap_pvt_thread_yield();
+                       ldap_pvt_thread_mutex_lock( &bdb_tool_index_mutex );
+               }
                for ( i=1; i<slap_tool_thread_max; i++ )
                        bdb_tool_index_threads[i] = LDAP_BUSY;
+               bdb_tool_index_tcount = slap_tool_thread_max - 1;
                ldap_pvt_thread_cond_broadcast( &bdb_tool_index_cond );
                ldap_pvt_thread_mutex_unlock( &bdb_tool_index_mutex );
                rc = bdb_index_recrun( op, bdb, ir, e->e_id, 0 );
@@ -1032,6 +1040,7 @@ bdb_tool_index_task( void *ctx, void *ptr )
        free( ptr );
        while ( 1 ) {
                ldap_pvt_thread_mutex_lock( &bdb_tool_index_mutex );
+               bdb_tool_index_tcount--;
                ldap_pvt_thread_cond_wait( &bdb_tool_index_cond,
                        &bdb_tool_index_mutex );
                ldap_pvt_thread_mutex_unlock( &bdb_tool_index_mutex );
index 9c880bc552201d9a5327ee336e2ca170668fcefd..625f3b05500b436bf3502f7a085ca973091ac80f 100644 (file)
@@ -155,6 +155,8 @@ ldap_back_search(
        int             freetext = 0;
        int             do_retry = 1;
        LDAPControl     **ctrls = NULL;
+       /* FIXME: shouldn't this be null? */
+       const char      *save_matched = rs->sr_matched;
 
        lc = ldap_back_getconn( op, rs, LDAP_BACK_SENDERR );
        if ( !lc || !ldap_back_dobind( lc, op, rs, LDAP_BACK_SENDERR ) ) {
@@ -454,14 +456,14 @@ finish:;
                rs->sr_ctrls = NULL;
        }
 
-       if ( rs->sr_matched != NULL ) {
+       if ( rs->sr_matched != NULL && rs->sr_matched != save_matched ) {
                if ( rs->sr_matched != match.bv_val ) {
                        ber_memfree_x( (char *)rs->sr_matched, op->o_tmpmemctx );
 
                } else {
                        LDAP_FREE( match.bv_val );
                }
-               rs->sr_matched = NULL;
+               rs->sr_matched = save_matched;
        }
 
        if ( !BER_BVISNULL( &filter ) && filter.bv_val != op->ors_filterstr.bv_val ) {
index a9d71afa581132c4e7f754c5a5ddd6230b4a416f..4e090b0fc98f93e51b0bd09d54deb97726698e87 100644 (file)
@@ -1222,7 +1222,7 @@ syncprov_checkpoint( Operation *op, SlapReply *rs, slap_overinst *on )
        syncprov_info_t         *si = on->on_bi.bi_private;
        Modifications mod;
        Operation opm;
-       SlapReply rsm;
+       SlapReply rsm = { 0 };
        struct berval bv[2];
        slap_callback cb = {0};
 
index 5b6a1db01b16fb8323bc5f838abc015b82686862..cec27d7016a072134298646f230c0c829b99d951 100755 (executable)
@@ -21,6 +21,8 @@ if test $BACKLDAP = "ldapno" ; then
        exit 0
 fi 
 
+rm -rf $TESTDIR
+
 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
 
 echo "Running slapadd to build slapd database..."
@@ -50,6 +52,7 @@ if test $WAIT != 0 ; then
     echo PID $PID1
     read foo
 fi
+KILLPIDS="$PID1"
 
 echo "Starting second slapd on TCP/IP port $PORT2..."
 . $CONFFILTER $BACKEND $MONITORDB < $CHAINCONF2 > $CONF2
@@ -60,7 +63,7 @@ if test $WAIT != 0 ; then
     read foo
 fi
 
-KILLPIDS="$PID1 $PID2"
+KILLPIDS="$KILLPIDS $PID2"
 
 sleep 1
 
@@ -76,6 +79,12 @@ for i in 0 1 2 3 4 5; do
        sleep 5
 done
 
+if test $RC != 0 ; then
+       echo "ldapsearch failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+fi
+
 echo "Using ldapsearch to check that second slapd is running..."
 for i in 0 1 2 3 4 5; do
        $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
@@ -88,6 +97,12 @@ for i in 0 1 2 3 4 5; do
        sleep 5
 done
 
+if test $RC != 0 ; then
+       echo "ldapsearch failed ($RC)!"
+       test $KILLSERVERS != no && kill -HUP $KILLPIDS
+       exit $RC
+fi
+
 for P in $PORT1 $PORT2 ; do
        echo "Testing ldapsearch as anonymous for \"$BASEDN\" on port $P..."
        $LDAPSEARCH -h $LOCALHOST -p $P -b "$BASEDN" -S "" \