From: Quanah Gibson-Mount Date: Fri, 12 Dec 2008 22:26:20 +0000 (+0000) Subject: ITS#5850 X-Git-Tag: OPENLDAP_REL_ENG_2_4_14~139 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2d29171430ac8c39fdfa797e7af67a0e595b34ef;p=openldap ITS#5850 --- diff --git a/CHANGES b/CHANGES index bccd160fea..0221258a0e 100644 --- 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) diff --git a/servers/slapd/bconfig.c b/servers/slapd/bconfig.c index 8c1a9b91db..0517579b88 100644 --- a/servers/slapd/bconfig.c +++ b/servers/slapd/bconfig.c @@ -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; } diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 9a699456d3..bbdb3d1845 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -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; diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 1f17946e48..357084cfe0 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -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 );