]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/syncrepl.c
build entry's pretty DN from parent's (ITS#5326)
[openldap] / servers / slapd / syncrepl.c
index af10aee04398fc689e693f0cc66dc6d473d27692..1b1db2f7373b4d4e7e4f5c36a4227106bd9ed106 100644 (file)
@@ -2846,8 +2846,24 @@ retry_add:;
 
                        case LDAP_REFERRAL:
                        /* we assume that LDAP_NO_SUCH_OBJECT is returned 
-                        * only if the suffix entry is not present */
+                        * only if the suffix entry is not present.
+                        * This should not happen during Persist phase.
+                        */
                        case LDAP_NO_SUCH_OBJECT:
+                               if ( abs(si->si_type) == LDAP_SYNC_REFRESH_AND_PERSIST &&
+                                       si->si_refreshDone ) {
+                                       /* Something's wrong, start over */
+                                       ber_bvarray_free( si->si_syncCookie.ctxcsn );
+                                       si->si_syncCookie.ctxcsn = NULL;
+                                       ldap_pvt_thread_mutex_lock( &si->si_cookieState->cs_mutex );
+                                       ber_bvarray_free( si->si_cookieState->cs_vals );
+                                       ch_free( si->si_cookieState->cs_sids );
+                                       si->si_cookieState->cs_vals = NULL;
+                                       si->si_cookieState->cs_sids = 0;
+                                       si->si_cookieState->cs_num = 0;
+                                       ldap_pvt_thread_mutex_unlock( &si->si_cookieState->cs_mutex );
+                                       return LDAP_NO_SUCH_OBJECT;
+                               }
                                rc = syncrepl_add_glue( op, entry );
                                entry = NULL;
                                break;
@@ -3499,8 +3515,8 @@ syncrepl_add_glue_ancestors(
        }
        
        if ( !BER_BVISEMPTY( &ptr ) ) {
-               dn.bv_len -= ptr.bv_len + 1;
-               dn.bv_val += ptr.bv_len + 1;
+               dn.bv_len -= ptr.bv_len + ( suffrdns != 0 );
+               dn.bv_val += ptr.bv_len + ( suffrdns != 0 );
        }
 
        /* the normalizedDNs are always the same length, no counting