]> git.sur5r.net Git - openldap/commitdiff
map result codes as required (ITS#4419)
authorPierangelo Masarati <ando@openldap.org>
Thu, 2 Mar 2006 00:35:12 +0000 (00:35 +0000)
committerPierangelo Masarati <ando@openldap.org>
Thu, 2 Mar 2006 00:35:12 +0000 (00:35 +0000)
servers/slapd/back-meta/add.c
servers/slapd/back-meta/delete.c
servers/slapd/back-meta/init.c
servers/slapd/back-meta/modify.c
servers/slapd/back-meta/modrdn.c

index 89453b8ec82153f9bd97bf8b5d3aacd2b4fcae82..0d32ac7eb93e1d86ddaf6e836595e8338dd41eb5 100644 (file)
@@ -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 ) {
index f0f5e4259ffe1906b42e6d9e67654f5af5b63743..aaeaa3837c2d8522bd38ee85da43e28f8b1be7d7 100644 (file)
@@ -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 ) {
index 06549b9c8b98bb8e2e5abbdbf3a210d8b7e30e17..3697f41fd014c27bc8219195527b6261e760a778 100644 (file)
@@ -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 );
        }
index fd54c03fcca7f4b88832cbf321540f020f0eb33e..20f04e28c2eaff4f108fe3542e931639bb3fc449 100644 (file)
@@ -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;
 }
 
index 0b0fcfb0edf3a22f64fd897c08dafe74745328c5..6536cab579636ae0b04d69e6784be65e94f22e30 100644 (file)
@@ -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 );
        }