]> git.sur5r.net Git - openldap/commitdiff
ITS#5850
authorQuanah Gibson-Mount <quanah@openldap.org>
Fri, 12 Dec 2008 22:26:20 +0000 (22:26 +0000)
committerQuanah Gibson-Mount <quanah@openldap.org>
Fri, 12 Dec 2008 22:26:20 +0000 (22:26 +0000)
CHANGES
servers/slapd/bconfig.c
servers/slapd/slap.h
servers/slapd/syncrepl.c

diff --git a/CHANGES b/CHANGES
index bccd160fea240cd781b564d054a24924eba99886..0221258a0ea212440f7887d118a01b69e17bafa1 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -4,6 +4,7 @@ OpenLDAP 2.4.14 Engineering
        Fixed libldap peer cert memory leak (ITS#5849)
        Fixed libldap_r deref building (ITS#5768)
        Fixed slapd syncrepl rename handling (ITS#5809)
+       Fixed slapd syncrepl MMR when adding new server (ITS#5850)
        Build Environment
                Fixed test049,test050 to work on windows (ITS#5842)
 
index 8c1a9b91db18443bd076f062f036ae959d716c43..0517579b88fe6d58176fca08bf9d166be100a1ce 100644 (file)
@@ -3069,7 +3069,16 @@ config_shadow( ConfigArgs *c, int flag )
                return 1;
        }
 
-       SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SINGLE_SHADOW | flag);
+       if ( SLAP_SHADOW(c->be) ) {
+               /* if already shadow, only check consistency */
+               if ( ( SLAP_DBFLAGS(c->be) & flag ) != flag ) {
+                       Debug( LDAP_DEBUG_ANY, "%s: inconsistent shadow flag 0x%x.\n", c->log, flag, 0 );
+                       return 1;
+               }
+
+       } else {
+               SLAP_DBFLAGS(c->be) |= (SLAP_DBFLAG_SHADOW | SLAP_DBFLAG_SINGLE_SHADOW | flag);
+       }
 
        return 0;
 }
index 9a699456d3eced23274a6c3d7753e2f0c3ad896e..bbdb3d18457126f8dbbcf20820eeb42b9c5f8751 100644 (file)
@@ -1791,6 +1791,7 @@ struct BackendDB {
 #define SLAP_DBFLAG_SINGLE_SHADOW      0x4000U /* a single-master shadow */
 #define SLAP_DBFLAG_SYNC_SHADOW                0x1000U /* a sync shadow */
 #define SLAP_DBFLAG_SLURP_SHADOW       0x2000U /* a slurp shadow */
+#define SLAP_DBFLAG_SHADOW_MASK                (SLAP_DBFLAG_SHADOW|SLAP_DBFLAG_SINGLE_SHADOW|SLAP_DBFLAG_SYNC_SHADOW|SLAP_DBFLAG_SLURP_SHADOW)
 #define SLAP_DBFLAG_CLEAN              0x10000U /* was cleanly shutdown */
 #define SLAP_DBFLAG_ACL_ADD            0x20000U /* check attr ACLs on adds */
        slap_mask_t     be_flags;
index 1f17946e484afb68a43c85a42d0751fc047a6e87..357084cfe04144b51a4d585076acdc82e9e23e2e 100644 (file)
@@ -723,7 +723,6 @@ do_syncrep2(
        syncinfo_t *si )
 {
        LDAPControl     **rctrls = NULL;
-       LDAPControl     *rctrlp;
 
        BerElementBuffer berbuf;
        BerElement      *ber = (BerElement *)&berbuf;
@@ -780,6 +779,8 @@ do_syncrep2(
        while ( ( rc = ldap_result( si->si_ld, si->si_msgid, LDAP_MSG_ONE,
                tout_p, &msg ) ) > 0 )
        {
+               LDAPControl     *rctrlp = NULL;
+
                if ( slapd_shutdown ) {
                        rc = -2;
                        goto done;
@@ -788,18 +789,22 @@ do_syncrep2(
                case LDAP_RES_SEARCH_ENTRY:
                        ldap_get_entry_controls( si->si_ld, msg, &rctrls );
                        /* we can't work without the control */
-                       rctrlp = NULL;
                        if ( rctrls ) {
                                LDAPControl **next;
                                /* NOTE: make sure we use the right one;
                                 * a better approach would be to run thru
                                 * the whole list and take care of all */
+                               /* NOTE: since we issue the search request,
+                                * we should know what controls to expect,
+                                * and there should be none apart from the
+                                * sync-related control */
                                rctrlp = ldap_control_find( LDAP_CONTROL_SYNC_STATE, rctrls, &next );
                                if ( next && ldap_control_find( LDAP_CONTROL_SYNC_STATE, next, NULL ) )
                                {
                                        Debug( LDAP_DEBUG_ANY, "do_syncrep2: %s "
                                                "got search entry with multiple "
                                                "Sync State control\n", si->si_ridtxt, 0, 0 );
+                                       ldap_controls_free( rctrls );
                                        rc = -1;
                                        goto done;
                                }
@@ -920,7 +925,26 @@ do_syncrep2(
                                        si->si_ridtxt, err, ldap_err2string( err ) );
                        }
                        if ( rctrls ) {
-                               rctrlp = *rctrls;
+                               LDAPControl **next;
+                               /* NOTE: make sure we use the right one;
+                                * a better approach would be to run thru
+                                * the whole list and take care of all */
+                               /* NOTE: since we issue the search request,
+                                * we should know what controls to expect,
+                                * and there should be none apart from the
+                                * sync-related control */
+                               rctrlp = ldap_control_find( LDAP_CONTROL_SYNC_DONE, rctrls, &next );
+                               if ( next && ldap_control_find( LDAP_CONTROL_SYNC_DONE, next, NULL ) )
+                               {
+                                       Debug( LDAP_DEBUG_ANY, "do_syncrep2: %s "
+                                               "got search result with multiple "
+                                               "Sync State control\n", si->si_ridtxt, 0, 0 );
+                                       ldap_controls_free( rctrls );
+                                       rc = -1;
+                                       goto done;
+                               }
+                       }
+                       if ( rctrlp ) {
                                ber_init2( ber, &rctrlp->ldctl_value, LBER_USE_DER );
 
                                ber_scanf( ber, "{" /*"}"*/);
@@ -4446,7 +4470,7 @@ syncrepl_config( ConfigArgs *c )
                        }
                }
                if ( !c->be->be_syncinfo ) {
-                       SLAP_DBFLAGS( c->be ) &= ~(SLAP_DBFLAG_SHADOW|SLAP_DBFLAG_SYNC_SHADOW);
+                       SLAP_DBFLAGS( c->be ) &= ~SLAP_DBFLAG_SHADOW_MASK;
                        if ( cs ) {
                                ber_bvarray_free( cs->cs_vals );
                                ldap_pvt_thread_mutex_destroy( &cs->cs_mutex );