fix the glueing code

This commit is contained in:
Jong Hyuk Choi 2003-06-25 22:28:50 +00:00
parent 2e793edc77
commit 9faeffe8c6

View file

@ -992,11 +992,15 @@ syncrepl_entry(
op->o_req_dn = e->e_name;
op->o_req_ndn = e->e_nname;
rc = be->be_modify( op, &rs );
si->e = NULL;
return 0;
} else if ( rc == LDAP_REFERRAL ||
rc == LDAP_NO_SUCH_OBJECT ) {
syncrepl_add_glue( si, ld, op, e,
modlist, syncstate,
syncUUID, syncCookie);
si->e = NULL;
return 0;
} else {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, ERR,
@ -1007,8 +1011,11 @@ syncrepl_entry(
"be_modify failed (%d)\n",
rc, 0, 0 );
#endif
si->e = NULL;
return 1;
}
} else {
si->e = NULL;
return 0;
}
} else {
@ -1019,11 +1026,10 @@ syncrepl_entry(
Debug( LDAP_DEBUG_ANY,
"be_modify/be_delete failed (%d)\n", rc, 0, 0 );
#endif
si->e = NULL;
return 1;
}
si->e = NULL;
return 1;
case LDAP_SYNC_DELETE :
/* Already deleted */
return 1;
@ -1136,6 +1142,7 @@ syncrepl_add_glue(
Entry *glue;
SlapReply rs = {REP_RESULT};
Connection *conn = op->o_conn;
char* ptr;
op->o_tag = LDAP_REQ_ADD;
op->o_callback = &cb;
@ -1145,49 +1152,66 @@ syncrepl_add_glue(
ber_dupbv( &dn, &e->e_nname );
ber_dupbv( &pdn, &e->e_nname );
ptr = dn.bv_val;
while ( !be_issuffix ( be, &pdn )) {
dnParent( &dn, &pdn );
ch_free( dn.bv_val );
ber_dupbv( &dn, &pdn );
dn.bv_val = pdn.bv_val;
dn.bv_len = pdn.bv_len;
levels++;
}
ch_free( ptr );
for ( i = 0; i <= levels; i++ ) {
glue = (Entry*) ch_calloc( 1, sizeof(Entry) );
ch_free( dn.bv_val );
ch_free( pdn.bv_val );
glue->e_private = NULL;
ber_dupbv( &dn, &e->e_nname );
ber_dupbv( &pdn, &e->e_nname );
j = levels - i;
ptr = dn.bv_val;
for ( k = 0; k < j; k++ ) {
dnParent( &dn, &pdn );
ch_free( dn.bv_val );
ber_dupbv( &dn, &pdn );
dn.bv_val = pdn.bv_val;
dn.bv_len = pdn.bv_len;
}
dnPrettyNormal( 0, &dn, &pdn, &ndn, op->o_tmpmemctx );
ber_dupbv( &glue->e_name, &pdn );
ber_dupbv( &glue->e_nname, &ndn );
ch_free( dn.bv_val );
ch_free( ptr );
ch_free( pdn.bv_val );
ch_free( ndn.bv_val );
a = ch_calloc( 1, sizeof( Attribute ));
a->a_desc = slap_schema.si_ad_objectClass;
a->a_vals = ch_calloc( 3, sizeof( struct berval ));
ber_str2bv( "top", strlen("top"), 1, &a->a_vals[0] );
ber_str2bv( "glue", strlen("glue"), 1, &a->a_vals[1] );
a->a_vals[2].bv_len = 0;
a->a_vals[2].bv_val = NULL;
a->a_nvals = ch_calloc( 3, sizeof( struct berval ));
ber_str2bv( "top", strlen("top"), 1, &a->a_nvals[0] );
ber_str2bv( "glue", strlen("glue"), 1, &a->a_nvals[1] );
a->a_nvals[2].bv_len = 0;
a->a_nvals[2].bv_val = NULL;
a->a_next = glue->e_attrs;
glue->e_attrs = a;
a = ch_calloc( 1, sizeof( Attribute ));
a->a_desc = slap_schema.si_ad_structuralObjectClass;
a->a_vals = ch_calloc( 2, sizeof( struct berval ));
ber_str2bv( "glue", strlen("glue"), 1, &a->a_vals[0] );
a->a_vals[1].bv_len = 0;
a->a_vals[1].bv_val = NULL;
a->a_nvals = ch_calloc( 2, sizeof( struct berval ));
ber_str2bv( "glue", strlen("glue"), 1, &a->a_nvals[0] );
a->a_nvals[1].bv_len = 0;
a->a_nvals[1].bv_val = NULL;
a->a_next = glue->e_attrs;
glue->e_attrs = a;