]> git.sur5r.net Git - openldap/commitdiff
persistent search updates with recent changes
authorJong Hyuk Choi <jongchoi@openldap.org>
Tue, 20 May 2003 20:21:39 +0000 (20:21 +0000)
committerJong Hyuk Choi <jongchoi@openldap.org>
Tue, 20 May 2003 20:21:39 +0000 (20:21 +0000)
servers/slapd/back-bdb/delete.c
servers/slapd/back-bdb/search.c
servers/slapd/connection.c
servers/slapd/proto-slap.h
servers/slapd/sl_malloc.c
servers/slapd/syncrepl.c

index 6ed4548730403276d9729dca7afe9958a3bb9951..3327e286e4b834d977372bd4662f0b7daf861bb0 100644 (file)
@@ -487,10 +487,12 @@ return_results:
        send_ldap_result( op, rs );
 
 #if defined(LDAP_CLIENT_UPDATE) || defined(LDAP_SYNC)
-        if ( rs->sr_err == LDAP_SUCCESS && !noop ) {
+       if ( rs->sr_err == LDAP_SUCCESS && !noop ) {
+               BEI(e) = eip;
                LDAP_LIST_FOREACH( ps_list, &bdb->bi_psearch_list, o_ps_link ) {
                        bdb_psearch( op, rs, ps_list, e, LDAP_PSEARCH_BY_DELETE );
                }
+               BEI(e) = NULL;
        }
 #endif
 
index 3a0bd7cd09d4ac3f1fb36a0c06c17b837b324782..48ffd1e8ff52dbe6f740c1f2939ba73335cec4d4 100644 (file)
@@ -340,6 +340,10 @@ bdb_cancel( Operation *op, SlapReply *rs )
                                rs->sr_err = LDAP_CANCELLED;
                                send_ldap_result( ps_list, rs );
 
+                               if ( ps_list->o_tmpmemctx ) {
+                                       sl_mem_destroy( NULL, ps_list->o_tmpmemctx );
+                               }
+
                                slap_op_free ( ps_list );
                                return LDAP_SUCCESS;
                        }
@@ -972,7 +976,7 @@ id2entry_retry:
                 * scope while we are looking at it, and unless we're using
                 * BDB_HIER, its parents cannot be moved either.
                 */
-               switch( op->ors_scope ) {
+               switch( sop->ors_scope ) {
                case LDAP_SCOPE_BASE:
                        /* This is always true, yes? */
                        if ( id == base.e_id )
index 30fcc56989cbb5d5a90199477f991a105b5788a7..90ba3505dbf212507e3f4786577ed5917b329500 100644 (file)
@@ -1070,12 +1070,16 @@ operations_error:
                goto co_op_free;
 #endif
 #ifdef LDAP_CLIENT_UPDATE
-       if ( ( op->o_clientupdate_type & SLAP_LCUP_PERSIST ) )
+       if ( ( op->o_clientupdate_type & SLAP_LCUP_PERSIST ) ) {
+               sl_mem_detach( ctx, memctx );
                goto no_co_op_free;
+       }
 #endif
 #ifdef LDAP_SYNC
-       if ( ( op->o_sync_mode & SLAP_SYNC_PERSIST ) )
+       if ( ( op->o_sync_mode & SLAP_SYNC_PERSIST ) ) {
+               sl_mem_detach( ctx, memctx );
                goto no_co_op_free;
+       }
 #endif
 
 co_op_free:
index 9d26c17ebc0df82f1e858db6b612e967b07f63e4..1516f379a94812c5ec705ff677a1b5aea77ec500 100644 (file)
@@ -951,6 +951,8 @@ LDAP_SLAPD_F (void *) sl_calloc LDAP_P(( ber_len_t nelem, ber_len_t size, void *
 LDAP_SLAPD_F (void) sl_free LDAP_P(( void *, void *ctx ));
 LDAP_SLAPD_F (void) sl_mem_init LDAP_P(( void ));
 LDAP_SLAPD_F (void *) sl_mem_create LDAP_P(( ber_len_t size, void *ctx ));
+LDAP_SLAPD_F (void) sl_mem_detach LDAP_P(( void *ctx, void *memctx ));
+LDAP_SLAPD_F (void) sl_mem_destroy LDAP_P(( void *key, void *data ));
 LDAP_SLAPD_F (void *) sl_mark LDAP_P(( void *ctx ));
 LDAP_SLAPD_F (void) sl_release LDAP_P(( void *, void *ctx ));
 LDAP_SLAPD_F (void *) sl_context LDAP_P(( void *ptr ));
index f56328815ae26e029c2e45b20f5ae70252431cde..11defd06d4a42163a34c3ad106d182ee27336888 100644 (file)
@@ -18,7 +18,7 @@ struct slab_heap {
        void *h_end;
 };
 
-static void
+void
 sl_mem_destroy(
        void *key,
        void *data
@@ -72,6 +72,20 @@ sl_mem_create(
        return sh;
 }
 
+void
+sl_mem_detach(
+       void *ctx,
+       void *memctx
+)
+{
+       struct slab_heap *sh = memctx;
+       int size = sh->h_end - sh->h_base;
+
+       sh->h_base = ch_realloc( sh->h_base, size );
+
+       ldap_pvt_thread_pool_setkey( ctx, sl_mem_init, NULL, NULL );
+}
+
 void *
 sl_malloc(
     ber_len_t  size,
index e8c713a5db62c91d41d125d000e7991535165840..2547179e4c7e15bca7f59856ee377070411c0ec8 100644 (file)
@@ -807,6 +807,8 @@ syncrepl_message_to_entry(
        if ( *syncstate == LDAP_SYNC_PRESENT ) {
                e = NULL;
                goto done;
+       } else if ( *syncstate == LDAP_SYNC_DELETE ) {
+               goto done;
        }
 
        if ( *modlist == NULL ) {
@@ -917,11 +919,8 @@ syncrepl_entry(
                        return 0;
        }
 
-       if ( !attr_find( e->e_attrs, slap_schema.si_ad_entryUUID )) {
-               attr_merge_one( e, slap_schema.si_ad_entryUUID, syncUUID, syncUUID );
-       }
-
-       filterstr = (char *) sl_malloc( strlen("entryUUID=") + syncUUID->bv_len + 1, op->o_tmpmemctx ); 
+       filterstr = (char *) sl_malloc( strlen("entryUUID=") + syncUUID->bv_len + 1,
+                                                                       op->o_tmpmemctx ); 
        strcpy( filterstr, "entryUUID=" );
        strcat( filterstr, syncUUID->bv_val );
 
@@ -954,26 +953,27 @@ syncrepl_entry(
 
        cb.sc_response = null_callback;
 
-       if ( si->syncUUID_ndn )
-               printf("syncUUID_ndn = %s\n", si->syncUUID_ndn );
+       rc = LDAP_SUCCESS;
+
+       if ( si->syncUUID_ndn ) {
+               op->o_req_dn = *si->syncUUID_ndn;
+               op->o_req_ndn = *si->syncUUID_ndn;
+               op->o_tag = LDAP_REQ_DELETE;
+               rc = be->be_delete( op, &rs );
+       }
 
        switch ( syncstate ) {
        case LDAP_SYNC_ADD :
        case LDAP_SYNC_MODIFY :
 
-               rc = LDAP_SUCCESS;
-
-               if ( si->syncUUID_ndn ) {
-                       op->o_req_dn = *si->syncUUID_ndn;
-                       op->o_req_ndn = *si->syncUUID_ndn;
-                       op->o_tag = LDAP_REQ_DELETE;
-                       rc = be->be_delete( op, &rs );
-               }
-
                if ( rc == LDAP_SUCCESS ||
                         rc == LDAP_REFERRAL ||
                         rc == LDAP_NO_SUCH_OBJECT ||
                         rc == DB_NOTFOUND ) {
+
+                       if ( !attr_find( e->e_attrs, slap_schema.si_ad_entryUUID )) {
+                               attr_merge_one( e, slap_schema.si_ad_entryUUID, syncUUID, syncUUID );
+                       }
                        op->o_tag = LDAP_REQ_ADD;
                        op->ora_e = e;
                        op->o_req_dn = e->e_name;
@@ -1022,11 +1022,11 @@ syncrepl_entry(
 
                si->e = NULL;
                return 1;
+
        case LDAP_SYNC_DELETE :
-               op->o_tag = LDAP_REQ_DELETE;
-               be->be_delete( op, &rs );
-               si->e = NULL;
+               /* Already deleted */
                return 1;
+
        default :
 #ifdef NEW_LOGGING
                LDAP_LOG( OPERATION, ERR,