mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-21 03:10:25 +08:00
Split Operation into Opheader and op
This commit is contained in:
parent
f3562cbcf0
commit
90cc409325
@ -2025,21 +2025,13 @@ aci_set_gather( SetCookie *cookie, struct berval *name, AttributeDescription *de
|
||||
|
||||
p.cookie = cookie;
|
||||
|
||||
op2.o_hdr = cp->op->o_hdr;
|
||||
op2.o_tag = LDAP_REQ_SEARCH;
|
||||
op2.o_protocol = LDAP_VERSION3;
|
||||
op2.o_ndn = op2.o_bd->be_rootndn;
|
||||
op2.o_callback = &cb;
|
||||
op2.o_time = slap_get_time();
|
||||
op2.o_do_not_cache = 1;
|
||||
op2.o_is_auth_check = 0;
|
||||
op2.o_threadctx = cp->op->o_threadctx;
|
||||
op2.o_tmpmemctx = cp->op->o_tmpmemctx;
|
||||
op2.o_tmpmfuncs = cp->op->o_tmpmfuncs;
|
||||
#ifdef LDAP_SLAPI
|
||||
op2.o_pb = cp->op->o_pb;
|
||||
#endif
|
||||
op2.o_conn = cp->op->o_conn;
|
||||
op2.o_connid = cp->op->o_connid;
|
||||
ber_dupbv_x( &op2.o_req_dn, &op2.o_req_ndn, cp->op->o_tmpmemctx );
|
||||
op2.ors_slimit = SLAP_NO_LIMIT;
|
||||
op2.ors_tlimit = SLAP_NO_LIMIT;
|
||||
|
@ -374,6 +374,7 @@ monitor_filter2ndn( struct berval *base, int scope, struct berval *filter,
|
||||
{
|
||||
Connection conn = { 0 };
|
||||
Operation op = { 0 };
|
||||
Opheader ohdr = { 0 };
|
||||
SlapReply rs = { 0 };
|
||||
slap_callback cb = { NULL, monitor_filter2ndn_cb, NULL, NULL };
|
||||
AttributeName anlist[ 2 ];
|
||||
@ -385,7 +386,7 @@ monitor_filter2ndn( struct berval *base, int scope, struct berval *filter,
|
||||
return -1;
|
||||
}
|
||||
|
||||
connection_fake_init( &conn, &op, &conn );
|
||||
connection_fake_init( &conn, &op, &ohdr, &conn );
|
||||
|
||||
op.o_tag = LDAP_REQ_SEARCH;
|
||||
|
||||
|
@ -1695,6 +1695,7 @@ void
|
||||
connection_fake_init(
|
||||
Connection *conn,
|
||||
Operation *op,
|
||||
Opheader *ohdr,
|
||||
void *ctx )
|
||||
{
|
||||
conn->c_connid = -1;
|
||||
@ -1705,6 +1706,7 @@ connection_fake_init(
|
||||
conn->c_peer_domain = slap_empty_bv;
|
||||
conn->c_peer_name = slap_empty_bv;
|
||||
|
||||
op->o_hdr = ohdr;
|
||||
/* set memory context */
|
||||
op->o_tmpmemctx = slap_sl_mem_create(SLAP_SLAB_SIZE, SLAP_SLAB_STACK, ctx);
|
||||
op->o_tmpmfuncs = &slap_sl_mfuncs;
|
||||
|
@ -541,7 +541,9 @@ void
|
||||
filter_free( Filter *f )
|
||||
{
|
||||
Operation op;
|
||||
Opheader ohdr;
|
||||
|
||||
op.o_hdr = &ohdr;
|
||||
op.o_tmpmemctx = slap_sl_context( f );
|
||||
op.o_tmpmfuncs = &slap_sl_mfuncs;
|
||||
filter_free_x( &op, f );
|
||||
@ -776,6 +778,9 @@ void
|
||||
filter2bv( Filter *f, struct berval *fstr )
|
||||
{
|
||||
Operation op;
|
||||
Opheader ohdr;
|
||||
|
||||
op.o_hdr = &ohdr;
|
||||
op.o_tmpmemctx = NULL;
|
||||
op.o_tmpmfuncs = &ch_mfuncs;
|
||||
|
||||
|
@ -53,7 +53,6 @@ void slap_op_destroy(void)
|
||||
while ( (o = LDAP_STAILQ_FIRST( &slap_free_ops )) != NULL) {
|
||||
LDAP_STAILQ_REMOVE_HEAD( &slap_free_ops, o_next );
|
||||
LDAP_STAILQ_NEXT(o, o_next) = NULL;
|
||||
ch_free( o->o_controls );
|
||||
ch_free( o );
|
||||
}
|
||||
ldap_pvt_thread_mutex_destroy( &slap_op_mutex );
|
||||
@ -63,7 +62,6 @@ void
|
||||
slap_op_free( Operation *op )
|
||||
{
|
||||
struct berval slap_empty_bv_dup;
|
||||
void **controls;
|
||||
|
||||
assert( LDAP_STAILQ_NEXT(op, o_next) == NULL );
|
||||
|
||||
@ -106,10 +104,9 @@ slap_op_free( Operation *op )
|
||||
#endif /* defined( LDAP_SLAPI ) */
|
||||
|
||||
|
||||
controls = op->o_controls;
|
||||
memset( controls, 0, sizeof(void *) * SLAP_MAX_CIDS );
|
||||
memset( op, 0, sizeof(Operation) );
|
||||
op->o_controls = controls;
|
||||
memset( op, 0, sizeof(Operation) + sizeof(Opheader) + SLAP_MAX_CIDS * sizeof(void *) );
|
||||
op->o_hdr = (Opheader *)(op+1);
|
||||
op->o_controls = (void **)(op->o_hdr+1);
|
||||
|
||||
#if 0
|
||||
slap_sync_cookie_free( &op->o_sync_state, 0 );
|
||||
@ -144,8 +141,10 @@ slap_op_alloc(
|
||||
ldap_pvt_thread_mutex_unlock( &slap_op_mutex );
|
||||
|
||||
if (!op) {
|
||||
op = (Operation *) ch_calloc( 1, sizeof(Operation) );
|
||||
op->o_controls = (void **) ch_calloc( SLAP_MAX_CIDS, sizeof( void *));
|
||||
op = (Operation *) ch_calloc( 1, sizeof(Operation)
|
||||
+ sizeof(Opheader) + SLAP_MAX_CIDS * sizeof(void *) );
|
||||
op->o_hdr = (Opheader *)(op + 1);
|
||||
op->o_controls = (void **)(op->o_hdr+1);
|
||||
}
|
||||
|
||||
op->o_ber = ber;
|
||||
|
@ -1411,6 +1411,7 @@ consistency_check(
|
||||
cache_manager *cm = on->on_bi.bi_private;
|
||||
query_manager *qm = cm->qm;
|
||||
Operation op = {0};
|
||||
Opheader ohdr = {0};
|
||||
Connection conn = {0};
|
||||
|
||||
SlapReply rs = {REP_RESULT};
|
||||
@ -1418,7 +1419,7 @@ consistency_check(
|
||||
int i, return_val, pause = 1;
|
||||
QueryTemplate* templ;
|
||||
|
||||
connection_fake_init( &conn, &op, ctx );
|
||||
connection_fake_init( &conn, &op, &ohdr, ctx );
|
||||
|
||||
op.o_bd = &cm->db;
|
||||
op.o_dn = cm->db.be_rootdn;
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
#define SLAPD_OVER_SYNCPROV SLAPD_MOD_DYNAMIC
|
||||
|
||||
#ifdef SLAPD_OVER_SYNCPROV
|
||||
|
||||
#include <ac/string.h>
|
||||
@ -394,8 +392,11 @@ syncprov_sendresp( Operation *op, opcookie *opc, syncops *so, Entry *e, int mode
|
||||
Entry e_uuid = {0};
|
||||
Attribute a_uuid = {0};
|
||||
Operation sop = *so->s_op;
|
||||
Opheader ohdr;
|
||||
syncrepl_state *srs = sop.o_controls[sync_cid];
|
||||
|
||||
ohdr = *sop.o_hdr;
|
||||
sop.o_hdr = &ohdr;
|
||||
sop.o_tmpmemctx = op->o_tmpmemctx;
|
||||
|
||||
ctrls[1] = NULL;
|
||||
@ -789,7 +790,7 @@ syncprov_op_search( Operation *op, SlapReply *rs )
|
||||
Filter *fand, *fava;
|
||||
syncops *sop = NULL;
|
||||
searchstate *ss;
|
||||
syncrepl_state *srs = op->o_controls[sync_cid];
|
||||
syncrepl_state *srs;
|
||||
|
||||
if ( !(op->o_sync_mode & SLAP_SYNC_REFRESH) ) return SLAP_CB_CONTINUE;
|
||||
|
||||
@ -798,6 +799,8 @@ syncprov_op_search( Operation *op, SlapReply *rs )
|
||||
return rs->sr_err;
|
||||
}
|
||||
|
||||
srs = op->o_controls[sync_cid];
|
||||
|
||||
/* If this is a persistent search, set it up right away */
|
||||
if ( op->o_sync_mode & SLAP_SYNC_PERSIST ) {
|
||||
syncops so;
|
||||
|
@ -202,7 +202,7 @@ int passwd_extop(
|
||||
rs->sr_err = LDAP_OTHER;
|
||||
|
||||
} else {
|
||||
op2 = *op;
|
||||
op2.o_hdr = op->o_hdr;
|
||||
op2.o_tag = LDAP_REQ_MODIFY;
|
||||
op2.o_callback = &cb2;
|
||||
op2.orm_modlist = qpw->rs_mods;
|
||||
|
@ -448,6 +448,7 @@ LDAP_SLAPD_F (void) connection2anonymous LDAP_P((Connection *));
|
||||
LDAP_SLAPD_F (void) connection_fake_init LDAP_P((
|
||||
Connection *conn,
|
||||
Operation *op,
|
||||
Opheader *ohdr,
|
||||
void *threadctx ));
|
||||
LDAP_SLAPD_F (void) connection_assign_nextid LDAP_P((Connection *));
|
||||
|
||||
|
@ -398,18 +398,13 @@ slap_auxprop_lookup(
|
||||
|
||||
if ( op.o_bd && op.o_bd->be_search ) {
|
||||
SlapReply rs = {REP_RESULT};
|
||||
op.o_hdr = conn->c_sasl_bindop->o_hdr;
|
||||
op.o_tag = LDAP_REQ_SEARCH;
|
||||
op.o_protocol = LDAP_VERSION3;
|
||||
op.o_ndn = conn->c_ndn;
|
||||
op.o_callback = &cb;
|
||||
op.o_time = slap_get_time();
|
||||
op.o_do_not_cache = 1;
|
||||
op.o_is_auth_check = 1;
|
||||
op.o_threadctx = conn->c_sasl_bindop->o_threadctx;
|
||||
op.o_tmpmemctx = conn->c_sasl_bindop->o_tmpmemctx;
|
||||
op.o_tmpmfuncs = conn->c_sasl_bindop->o_tmpmfuncs;
|
||||
op.o_conn = conn;
|
||||
op.o_connid = conn->c_connid;
|
||||
op.o_req_dn = op.o_req_ndn;
|
||||
op.ors_scope = LDAP_SCOPE_BASE;
|
||||
op.ors_deref = LDAP_DEREF_NEVER;
|
||||
@ -504,18 +499,13 @@ slap_auxprop_store(
|
||||
}
|
||||
|
||||
if ( rc == LDAP_SUCCESS ) {
|
||||
op.o_hdr = conn->c_sasl_bindop->o_hdr;
|
||||
op.o_tag = LDAP_REQ_MODIFY;
|
||||
op.o_protocol = LDAP_VERSION3;
|
||||
op.o_ndn = op.o_req_ndn;
|
||||
op.o_callback = &cb;
|
||||
op.o_time = slap_get_time();
|
||||
op.o_do_not_cache = 1;
|
||||
op.o_is_auth_check = 1;
|
||||
op.o_threadctx = conn->c_sasl_bindop->o_threadctx;
|
||||
op.o_tmpmemctx = conn->c_sasl_bindop->o_tmpmemctx;
|
||||
op.o_tmpmfuncs = conn->c_sasl_bindop->o_tmpmfuncs;
|
||||
op.o_conn = conn;
|
||||
op.o_connid = conn->c_connid;
|
||||
op.o_req_dn = op.o_req_ndn;
|
||||
op.orm_modlist = modlist;
|
||||
|
||||
|
@ -992,21 +992,13 @@ exact_match:
|
||||
goto CONCLUDED;
|
||||
}
|
||||
|
||||
op.o_hdr = opx->o_hdr;
|
||||
op.o_tag = LDAP_REQ_SEARCH;
|
||||
op.o_protocol = LDAP_VERSION3;
|
||||
op.o_ndn = *authc;
|
||||
op.o_callback = &cb;
|
||||
op.o_time = slap_get_time();
|
||||
op.o_do_not_cache = 1;
|
||||
op.o_is_auth_check = 1;
|
||||
op.o_threadctx = opx->o_threadctx;
|
||||
op.o_tmpmemctx = opx->o_tmpmemctx;
|
||||
op.o_tmpmfuncs = opx->o_tmpmfuncs;
|
||||
#ifdef LDAP_SLAPI
|
||||
op.o_pb = opx->o_pb;
|
||||
#endif
|
||||
op.o_conn = opx->o_conn;
|
||||
op.o_connid = opx->o_connid;
|
||||
/* use req_ndn as req_dn instead of non-pretty base of uri */
|
||||
if( !BER_BVISNULL( &base ) ) {
|
||||
ch_free( base.bv_val );
|
||||
@ -1163,21 +1155,13 @@ void slap_sasl2dn( Operation *opx,
|
||||
goto FINISHED;
|
||||
}
|
||||
|
||||
op.o_conn = opx->o_conn;
|
||||
op.o_connid = opx->o_connid;
|
||||
op.o_hdr = opx->o_hdr;
|
||||
op.o_tag = LDAP_REQ_SEARCH;
|
||||
op.o_protocol = LDAP_VERSION3;
|
||||
op.o_ndn = opx->o_conn->c_ndn;
|
||||
op.o_callback = &cb;
|
||||
op.o_time = slap_get_time();
|
||||
op.o_do_not_cache = 1;
|
||||
op.o_is_auth_check = 1;
|
||||
op.o_threadctx = opx->o_threadctx;
|
||||
op.o_tmpmemctx = opx->o_tmpmemctx;
|
||||
op.o_tmpmfuncs = opx->o_tmpmfuncs;
|
||||
#ifdef LDAP_SLAPI
|
||||
op.o_pb = opx->o_pb;
|
||||
#endif
|
||||
op.ors_deref = LDAP_DEREF_NEVER;
|
||||
op.ors_slimit = 1;
|
||||
op.ors_tlimit = SLAP_NO_LIMIT;
|
||||
|
@ -2139,18 +2139,57 @@ typedef struct syncrepl_state {
|
||||
/*
|
||||
* represents an operation pending from an ldap client
|
||||
*/
|
||||
typedef struct slap_op {
|
||||
unsigned long o_opid; /* id of this operation */
|
||||
unsigned long o_connid; /* id of conn initiating this op */
|
||||
char o_log_prefix[sizeof("conn=18446744073709551615 op=18446744073709551615")];
|
||||
struct slap_conn *o_conn; /* connection spawning this op */
|
||||
BackendDB *o_bd; /* backend DB processing this op */
|
||||
typedef struct slap_op_header {
|
||||
unsigned long oh_opid; /* id of this operation */
|
||||
unsigned long oh_connid; /* id of conn initiating this op */
|
||||
struct slap_conn *oh_conn; /* connection spawning this op */
|
||||
|
||||
ber_int_t oh_msgid; /* msgid of the request */
|
||||
ber_int_t oh_protocol; /* version of the LDAP protocol used by client */
|
||||
|
||||
ldap_pvt_thread_t oh_tid; /* thread handling this op */
|
||||
|
||||
void *oh_threadctx; /* thread pool thread context */
|
||||
void *oh_tmpmemctx; /* slab malloc context */
|
||||
BerMemoryFunctions *oh_tmpmfuncs;
|
||||
|
||||
char oh_log_prefix[sizeof("conn=18446744073709551615 op=18446744073709551615")];
|
||||
|
||||
#ifdef LDAP_SLAPI
|
||||
void *oh_pb; /* NS-SLAPI plugin */
|
||||
void *oh_extensions; /* NS-SLAPI plugin */
|
||||
#endif
|
||||
} Opheader;
|
||||
|
||||
typedef struct slap_op {
|
||||
Opheader *o_hdr;
|
||||
|
||||
#define o_opid o_hdr->oh_opid
|
||||
#define o_connid o_hdr->oh_connid
|
||||
#define o_conn o_hdr->oh_conn
|
||||
#define o_msgid o_hdr->oh_msgid
|
||||
#define o_protocol o_hdr->oh_protocol
|
||||
#define o_tid o_hdr->oh_tid
|
||||
#define o_threadctx o_hdr->oh_threadctx
|
||||
#define o_tmpmemctx o_hdr->oh_tmpmemctx
|
||||
#define o_tmpmfuncs o_hdr->oh_tmpmfuncs
|
||||
|
||||
#define o_tmpalloc o_tmpmfuncs->bmf_malloc
|
||||
#define o_tmpcalloc o_tmpmfuncs->bmf_calloc
|
||||
#define o_tmprealloc o_tmpmfuncs->bmf_realloc
|
||||
#define o_tmpfree o_tmpmfuncs->bmf_free
|
||||
|
||||
#define o_log_prefix o_hdr->oh_log_prefix
|
||||
|
||||
#ifdef LDAP_SLAPI
|
||||
#define o_pb o_hdr->oh_pb
|
||||
#define o_extensions o_hdr->oh_extensions
|
||||
#endif
|
||||
|
||||
ber_int_t o_msgid; /* msgid of the request */
|
||||
ber_int_t o_protocol; /* version of the LDAP protocol used by client */
|
||||
ber_tag_t o_tag; /* tag of the request */
|
||||
time_t o_time; /* time op was initiated */
|
||||
|
||||
BackendDB *o_bd; /* backend DB processing this op */
|
||||
struct berval o_req_dn; /* DN of target of request */
|
||||
struct berval o_req_ndn;
|
||||
|
||||
@ -2213,9 +2252,6 @@ typedef struct slap_op {
|
||||
#define ore_reqoid oq_extended.rs_reqoid
|
||||
#define ore_flags oq_extended.rs_flags
|
||||
#define ore_reqdata oq_extended.rs_reqdata
|
||||
|
||||
ldap_pvt_thread_t o_tid; /* thread handling this op */
|
||||
|
||||
volatile sig_atomic_t o_abandon; /* abandon flag */
|
||||
volatile sig_atomic_t o_cancel; /* cancel flag */
|
||||
#define SLAP_CANCEL_NONE 0x00
|
||||
@ -2337,26 +2373,13 @@ typedef struct slap_op {
|
||||
slap_callback *o_callback; /* callback pointers */
|
||||
LDAPControl **o_ctrls; /* controls */
|
||||
|
||||
void *o_threadctx; /* thread pool thread context */
|
||||
void *o_tmpmemctx; /* slab malloc context */
|
||||
BerMemoryFunctions *o_tmpmfuncs;
|
||||
#define o_tmpalloc o_tmpmfuncs->bmf_malloc
|
||||
#define o_tmpcalloc o_tmpmfuncs->bmf_calloc
|
||||
#define o_tmprealloc o_tmpmfuncs->bmf_realloc
|
||||
#define o_tmpfree o_tmpmfuncs->bmf_free
|
||||
void *o_private; /* anything the backend needs */
|
||||
|
||||
LDAP_STAILQ_ENTRY(slap_op) o_next; /* next operation in list */
|
||||
|
||||
|
||||
int o_nocaching;
|
||||
int o_delete_glue_parent;
|
||||
|
||||
#ifdef LDAP_SLAPI
|
||||
void *o_pb; /* NS-SLAPI plugin */
|
||||
void *o_extensions; /* NS-SLAPI plugin */
|
||||
#endif
|
||||
|
||||
} Operation;
|
||||
|
||||
#define send_ldap_error( op, rs, err, text ) do { \
|
||||
|
@ -39,8 +39,9 @@ slapacl( int argc, char **argv )
|
||||
{
|
||||
int rc = EXIT_SUCCESS;
|
||||
const char *progname = "slapacl";
|
||||
Connection conn;
|
||||
Operation op;
|
||||
Connection conn = {0};
|
||||
Operation op = {0};
|
||||
Opheader ohdr = {0};
|
||||
Entry e = { 0 };
|
||||
char *attr = NULL;
|
||||
|
||||
@ -49,10 +50,7 @@ slapacl( int argc, char **argv )
|
||||
argv = &argv[ optind ];
|
||||
argc -= optind;
|
||||
|
||||
memset( &conn, 0, sizeof( Connection ) );
|
||||
memset( &op, 0, sizeof( Operation ) );
|
||||
|
||||
connection_fake_init( &conn, &op, &conn );
|
||||
connection_fake_init( &conn, &op, &ohdr, &conn );
|
||||
|
||||
if ( !BER_BVISNULL( &authcID ) ) {
|
||||
rc = slap_sasl_getdn( &conn, &op, &authcID, NULL,
|
||||
|
@ -79,18 +79,16 @@ slapauth( int argc, char **argv )
|
||||
{
|
||||
int rc = EXIT_SUCCESS;
|
||||
const char *progname = "slapauth";
|
||||
Connection conn;
|
||||
Operation op;
|
||||
Connection conn = {0};
|
||||
Operation op = {0};
|
||||
Opheader ohdr = {0};
|
||||
|
||||
slap_tool_init( progname, SLAPAUTH, argc, argv );
|
||||
|
||||
argv = &argv[ optind ];
|
||||
argc -= optind;
|
||||
|
||||
memset( &conn, 0, sizeof( Connection ) );
|
||||
memset( &op, 0, sizeof( Operation ) );
|
||||
|
||||
connection_fake_init( &conn, &op, &conn );
|
||||
connection_fake_init( &conn, &op, &ohdr, &conn );
|
||||
|
||||
if ( !BER_BVISNULL( &authzID ) ) {
|
||||
struct berval authzdn;
|
||||
|
@ -890,6 +890,7 @@ do_syncrepl(
|
||||
syncinfo_t *si = ( syncinfo_t * ) rtask->arg;
|
||||
Connection conn = {0};
|
||||
Operation op = {0};
|
||||
Opheader ohdr = {0};
|
||||
int rc = LDAP_SUCCESS;
|
||||
int first = 0;
|
||||
int dostop = 0;
|
||||
@ -918,7 +919,7 @@ do_syncrepl(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
connection_fake_init( &conn, &op, ctx );
|
||||
connection_fake_init( &conn, &op, &ohdr, ctx );
|
||||
|
||||
/* use global malloc for now */
|
||||
op.o_tmpmemctx = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user