]> git.sur5r.net Git - openldap/commitdiff
ITS#6758 Rewrite code for contrib:wrap_slap_ops.
authorHallvard Furuseth <hallvard@openldap.org>
Wed, 11 Dec 2013 13:40:45 +0000 (14:40 +0100)
committerHallvard Furuseth <hallvard@openldap.org>
Wed, 11 Dec 2013 13:40:45 +0000 (14:40 +0100)
Tweak slapd code so wrap_slap_ops can process it: Use pointers
BackendInfo *bi instead of array "func" = &bi->bi_op_bind. In
slapo-chain, keep a slap_operation_t instead of a function ptr.

servers/slapd/back-ldap/chain.c
servers/slapd/back-relay/op.c
servers/slapd/backglue.c
servers/slapd/backover.c
servers/slapd/overlays/pcache.c
servers/slapd/slapi/slapi_ops.c

index 3ecc3b673c359282a3f651a11326ba8d0ea99f65..79e4ae882ba2544ad130cfecf5f4a78019fba9a4 100644 (file)
@@ -118,7 +118,7 @@ static int ldap_chain_db_open_one( BackendDB *be );
 typedef struct ldap_chain_cb_t {
        ldap_chain_status_t     lb_status;
        ldap_chain_t            *lb_lc;
-       BI_op_func              *lb_op_f;
+       slap_operation_t        lb_op_type;
        int                     lb_depth;
 } ldap_chain_cb_t;
 
@@ -126,7 +126,7 @@ static int
 ldap_chain_op(
        Operation       *op,
        SlapReply       *rs,
-       BI_op_func      *op_f,
+       slap_operation_t op_type,
        BerVarray       ref,
        int             depth );
 
@@ -316,7 +316,8 @@ ldap_chain_cb_search_response( Operation *op, SlapReply *rs )
                        && lb->lb_depth < lb->lb_lc->lc_max_depth
                        && rs->sr_ref != NULL )
                {
-                       rs->sr_err = ldap_chain_op( op, rs, lb->lb_op_f, rs->sr_ref, lb->lb_depth );
+                       rs->sr_err = ldap_chain_op( op, rs, lb->lb_op_type,
+                               rs->sr_ref, lb->lb_depth );
                }
 
                /* back-ldap tried to send result */
@@ -356,7 +357,8 @@ retry:;
 
                case LDAP_REFERRAL:
                        if ( lb->lb_depth < lb->lb_lc->lc_max_depth && rs->sr_ref != NULL ) {
-                               rs->sr_err = ldap_chain_op( op, rs, lb->lb_op_f, rs->sr_ref, lb->lb_depth );
+                               rs->sr_err = ldap_chain_op( op, rs, lb->lb_op_type,
+                                       rs->sr_ref, lb->lb_depth );
                                goto retry;
                        }
 
@@ -391,7 +393,7 @@ static int
 ldap_chain_op(
        Operation       *op,
        SlapReply       *rs,
-       BI_op_func      *op_f,
+       slap_operation_t op_type,
        BerVarray       ref,
        int             depth )
 {
@@ -602,10 +604,10 @@ Document: RFC 4511
                                op->o_log_prefix, ref->bv_val, temporary ? "temporary" : "caching" );
                }
 
-               lb->lb_op_f = op_f;
+               lb->lb_op_type = op_type;
                lb->lb_depth = depth + 1;
 
-               rc = op_f( op, &rs2 );
+               rc = (&lback->bi_op_bind)[ op_type ]( op, &rs2 );
 
                /* note the first error */
                if ( first_rc == -1 ) {
@@ -873,7 +875,7 @@ ldap_chain_search(
                                op->o_log_prefix, ref->bv_val, temporary ? "temporary" : "caching" );
                }
 
-               lb->lb_op_f = lback->bi_op_search;
+               lb->lb_op_type = op_search;
                lb->lb_depth = depth + 1;
 
                /* FIXME: should we also copy filter and scope?
@@ -1041,30 +1043,30 @@ ldap_chain_response( Operation *op, SlapReply *rs )
                /* FIXME: can we really get a referral for binds? */
                op->o_req_ndn = slap_empty_bv;
                op->o_conn = NULL;
-               rc = ldap_chain_op( op, rs, lback->bi_op_bind, ref, 0 );
+               rc = ldap_chain_op( op, rs, op_bind, ref, 0 );
                op->o_req_ndn = rndn;
                op->o_conn = conn;
                }
                break;
 
        case LDAP_REQ_ADD:
-               rc = ldap_chain_op( op, rs, lback->bi_op_add, ref, 0 );
+               rc = ldap_chain_op( op, rs, op_add, ref, 0 );
                break;
 
        case LDAP_REQ_DELETE:
-               rc = ldap_chain_op( op, rs, lback->bi_op_delete, ref, 0 );
+               rc = ldap_chain_op( op, rs, op_delete, ref, 0 );
                break;
 
        case LDAP_REQ_MODRDN:
-               rc = ldap_chain_op( op, rs, lback->bi_op_modrdn, ref, 0 );
+               rc = ldap_chain_op( op, rs, op_modrdn, ref, 0 );
                break;
 
        case LDAP_REQ_MODIFY:
-               rc = ldap_chain_op( op, rs, lback->bi_op_modify, ref, 0 );
+               rc = ldap_chain_op( op, rs, op_modify, ref, 0 );
                break;
 
        case LDAP_REQ_COMPARE:
-               rc = ldap_chain_op( op, rs, lback->bi_op_compare, ref, 0 );
+               rc = ldap_chain_op( op, rs, op_compare, ref, 0 );
                if ( rs->sr_err == LDAP_COMPARE_TRUE || rs->sr_err == LDAP_COMPARE_FALSE ) {
                        rc = LDAP_SUCCESS;
                }
@@ -1081,8 +1083,7 @@ ldap_chain_response( Operation *op, SlapReply *rs )
                         * to check limits, to make sure safe defaults
                         * are in place */
                        if ( op->ors_limit != NULL || limits_check( op, rs ) == 0 ) {
-                               rc = ldap_chain_op( op, rs, lback->bi_op_search, ref, 0 );
-
+                               rc = ldap_chain_op( op, rs, op_search, ref, 0 );
                        } else {
                                rc = SLAP_CB_CONTINUE;
                        }
@@ -1090,7 +1091,7 @@ ldap_chain_response( Operation *op, SlapReply *rs )
                break;
 
        case LDAP_REQ_EXTENDED:
-               rc = ldap_chain_op( op, rs, lback->bi_extended, ref, 0 );
+               rc = ldap_chain_op( op, rs, op_extended, ref, 0 );
                /* FIXME: ldap_back_extended() by design 
                 * doesn't send result; frontend is expected
                 * to send it... */
index 7c8b4aecbf0fd5051dd0b9b768655966ce3a41b5..89093bc03403c8f670ecdd7f1e1a0c9ed51a0fc9 100644 (file)
@@ -194,7 +194,7 @@ static int
 relay_back_op( Operation *op, SlapReply *rs, int which )
 {
        BackendDB       *bd;
-       BI_op_bind      *func;
+       BackendInfo     *bi;
        slap_mask_t     fail_mode = relay_fail_modes[which].rf_op;
        int             rc = ( fail_mode & RB_ERR_MASK );
 
@@ -203,12 +203,12 @@ relay_back_op( Operation *op, SlapReply *rs, int which )
                if ( fail_mode & RB_BDERR )
                        return rs->sr_err;      /* sr_err was set above */
 
-       } else if ( (func = (&bd->be_bind)[which]) != 0 ) {
+       } else if ( (&( bi = bd->bd_info )->bi_op_bind)[which] ) {
                relay_callback  rcb;
 
                relay_back_add_cb( &rcb, op );
                RELAY_WRAP_OP( op, bd, which, {
-                       rc = func( op, rs );
+                       rc = (&bi->bi_op_bind)[which]( op, rs );
                });
                relay_back_remove_cb( &rcb, op );
 
index 8f0d12a1eff2fa16fd8a255a41552880ee0d23f2..1c066d18541e073e135d5963e559e8e912126587 100644 (file)
@@ -225,8 +225,7 @@ glue_op_func ( Operation *op, SlapReply *rs )
 {
        slap_overinst   *on = (slap_overinst *)op->o_bd->bd_info;
        BackendDB *b0 = op->o_bd;
-       BackendInfo *bi0 = op->o_bd->bd_info;
-       BI_op_modify **func;
+       BackendInfo *bi0 = op->o_bd->bd_info, *bi1;
        slap_operation_t which = op_bind;
        int rc;
 
@@ -247,11 +246,9 @@ glue_op_func ( Operation *op, SlapReply *rs )
        default: assert( 0 ); break;
        }
 
-       func = &op->o_bd->bd_info->bi_op_bind;
-       if ( func[which] )
-               rc = func[which]( op, rs );
-       else
-               rc = SLAP_CB_BYPASS;
+       bi1 = op->o_bd->bd_info;
+       rc = (&bi1->bi_op_bind)[ which ] ?
+               (&bi1->bi_op_bind)[ which ]( op, rs ) : SLAP_CB_BYPASS;
 
        op->o_bd = b0;
        op->o_bd->bd_info = bi0;
index 02dc5125cbba412a0a532b6bbd6138b30a392d75..4cf47cdcc826d9e31eedd3eb00f30f8a3a0dbb08 100644 (file)
@@ -669,26 +669,26 @@ int overlay_op_walk(
        slap_overinst *on
 )
 {
-       BI_op_bind **func;
+       BackendInfo *bi;
        int rc = SLAP_CB_CONTINUE;
 
        for (; on; on=on->on_next ) {
                if ( on->on_bi.bi_flags & SLAPO_BFLAG_DISABLED )
                        continue;
-               func = &on->on_bi.bi_op_bind;
-               if ( func[which] ) {
+               bi = &on->on_bi;
+               if ( (&bi->bi_op_bind)[ which ] ) {
                        op->o_bd->bd_info = (BackendInfo *)on;
-                       rc = func[which]( op, rs );
+                       rc = (&bi->bi_op_bind)[ which ]( op, rs );
                        if ( rc != SLAP_CB_CONTINUE ) break;
                }
        }
        if ( rc == SLAP_CB_BYPASS )
                rc = SLAP_CB_CONTINUE;
 
-       func = &oi->oi_orig->bi_op_bind;
-       if ( func[which] && rc == SLAP_CB_CONTINUE ) {
-               op->o_bd->bd_info = oi->oi_orig;
-               rc = func[which]( op, rs );
+       bi = oi->oi_orig;
+       if ( (&bi->bi_op_bind)[ which ] && rc == SLAP_CB_CONTINUE ) {
+               op->o_bd->bd_info = bi;
+               rc = (&bi->bi_op_bind)[ which ]( op, rs );
        }
        /* should not fall thru this far without anything happening... */
        if ( rc == SLAP_CB_CONTINUE ) {
@@ -1451,4 +1451,3 @@ overlay_config( BackendDB *be, const char *ov, int idx, BackendInfo **res, Confi
 
        return 0;
 }
-
index 8356e49bc332a5ec3df75a7182bf2be36b4ac305..cd81a68ed2925f882a3734dbb2062961c58f6cdd 100644 (file)
@@ -2792,17 +2792,16 @@ pcache_op_privdb(
        /* map tag to operation */
        type = slap_req2op( op->o_tag );
        if ( type != SLAP_OP_LAST ) {
-               BI_op_func      **func;
+               BackendInfo     *bi = cm->db.bd_info;
                int             rc;
 
                /* execute, if possible */
-               func = &cm->db.be_bind;
-               if ( func[ type ] != NULL ) {
+               if ( (&bi->bi_op_bind)[ type ] ) {
                        Operation       op2 = *op;
        
                        op2.o_bd = &cm->db;
 
-                       rc = func[ type ]( &op2, rs );
+                       rc = (&bi->bi_op_bind)[ type ]( &op2, rs );
                        if ( type == SLAP_OP_BIND && rc == LDAP_SUCCESS ) {
                                op->o_conn->c_authz_cookie = cm->db.be_private;
                        }
index 7db0c315adfa8fdb843fde0ef7ba25fac4090706..326c57b7cebc0d926278c3300f5cffa1d7c09fe5 100644 (file)
@@ -384,7 +384,6 @@ slapi_int_connection_done_pb( Slapi_PBlock *pb )
 static int
 slapi_int_func_internal_pb( Slapi_PBlock *pb, slap_operation_t which )
 {
-       BI_op_bind              **func;
        SlapReply               *rs = pb->pb_rs;
        int                     rc;
 
@@ -397,9 +396,7 @@ slapi_int_func_internal_pb( Slapi_PBlock *pb, slap_operation_t which )
        }
 
        pb->pb_op->o_bd = frontendDB;
-       func = &frontendDB->be_bind;
-
-       return func[which]( pb->pb_op, pb->pb_rs );
+       return (&frontendDB->be_bind)[which]( pb->pb_op, pb->pb_rs );
 }
 
 int
@@ -953,4 +950,3 @@ slapi_delete_internal(
 }
 
 #endif /* LDAP_SLAPI */
-