From a3f4f0b2db703f5d2af06214b806464ffb3c5a34 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Thu, 2 Mar 2006 00:35:12 +0000 Subject: [PATCH] map result codes as required (ITS#4419) --- servers/slapd/back-meta/add.c | 16 +++++++++++----- servers/slapd/back-meta/delete.c | 16 +++++++++++----- servers/slapd/back-meta/init.c | 3 +++ servers/slapd/back-meta/modify.c | 20 ++++++++++---------- servers/slapd/back-meta/modrdn.c | 8 +++++++- 5 files changed, 42 insertions(+), 21 deletions(-) diff --git a/servers/slapd/back-meta/add.c b/servers/slapd/back-meta/add.c index 89453b8ec8..0d32ac7eb9 100644 --- a/servers/slapd/back-meta/add.c +++ b/servers/slapd/back-meta/add.c @@ -45,6 +45,7 @@ meta_back_add( Operation *op, SlapReply *rs ) dncookie dc; int msgid; int do_retry = 1; + int maperr = 1; Debug(LDAP_DEBUG_ARGS, "==> meta_back_add: %s\n", op->o_req_dn.bv_val, 0, 0 ); @@ -185,20 +186,19 @@ retry:; } rs->sr_err = LDAP_OTHER; + maperr = 0; rc = ldap_result( mc->mc_conns[ candidate ].msc_ld, msgid, LDAP_MSG_ALL, tvp, &res ); switch ( rc ) { case -1: - send_ldap_result( op, rs ); - goto cleanup; + break; case 0: ldap_abandon_ext( mc->mc_conns[ candidate ].msc_ld, msgid, NULL, NULL ); rs->sr_err = op->o_protocol >= LDAP_VERSION3 ? LDAP_ADMINLIMIT_EXCEEDED : LDAP_OPERATIONS_ERROR; - send_ldap_result( op, rs ); - goto cleanup; + break; case LDAP_RES_ADD: rc = ldap_parse_result( mc->mc_conns[ candidate ].msc_ld, @@ -206,6 +206,7 @@ retry:; if ( rc != LDAP_SUCCESS ) { rs->sr_err = rc; } + maperr = 1; break; default: @@ -214,7 +215,12 @@ retry:; } } - (void)meta_back_op_result( mc, op, rs, candidate ); + if ( maperr ) { + rs->sr_err = meta_back_op_result( mc, op, rs, candidate ); + + } else { + send_ldap_result( op, rs ); + } cleanup:; for ( --i; i >= 0; --i ) { diff --git a/servers/slapd/back-meta/delete.c b/servers/slapd/back-meta/delete.c index f0f5e4259f..aaeaa3837c 100644 --- a/servers/slapd/back-meta/delete.c +++ b/servers/slapd/back-meta/delete.c @@ -41,6 +41,7 @@ meta_back_delete( Operation *op, SlapReply *rs ) dncookie dc; int msgid; int do_retry = 1; + int maperr = 1; mc = meta_back_getconn( op, rs, &candidate, LDAP_BACK_SENDERR ); if ( !mc || !meta_back_dobind( op, rs, mc, LDAP_BACK_SENDERR ) ) { @@ -83,21 +84,20 @@ retry:; } rs->sr_err = LDAP_OTHER; + maperr = 0; rc = ldap_result( mc->mc_conns[ candidate ].msc_ld, msgid, LDAP_MSG_ALL, tvp, &res ); switch ( rc ) { case -1: rs->sr_err = LDAP_OTHER; - send_ldap_result( op, rs ); - goto cleanup; + break; case 0: ldap_abandon_ext( mc->mc_conns[ candidate ].msc_ld, msgid, NULL, NULL ); rs->sr_err = op->o_protocol >= LDAP_VERSION3 ? LDAP_ADMINLIMIT_EXCEEDED : LDAP_OPERATIONS_ERROR; - send_ldap_result( op, rs ); - goto cleanup; + break; case LDAP_RES_DELETE: rc = ldap_parse_result( mc->mc_conns[ candidate ].msc_ld, @@ -105,6 +105,7 @@ retry:; if ( rc != LDAP_SUCCESS ) { rs->sr_err = rc; } + maperr = 1; break; default: @@ -113,7 +114,12 @@ retry:; } } - rs->sr_err = meta_back_op_result( mc, op, rs, candidate ); + if ( maperr ) { + rs->sr_err = meta_back_op_result( mc, op, rs, candidate ); + + } else { + send_ldap_result( op, rs ); + } cleanup:; if ( mdn.bv_val != op->o_req_dn.bv_val ) { diff --git a/servers/slapd/back-meta/init.c b/servers/slapd/back-meta/init.c index 06549b9c8b..3697f41fd0 100644 --- a/servers/slapd/back-meta/init.c +++ b/servers/slapd/back-meta/init.c @@ -196,6 +196,9 @@ target_free( if ( mt->mt_uri ) { free( mt->mt_uri ); } + if ( mt->mt_subtree_exclude ) { + ber_bvarray_free( mt->mt_subtree_exclude ); + } if ( !BER_BVISNULL( &mt->mt_psuffix ) ) { free( mt->mt_psuffix.bv_val ); } diff --git a/servers/slapd/back-meta/modify.c b/servers/slapd/back-meta/modify.c index fd54c03fcc..20f04e28c2 100644 --- a/servers/slapd/back-meta/modify.c +++ b/servers/slapd/back-meta/modify.c @@ -37,6 +37,7 @@ meta_back_modify( Operation *op, SlapReply *rs ) metainfo_t *mi = ( metainfo_t * )op->o_bd->be_private; metaconn_t *mc; int rc = 0; + int maperr = 1; LDAPMod **modv = NULL; LDAPMod *mods = NULL; Modifications *ml; @@ -64,7 +65,7 @@ meta_back_modify( Operation *op, SlapReply *rs ) dc.ctx = "modifyDN"; if ( ldap_back_dn_massage( &dc, &op->o_req_dn, &mdn ) ) { - rc = -1; + maperr = 0; goto cleanup; } @@ -74,13 +75,13 @@ meta_back_modify( Operation *op, SlapReply *rs ) mods = ch_malloc( sizeof( LDAPMod )*i ); if ( mods == NULL ) { rs->sr_err = LDAP_NO_MEMORY; - rc = -1; + maperr = 0; goto cleanup; } modv = ( LDAPMod ** )ch_malloc( ( i + 1 )*sizeof( LDAPMod * ) ); if ( modv == NULL ) { rs->sr_err = LDAP_NO_MEMORY; - rc = -1; + maperr = 0; goto cleanup; } @@ -197,7 +198,7 @@ retry:; msgid, LDAP_MSG_ALL, tvp, &res ); switch ( rc ) { case -1: - rc = -1; + maperr = 0; break; case 0: @@ -205,7 +206,7 @@ retry:; msgid, NULL, NULL ); rs->sr_err = op->o_protocol >= LDAP_VERSION3 ? LDAP_ADMINLIMIT_EXCEEDED : LDAP_OPERATIONS_ERROR; - rc = -1; + maperr = 0; break; case LDAP_RES_MODIFY: @@ -214,11 +215,11 @@ retry:; if ( rc != LDAP_SUCCESS ) { rs->sr_err = rc; } - rc = 0; + maperr = 1; break; default: - rc = -1; + maperr = 0; ldap_msgfree( res ); break; } @@ -237,16 +238,15 @@ cleanup:; free( mods ); free( modv ); - if ( rc != -1 ) { + if ( maperr ) { rc = meta_back_op_result( mc, op, rs, candidate ); } else { send_ldap_result( op, rs ); - rc = 0; } meta_back_release_conn( op, mc ); - return rc; + return rs->sr_err; } diff --git a/servers/slapd/back-meta/modrdn.c b/servers/slapd/back-meta/modrdn.c index 0b0fcfb0ed..6536cab579 100644 --- a/servers/slapd/back-meta/modrdn.c +++ b/servers/slapd/back-meta/modrdn.c @@ -42,6 +42,7 @@ meta_back_modrdn( Operation *op, SlapReply *rs ) dncookie dc; int msgid; int do_retry = 1; + int maperr = 1; mc = meta_back_getconn( op, rs, &candidate, LDAP_BACK_SENDERR ); if ( !mc || !meta_back_dobind( op, rs, mc, LDAP_BACK_SENDERR ) ) { @@ -87,6 +88,7 @@ meta_back_modrdn( Operation *op, SlapReply *rs ) dc.ctx = "newSuperiorDN"; if ( ldap_back_dn_massage( &dc, op->orr_newSup, &mnewSuperior ) ) { rs->sr_err = LDAP_OTHER; + maperr = 0; goto cleanup; } } @@ -98,6 +100,7 @@ meta_back_modrdn( Operation *op, SlapReply *rs ) dc.ctx = "modrDN"; if ( ldap_back_dn_massage( &dc, &op->o_req_dn, &mdn ) ) { rs->sr_err = LDAP_OTHER; + maperr = 0; goto cleanup; } @@ -126,6 +129,7 @@ retry:; rs->sr_err = LDAP_OTHER; rc = ldap_result( mc->mc_conns[ candidate ].msc_ld, msgid, LDAP_MSG_ALL, tvp, &res ); + maperr = 0; switch ( rc ) { case -1: break; @@ -143,6 +147,7 @@ retry:; if ( rc != LDAP_SUCCESS ) { rs->sr_err = rc; } + maperr = 1; break; default: @@ -164,8 +169,9 @@ cleanup:; BER_BVZERO( &mnewSuperior ); } - if ( rs->sr_err == LDAP_SUCCESS ) { + if ( maperr ) { meta_back_op_result( mc, op, rs, candidate ); + } else { send_ldap_result( op, rs ); } -- 2.39.5