mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-21 03:10:25 +08:00
internal operation return value processing cleanup
This commit is contained in:
parent
e8b2c7f3be
commit
22df3f94e4
@ -1095,7 +1095,10 @@ syncrepl_entry(
|
||||
struct berval syncUUID_strrep = BER_BVNULL;
|
||||
struct berval uuid_bv = BER_BVNULL;
|
||||
|
||||
SlapReply rs = {REP_RESULT};
|
||||
SlapReply rs_search = {REP_RESULT};
|
||||
SlapReply rs_delete = {REP_RESULT};
|
||||
SlapReply rs_add = {REP_RESULT};
|
||||
SlapReply rs_modify = {REP_RESULT};
|
||||
Filter f = {0};
|
||||
AttributeAssertion ava = {0};
|
||||
int rc = LDAP_SUCCESS;
|
||||
@ -1152,8 +1155,8 @@ syncrepl_entry(
|
||||
|
||||
si->si_syncUUID_ndn.bv_val = NULL;
|
||||
|
||||
if ( limits_check( op, &rs ) == 0 ) {
|
||||
rc = be->be_search( op, &rs );
|
||||
if ( limits_check( op, &rs_search ) == 0 ) {
|
||||
rc = be->be_search( op, &rs_search );
|
||||
}
|
||||
|
||||
if ( op->ors_filterstr.bv_val ) {
|
||||
@ -1163,7 +1166,7 @@ syncrepl_entry(
|
||||
cb.sc_response = null_callback;
|
||||
cb.sc_private = si;
|
||||
|
||||
if ( rc == LDAP_SUCCESS && si->si_syncUUID_ndn.bv_val ) {
|
||||
if ( rs_search.sr_err == LDAP_SUCCESS && si->si_syncUUID_ndn.bv_val ) {
|
||||
char *subseq_ptr;
|
||||
|
||||
if ( syncstate != LDAP_SYNC_DELETE ) {
|
||||
@ -1180,7 +1183,7 @@ syncrepl_entry(
|
||||
op->o_req_dn = si->si_syncUUID_ndn;
|
||||
op->o_req_ndn = si->si_syncUUID_ndn;
|
||||
op->o_tag = LDAP_REQ_DELETE;
|
||||
rc = be->be_delete( op, &rs );
|
||||
rc = be->be_delete( op, &rs_delete );
|
||||
|
||||
org_req_dn = op->o_req_dn;
|
||||
org_req_ndn = op->o_req_ndn;
|
||||
@ -1191,7 +1194,7 @@ syncrepl_entry(
|
||||
op->o_ndn = op->o_bd->be_rootndn;
|
||||
op->o_managedsait = 1;
|
||||
|
||||
while ( rs.sr_err == LDAP_SUCCESS && op->o_delete_glue_parent ) {
|
||||
while ( rs_delete.sr_err == LDAP_SUCCESS && op->o_delete_glue_parent ) {
|
||||
op->o_delete_glue_parent = 0;
|
||||
if ( !be_issuffix( op->o_bd, &op->o_req_ndn )) {
|
||||
slap_callback cb = { NULL };
|
||||
@ -1200,7 +1203,7 @@ syncrepl_entry(
|
||||
op->o_req_dn = pdn;
|
||||
op->o_req_ndn = pdn;
|
||||
op->o_callback = &cb;
|
||||
op->o_bd->be_delete( op, &rs );
|
||||
op->o_bd->be_delete( op, &rs_delete );
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
@ -1219,10 +1222,10 @@ syncrepl_entry(
|
||||
switch ( syncstate ) {
|
||||
case LDAP_SYNC_ADD:
|
||||
case LDAP_SYNC_MODIFY:
|
||||
if ( rc == LDAP_SUCCESS ||
|
||||
rc == LDAP_REFERRAL ||
|
||||
rc == LDAP_NO_SUCH_OBJECT ||
|
||||
rc == LDAP_NOT_ALLOWED_ON_NONLEAF )
|
||||
if ( rs_search.sr_err == LDAP_SUCCESS ||
|
||||
rs_search.sr_err == LDAP_REFERRAL ||
|
||||
rs_search.sr_err == LDAP_NO_SUCH_OBJECT ||
|
||||
rs_search.sr_err == LDAP_NOT_ALLOWED_ON_NONLEAF )
|
||||
{
|
||||
attr_delete( &e->e_attrs, slap_schema.si_ad_entryUUID );
|
||||
attr_merge_one( e, slap_schema.si_ad_entryUUID,
|
||||
@ -1232,10 +1235,12 @@ syncrepl_entry(
|
||||
op->ora_e = e;
|
||||
op->o_req_dn = e->e_name;
|
||||
op->o_req_ndn = e->e_nname;
|
||||
rc = be->be_add( op, &rs );
|
||||
|
||||
if ( rc != LDAP_SUCCESS ) {
|
||||
if ( rc == LDAP_ALREADY_EXISTS ) {
|
||||
rc = be->be_add( op, &rs_add );
|
||||
|
||||
if ( rs_add.sr_err != LDAP_SUCCESS ) {
|
||||
if ( rs_add.sr_err == LDAP_ALREADY_EXISTS &&
|
||||
rs_search.sr_err != LDAP_NO_SUCH_OBJECT ) {
|
||||
Modifications *mod;
|
||||
Modifications *modtail = modlist;
|
||||
|
||||
@ -1258,21 +1263,22 @@ syncrepl_entry(
|
||||
op->o_req_dn = e->e_name;
|
||||
op->o_req_ndn = e->e_nname;
|
||||
|
||||
rc = be->be_modify( op, &rs );
|
||||
if ( rc != LDAP_SUCCESS ) {
|
||||
rc = be->be_modify( op, &rs_modify );
|
||||
if ( rs_modify.sr_err != LDAP_SUCCESS ) {
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG( OPERATION, ERR,
|
||||
"syncrepl_entry : be_modify failed (%d)\n",
|
||||
rc, 0, 0 );
|
||||
rs_modify.sr_err, 0, 0 );
|
||||
#else
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"syncrepl_entry : be_modify failed (%d)\n",
|
||||
rc, 0, 0 );
|
||||
rs_modify.sr_err, 0, 0 );
|
||||
#endif
|
||||
}
|
||||
ret = 1;
|
||||
goto done;
|
||||
} else if ( rc == LDAP_REFERRAL || rc == LDAP_NO_SUCH_OBJECT ) {
|
||||
} else if ( rs_modify.sr_err == LDAP_REFERRAL ||
|
||||
rs_modify.sr_err == LDAP_NO_SUCH_OBJECT ) {
|
||||
syncrepl_add_glue( op, e );
|
||||
ret = 0;
|
||||
goto done;
|
||||
@ -1280,11 +1286,11 @@ syncrepl_entry(
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG( OPERATION, ERR,
|
||||
"syncrepl_entry : be_add failed (%d)\n",
|
||||
rc, 0, 0 );
|
||||
rs_add.sr_err, 0, 0 );
|
||||
#else
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"syncrepl_entry : be_add failed (%d)\n",
|
||||
rc, 0, 0 );
|
||||
rs_add.sr_err, 0, 0 );
|
||||
#endif
|
||||
ret = 1;
|
||||
goto done;
|
||||
@ -1297,10 +1303,12 @@ syncrepl_entry(
|
||||
} else {
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG( OPERATION, ERR,
|
||||
"syncrepl_entry : be_search failed (%d)\n", rc, 0, 0 );
|
||||
"syncrepl_entry : be_search failed (%d)\n",
|
||||
rs_search.sr_err, 0, 0 );
|
||||
#else
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"syncrepl_entry : be_search failed (%d)\n", rc, 0, 0 );
|
||||
"syncrepl_entry : be_search failed (%d)\n",
|
||||
rs_search.sr_err, 0, 0 );
|
||||
#endif
|
||||
ret = 1;
|
||||
goto done;
|
||||
@ -1347,7 +1355,9 @@ syncrepl_del_nonpresent(
|
||||
{
|
||||
Backend* be = op->o_bd;
|
||||
slap_callback cb = { NULL };
|
||||
SlapReply rs = {REP_RESULT};
|
||||
SlapReply rs_search = {REP_RESULT};
|
||||
SlapReply rs_delete = {REP_RESULT};
|
||||
SlapReply rs_modify = {REP_RESULT};
|
||||
struct nonpresent_entry *np_list, *np_prev;
|
||||
int rc;
|
||||
Modifications *ml;
|
||||
@ -1385,8 +1395,8 @@ syncrepl_del_nonpresent(
|
||||
op->o_nocaching = 1;
|
||||
op->o_managedsait = 0;
|
||||
|
||||
if ( limits_check( op, &rs ) == 0 ) {
|
||||
be->be_search( op, &rs );
|
||||
if ( limits_check( op, &rs_search ) == 0 ) {
|
||||
rc = be->be_search( op, &rs_search );
|
||||
}
|
||||
|
||||
op->o_managedsait = 1;
|
||||
@ -1406,9 +1416,9 @@ syncrepl_del_nonpresent(
|
||||
cb.sc_private = si;
|
||||
op->o_req_dn = *np_prev->npe_name;
|
||||
op->o_req_ndn = *np_prev->npe_nname;
|
||||
rc = op->o_bd->be_delete( op, &rs );
|
||||
rc = op->o_bd->be_delete( op, &rs_delete );
|
||||
|
||||
if ( rc == LDAP_NOT_ALLOWED_ON_NONLEAF ) {
|
||||
if ( rs_delete.sr_err == LDAP_NOT_ALLOWED_ON_NONLEAF ) {
|
||||
mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ));
|
||||
mod->sml_op = LDAP_MOD_REPLACE;
|
||||
mod->sml_desc = slap_schema.si_ad_objectClass;
|
||||
@ -1428,7 +1438,7 @@ syncrepl_del_nonpresent(
|
||||
op->o_tag = LDAP_REQ_MODIFY;
|
||||
op->orm_modlist = modlist;
|
||||
|
||||
rc = be->be_modify( op, &rs );
|
||||
rc = be->be_modify( op, &rs_modify );
|
||||
|
||||
for ( ml = modlist; ml != NULL; ml = mlnext ) {
|
||||
mlnext = ml->sml_next;
|
||||
@ -1445,7 +1455,7 @@ syncrepl_del_nonpresent(
|
||||
op->o_ndn = op->o_bd->be_rootndn;
|
||||
op->o_managedsait = 1;
|
||||
|
||||
while ( rs.sr_err == LDAP_SUCCESS &&
|
||||
while ( rs_delete.sr_err == LDAP_SUCCESS &&
|
||||
op->o_delete_glue_parent ) {
|
||||
op->o_delete_glue_parent = 0;
|
||||
if ( !be_issuffix( op->o_bd, &op->o_req_ndn )) {
|
||||
@ -1456,7 +1466,7 @@ syncrepl_del_nonpresent(
|
||||
op->o_req_ndn = pdn;
|
||||
op->o_callback = &cb;
|
||||
/* give it a root privil ? */
|
||||
op->o_bd->be_delete( op, &rs );
|
||||
op->o_bd->be_delete( op, &rs_delete );
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
@ -1494,7 +1504,7 @@ syncrepl_add_glue(
|
||||
struct berval dn = {0, NULL};
|
||||
struct berval ndn = {0, NULL};
|
||||
Entry *glue;
|
||||
SlapReply rs = {REP_RESULT};
|
||||
SlapReply rs_add = {REP_RESULT};
|
||||
char *ptr, *comma;
|
||||
|
||||
op->o_tag = LDAP_REQ_ADD;
|
||||
@ -1570,8 +1580,8 @@ syncrepl_add_glue(
|
||||
op->o_req_dn = glue->e_name;
|
||||
op->o_req_ndn = glue->e_nname;
|
||||
op->ora_e = glue;
|
||||
rc = be->be_add ( op, &rs );
|
||||
if ( rc == LDAP_SUCCESS ) {
|
||||
rc = be->be_add ( op, &rs_add );
|
||||
if ( rs_add.sr_err == LDAP_SUCCESS ) {
|
||||
be_entry_release_w( op, glue );
|
||||
} else {
|
||||
/* incl. ALREADY EXIST */
|
||||
@ -1598,8 +1608,8 @@ syncrepl_add_glue(
|
||||
op->o_req_dn = e->e_name;
|
||||
op->o_req_ndn = e->e_nname;
|
||||
op->ora_e = e;
|
||||
rc = be->be_add ( op, &rs );
|
||||
if ( rc == LDAP_SUCCESS ) {
|
||||
rc = be->be_add ( op, &rs_add );
|
||||
if ( rs_add.sr_err == LDAP_SUCCESS ) {
|
||||
be_entry_release_w( op, e );
|
||||
} else {
|
||||
entry_free( e );
|
||||
@ -1656,7 +1666,8 @@ syncrepl_updateCookie(
|
||||
struct berval slap_syncrepl_cn_bv = BER_BVNULL;
|
||||
|
||||
slap_callback cb = { NULL };
|
||||
SlapReply rs = {REP_RESULT};
|
||||
SlapReply rs_add = {REP_RESULT};
|
||||
SlapReply rs_modify = {REP_RESULT};
|
||||
|
||||
slap_sync_cookie_free( &si->si_syncCookie, 0 );
|
||||
slap_dup_sync_cookie( &si->si_syncCookie, syncCookie );
|
||||
@ -1762,19 +1773,19 @@ syncrepl_updateCookie(
|
||||
update_cookie_retry:
|
||||
op->o_tag = LDAP_REQ_MODIFY;
|
||||
op->orm_modlist = modlist;
|
||||
rc = be->be_modify( op, &rs );
|
||||
rc = be->be_modify( op, &rs_modify );
|
||||
|
||||
if ( rc != LDAP_SUCCESS ) {
|
||||
if ( rc == LDAP_REFERRAL ||
|
||||
rc == LDAP_NO_SUCH_OBJECT ) {
|
||||
if ( rs_modify.sr_err != LDAP_SUCCESS ) {
|
||||
if ( rs_modify.sr_err == LDAP_REFERRAL ||
|
||||
rs_modify.sr_err == LDAP_NO_SUCH_OBJECT ) {
|
||||
op->o_tag = LDAP_REQ_ADD;
|
||||
op->ora_e = e;
|
||||
rc = be->be_add( op, &rs );
|
||||
if ( rc != LDAP_SUCCESS ) {
|
||||
if ( rc == LDAP_ALREADY_EXISTS ) {
|
||||
rc = be->be_add( op, &rs_add );
|
||||
if ( rs_add.sr_err != LDAP_SUCCESS ) {
|
||||
if ( rs_add.sr_err == LDAP_ALREADY_EXISTS ) {
|
||||
goto update_cookie_retry;
|
||||
} else if ( rc == LDAP_REFERRAL ||
|
||||
rc == LDAP_NO_SUCH_OBJECT ) {
|
||||
} else if ( rs_add.sr_err == LDAP_REFERRAL ||
|
||||
rs_add.sr_err == LDAP_NO_SUCH_OBJECT ) {
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG( OPERATION, ERR,
|
||||
"cookie will be non-persistent\n",
|
||||
@ -1787,12 +1798,10 @@ update_cookie_retry:
|
||||
} else {
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG( OPERATION, ERR,
|
||||
"be_add failed (%d)\n",
|
||||
rc, 0, 0 );
|
||||
"be_add failed (%d)\n", rs_add.sr_err, 0, 0 );
|
||||
#else
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"be_add failed (%d)\n",
|
||||
rc, 0, 0 );
|
||||
"be_add failed (%d)\n", rs_add.sr_err, 0, 0 );
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
@ -1802,10 +1811,10 @@ update_cookie_retry:
|
||||
} else {
|
||||
#ifdef NEW_LOGGING
|
||||
LDAP_LOG( OPERATION, ERR,
|
||||
"be_modify failed (%d)\n", rc, 0, 0 );
|
||||
"be_modify failed (%d)\n", rs_modify.sr_err, 0, 0 );
|
||||
#else
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"be_modify failed (%d)\n", rc, 0, 0 );
|
||||
"be_modify failed (%d)\n", rs_modify.sr_err, 0, 0 );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user