move req2op selection into a helper

This commit is contained in:
Pierangelo Masarati 2006-09-04 07:17:34 +00:00
parent 8129f7e2f2
commit 0d2e2772d5
4 changed files with 36 additions and 51 deletions

View File

@ -1006,7 +1006,7 @@ connection_operation( void *ctx, void *arg_v )
Operation *op = arg_v;
SlapReply rs = {REP_RESULT};
ber_tag_t tag = op->o_tag;
int opidx = -1;
slap_op_t opidx = SLAP_OP_LAST;
Connection *conn = op->o_conn;
void *memctx = NULL;
void *memctx_null = NULL;
@ -1089,53 +1089,8 @@ connection_operation( void *ctx, void *arg_v )
}
}
switch ( tag ) {
case LDAP_REQ_BIND:
opidx = SLAP_OP_BIND;
break;
case LDAP_REQ_UNBIND:
opidx = SLAP_OP_UNBIND;
break;
case LDAP_REQ_ADD:
opidx = SLAP_OP_ADD;
break;
case LDAP_REQ_DELETE:
opidx = SLAP_OP_DELETE;
break;
case LDAP_REQ_MODRDN:
opidx = SLAP_OP_MODRDN;
break;
case LDAP_REQ_MODIFY:
opidx = SLAP_OP_MODIFY;
break;
case LDAP_REQ_COMPARE:
opidx = SLAP_OP_COMPARE;
break;
case LDAP_REQ_SEARCH:
opidx = SLAP_OP_SEARCH;
break;
case LDAP_REQ_ABANDON:
opidx = SLAP_OP_ABANDON;
break;
case LDAP_REQ_EXTENDED:
opidx = SLAP_OP_EXTENDED;
break;
default:
/* not reachable */
assert( 0 );
}
assert( opidx > -1 );
opidx = slap_req2op( tag );
assert( opidx != SLAP_OP_LAST );
INCR_OP_INITIATED( opidx );
rc = (*(opfun[opidx]))( op, &rs );
@ -1143,7 +1098,7 @@ operations_error:
if ( rc == SLAPD_DISCONNECT ) {
tag = LBER_ERROR;
} else if ( opidx > -1 ) {
} else if ( opidx != SLAP_OP_LAST ) {
/* increment completed operations count
* only if operation was initiated
* and rc != SLAPD_DISCONNECT */

View File

@ -165,3 +165,32 @@ slap_op_alloc(
return( op );
}
slap_op_t
slap_req2op( ber_tag_t tag )
{
switch ( tag ) {
case LDAP_REQ_BIND:
return SLAP_OP_BIND;
case LDAP_REQ_UNBIND:
return SLAP_OP_UNBIND;
case LDAP_REQ_ADD:
return SLAP_OP_ADD;
case LDAP_REQ_DELETE:
return SLAP_OP_DELETE;
case LDAP_REQ_MODRDN:
return SLAP_OP_MODRDN;
case LDAP_REQ_MODIFY:
return SLAP_OP_MODIFY;
case LDAP_REQ_COMPARE:
return SLAP_OP_COMPARE;
case LDAP_REQ_SEARCH:
return SLAP_OP_SEARCH;
case LDAP_REQ_ABANDON:
return SLAP_OP_ABANDON;
case LDAP_REQ_EXTENDED:
return SLAP_OP_EXTENDED;
}
return SLAP_OP_LAST;
}

View File

@ -1256,6 +1256,7 @@ LDAP_SLAPD_F (Operation *) slap_op_alloc LDAP_P((
LDAP_SLAPD_F (int) slap_op_add LDAP_P(( Operation **olist, Operation *op ));
LDAP_SLAPD_F (int) slap_op_remove LDAP_P(( Operation **olist, Operation *op ));
LDAP_SLAPD_F (Operation *) slap_op_pop LDAP_P(( Operation **olist ));
LDAP_SLAPD_F (slap_op_t) slap_req2op LDAP_P(( ber_tag_t tag ));
/*
* operational.c

View File

@ -2733,7 +2733,7 @@ struct slap_listener {
/*
* Operation indices
*/
enum {
typedef enum {
SLAP_OP_BIND = 0,
SLAP_OP_UNBIND,
SLAP_OP_ADD,
@ -2745,7 +2745,7 @@ enum {
SLAP_OP_ABANDON,
SLAP_OP_EXTENDED,
SLAP_OP_LAST
};
} slap_op_t;
typedef struct slap_counters_t {
ldap_pvt_thread_mutex_t sc_sent_mutex;