From: Howard Chu Date: Wed, 11 Nov 2009 03:36:46 +0000 (+0000) Subject: ITS#6373 create subentry if missing X-Git-Tag: ACLCHECK_0~133 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9ad558b78c9f8318360a12164f04cfd11778faa1;p=openldap ITS#6373 create subentry if missing --- diff --git a/servers/slapd/overlays/syncprov.c b/servers/slapd/overlays/syncprov.c index 03678ec026..3486cfa6d3 100644 --- a/servers/slapd/overlays/syncprov.c +++ b/servers/slapd/overlays/syncprov.c @@ -1399,6 +1399,20 @@ syncprov_checkpoint( Operation *op, SlapReply *rs, slap_overinst *on ) opm.o_managedsait = SLAP_CONTROL_NONCRITICAL; opm.o_no_schema_check = 1; opm.o_bd->be_modify( &opm, &rsm ); + + /* Should only happen with SYNC_USE_SUBENTRY */ + if ( rsm.sr_err == LDAP_NO_SUCH_OBJECT ) { + const char *text; + char txtbuf[SLAP_TEXT_BUFLEN]; + size_t textlen = sizeof txtbuf; + Entry *e = slap_create_context_csn_entry( opm.o_bd, NULL ); + slap_mods2entry( &mod, &e, 0, 1, &text, txtbuf, textlen); + opm.ora_e = e; + opm.o_bd->be_add( &opm, &rsm ); + if ( e == opm.ora_e ) + be_entry_release_w( &opm, opm.ora_e ); + } + if ( mod.sml_next != NULL ) { slap_mods_free( mod.sml_next, 1 ); } diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index b6dacb0122..ac0379c8ea 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -3061,6 +3061,20 @@ syncrepl_updateCookie( op->orm_modlist = &mod; op->orm_no_opattrs = 1; rc = op->o_bd->be_modify( op, &rs_modify ); + + /* Should only happen when SYNC_USE_SUBENTRY */ + if ( rs_modify.sr_err == LDAP_NO_SUCH_OBJECT ) { + const char *text; + char txtbuf[SLAP_TEXT_BUFLEN]; + size_t textlen = sizeof txtbuf; + Entry *e = slap_create_context_csn_entry( op->o_bd, NULL ); + rc = slap_mods2entry( &mod, &e, 0, 1, &text, txtbuf, textlen); + op->ora_e = e; + rc = op->o_bd->be_add( op, &rs_modify ); + if ( e == op->ora_e ) + be_entry_release_w( op, op->ora_e ); + } + op->orm_no_opattrs = 0; op->o_dont_replicate = 0;