size_t textlen = sizeof( textbuf );
int rc = 0;
int freevals = 1;
+ OpExtraDB oex;
Debug( LDAP_DEBUG_TRACE, "%s do_add\n",
op->o_log_prefix, 0, 0 );
freevals = 0;
+ oex.oe.oe_key = (void *)do_add;
+ oex.oe_db = NULL;
+ LDAP_SLIST_INSERT_HEAD(&op->o_extra, &oex.oe, oe_next);
+
op->o_bd = frontendDB;
rc = frontendDB->be_add( op, rs );
+ LDAP_SLIST_REMOVE(&op->o_extra, &oex.oe, OpExtra, oe_next);
#ifdef LDAP_X_TXN
if ( rc == LDAP_X_TXN_SPECIFY_OKAY ) {
} else
#endif
if ( rc == 0 ) {
- if ( op->ora_e != NULL && op->o_private != NULL ) {
+ if ( op->ora_e != NULL && oex.oe_db != NULL ) {
BackendDB *bd = op->o_bd;
- op->o_bd = (BackendDB *)op->o_private;
- op->o_private = NULL;
+ op->o_bd = oex.oe_db;
be_entry_release_w( op, op->ora_e );
op->ora_e = NULL;
op->o_bd = bd;
- op->o_private = NULL;
}
}
rc = op->o_bd->be_add( op, rs );
if ( rc == LDAP_SUCCESS ) {
+ OpExtra *oex;
/* NOTE: be_entry_release_w() is
* called by do_add(), so that global
* overlays on the way back can
* at least read the entry */
- op->o_private = op->o_bd;
+ LDAP_SLIST_FOREACH(oex, &op->o_extra, oe_next) {
+ if ( oex->oe_key == (void *)do_add ) {
+ ((OpExtraDB *)oex)->oe_db = op->o_bd;
+ break;
+ }
+ }
}
} else {
return LDAP_UNWILLING_TO_PERFORM;
}
-typedef struct fe_extra {
- OpExtra fe_oe;
- BackendDB *fe_be;
-} fe_extra;
-
int
fe_acl_group(
Operation *op,
int rc;
GroupAssertion *g;
Backend *be = op->o_bd;
- fe_extra *fex;
+ OpExtra *oex;
- for ( fex = (fe_extra *)op->o_extra; fex; fex = (fe_extra *)fex->fe_oe.oe_next ) {
- if ( fex->fe_oe.oe_key == (void *)backend_group )
+ LDAP_SLIST_FOREACH(oex, &op->o_extra, oe_next) {
+ if ( oex->oe_key == (void *)backend_group )
break;
}
- if ( fex && fex->fe_be )
- op->o_bd = fex->fe_be;
+ if ( oex && ((OpExtraDB *)oex)->oe_db )
+ op->o_bd = ((OpExtraDB *)oex)->oe_db;
else
op->o_bd = select_backend( gr_ndn, 0 );
{
int rc;
BackendDB *be_orig;
- fe_extra fex;
+ OpExtraDB oex;
if ( op->o_abandon ) {
return SLAPD_ABANDON;
}
if ( op->o_bd && SLAP_ISOVERLAY( op->o_bd ))
- fex.fe_be = op->o_bd->bd_orig;
+ oex.oe_db = op->o_bd->bd_orig;
else
- fex.fe_be = op->o_bd;
- fex.fe_oe.oe_key = (void *)backend_group;
- fex.fe_oe.oe_next = op->o_extra;
- op->o_extra = (OpExtra *)&fex;
+ oex.oe_db = op->o_bd;
+ oex.oe.oe_key = (void *)backend_group;
+ LDAP_SLIST_INSERT_HEAD(&op->o_extra, &oex.oe, oe_next);
be_orig = op->o_bd;
op->o_bd = frontendDB;
rc = frontendDB->be_group( op, target, gr_ndn,
op_ndn, group_oc, group_at );
op->o_bd = be_orig;
- slap_op_popextra( op, (OpExtra *)&fex );
+ LDAP_SLIST_REMOVE(&op->o_extra, &oex.oe, OpExtra, oe_next);
return rc;
}
int freeattr = 0, i, j, rc = LDAP_SUCCESS;
AccessControlState acl_state = ACL_STATE_INIT;
Backend *be = op->o_bd;
- fe_extra *fex;
+ OpExtra *oex;
- for ( fex = (fe_extra *)op->o_extra; fex; fex = (fe_extra *)fex->fe_oe.oe_next ) {
- if ( fex->fe_oe.oe_key == (void *)backend_attribute )
+ LDAP_SLIST_FOREACH(oex, &op->o_extra, oe_next) {
+ if ( oex->oe_key == (void *)backend_attribute )
break;
}
- if ( fex && fex->fe_be )
- op->o_bd = fex->fe_be;
+ if ( oex && ((OpExtraDB *)oex)->oe_db )
+ op->o_bd = ((OpExtraDB *)oex)->oe_db;
else
op->o_bd = select_backend( edn, 0 );
{
int rc;
BackendDB *be_orig;
- fe_extra fex;
+ OpExtraDB oex;
if ( op->o_bd && SLAP_ISOVERLAY( op->o_bd ))
- fex.fe_be = op->o_bd->bd_orig;
+ oex.oe_db = op->o_bd->bd_orig;
else
- fex.fe_be = op->o_bd;
- fex.fe_oe.oe_key = (void *)backend_attribute;
- fex.fe_oe.oe_next = op->o_extra;
- op->o_extra = (OpExtra *)&fex;
+ oex.oe_db = op->o_bd;
+ oex.oe.oe_key = (void *)backend_attribute;
+ LDAP_SLIST_INSERT_HEAD(&op->o_extra, &oex.oe, oe_next);
be_orig = op->o_bd;
op->o_bd = frontendDB;
rc = frontendDB->be_attribute( op, target, edn,
entry_at, vals, access );
op->o_bd = be_orig;
- slap_op_popextra( op, (OpExtra *)&fex );
+ LDAP_SLIST_REMOVE(&op->o_extra, &oex.oe, OpExtra, oe_next);
return rc;
}
Attribute **ap;
int rc = LDAP_SUCCESS;
BackendDB *be_orig = op->o_bd;
- fe_extra *fex;
+ OpExtra *oex;
- for ( fex = (fe_extra *)op->o_extra; fex; fex = (fe_extra *)fex->fe_oe.oe_next ) {
- if ( fex->fe_oe.oe_key == (void *)backend_operational )
+ LDAP_SLIST_FOREACH(oex, &op->o_extra, oe_next) {
+ if ( oex->oe_key == (void *)backend_operational )
break;
}
}
/* Let the overlays have a chance at this */
- if ( fex && fex->fe_be ) {
- op->o_bd = fex->fe_be;
+ if ( oex && ((OpExtraDB *)oex)->oe_db ) {
+ op->o_bd = ((OpExtraDB *)oex)->oe_db;
} else {
op->o_bd = select_backend( &op->o_req_ndn, 0 );
}
{
int rc;
BackendDB *be_orig;
- fe_extra fex;
+ OpExtraDB oex;
if ( op->o_bd && SLAP_ISOVERLAY( op->o_bd ))
- fex.fe_be = op->o_bd->bd_orig;
+ oex.oe_db = op->o_bd->bd_orig;
else
- fex.fe_be = op->o_bd;
- fex.fe_oe.oe_key = (void *)backend_operational;
- fex.fe_oe.oe_next = op->o_extra;
- op->o_extra = (OpExtra *)&fex;
+ oex.oe_db = op->o_bd;
+ oex.oe.oe_key = (void *)backend_operational;
+ LDAP_SLIST_INSERT_HEAD(&op->o_extra, &oex.oe, oe_next);
/* Moved this into the frontend so global overlays are called */
op->o_bd = frontendDB;
rc = frontendDB->be_operational( op, rs );
op->o_bd = be_orig;
- slap_op_popextra( op, (OpExtra *)&fex );
+ LDAP_SLIST_REMOVE(&op->o_extra, &oex.oe, OpExtra, oe_next);
return rc;
}
return( op );
}
-void
-slap_op_popextra( Operation *op, OpExtra *oe )
-{
- OpExtra **prev;
-
- for ( prev = &op->o_extra; *prev; prev = &(*prev)->oe_next ) {
- if ( *prev == oe ) {
- *prev = oe->oe_next;
- break;
- }
- }
-}
-
slap_op_t
slap_req2op( ber_tag_t tag )
{
syncprov_qplay( Operation *op, struct re_s *rtask )
{
syncops *so = rtask->arg;
- slap_overinst *on = so->s_op->o_private;
+ slap_overinst *on = LDAP_SLIST_FIRST(&so->s_op->o_extra)->oe_key;
syncres *sr;
Entry *e;
opcookie opc;
be = *so->s_op->o_bd;
be.be_flags |= SLAP_DBFLAG_OVERLAY;
op->o_bd = &be;
- op->o_private = NULL;
+ LDAP_SLIST_FIRST(&op->o_extra) = NULL;
op->o_callback = NULL;
rc = syncprov_qplay( op, rtask );
typedef struct SyncOperationBuffer {
Operation sob_op;
Opheader sob_hdr;
+ OpExtra sob_oe;
AttributeName sob_extra; /* not always present */
/* Further data allocated here */
} SyncOperationBuffer;
sopbuf2 = ch_calloc( 1, size );
op2 = &sopbuf2->sob_op;
op2->o_hdr = &sopbuf2->sob_hdr;
+ LDAP_SLIST_FIRST(&op2->o_extra) = &sopbuf2->sob_oe;
/* Copy the fields we care about explicitly, leave the rest alone */
*op2->o_hdr = *op->o_hdr;
op2->o_time = op->o_time;
op2->o_bd = on->on_info->oi_origdb;
op2->o_request = op->o_request;
- op2->o_private = on;
+ LDAP_SLIST_FIRST(&op2->o_extra)->oe_key = on;
+ LDAP_SLIST_NEXT(LDAP_SLIST_FIRST(&op2->o_extra), oe_next) = NULL;
ptr = (char *) sopbuf2 + offsetof( SyncOperationBuffer, sob_extra );
if ( i ) {
ber_tag_t tag, ber_int_t id, void *ctx ));
LDAP_SLAPD_F (slap_op_t) slap_req2op LDAP_P(( ber_tag_t tag ));
-LDAP_SLAPD_F (void) slap_op_popextra LDAP_P(( Operation *op, OpExtra *oe ));
/*
* operational.c
req_pwdexop_s oq_pwdexop;
} OpRequest;
+/* This is only a header. Actual users should define their own
+ * structs with the oe_next / oe_key fields at the top and
+ * whatever else they need following.
+ */
typedef struct OpExtra {
- struct OpExtra *oe_next;
+ LDAP_SLIST_ENTRY(OpExtra) oe_next;
void *oe_key;
} OpExtra;
+typedef struct OpExtraDB {
+ OpExtra oe;
+ BackendDB *oe_db;
+} OpExtraDB;
+
struct Operation {
Opheader *o_hdr;
/* DEPRECATE o_private - use o_extra instead */
void *o_private; /* anything the backend needs */
- OpExtra *o_extra; /* anything the backend needs */
+ LDAP_SLIST_HEAD(o_e, OpExtra) o_extra; /* anything the backend needs */
LDAP_STAILQ_ENTRY(Operation) o_next; /* next operation in list */
};
{
SlapReply *rs;
Slapi_Entry *entry_orig = NULL;
+ OpExtraDB oex;
+ int rc;
if ( pb == NULL ) {
return -1;
goto cleanup;
}
- if ( slapi_int_func_internal_pb( pb, op_add ) == 0 ) {
- if ( pb->pb_op->ora_e != NULL && pb->pb_op->o_private != NULL ) {
+ oex.oe.oe_key = (void *)do_add;
+ oex.oe_db = NULL;
+ LDAP_SLIST_INSERT_HEAD(&pb->pb_op->o_extra, &oex.oe, oe_next);
+ rc = slapi_int_func_internal_pb( pb, op_add );
+ LDAP_SLIST_REMOVE(&pb->pb_op->o_extra, &oex.oe, OpExtra, oe_next);
+
+ if ( !rc ) {
+ if ( pb->pb_op->ora_e != NULL && oex.oe_db != NULL ) {
BackendDB *bd = pb->pb_op->o_bd;
- pb->pb_op->o_bd = (BackendDB *)pb->pb_op->o_private;
- pb->pb_op->o_private = NULL;
+ pb->pb_op->o_bd = oex.oe_db;
be_entry_release_w( pb->pb_op, pb->pb_op->ora_e );
pb->pb_op->ora_e = NULL;
pb->pb_op->o_bd = bd;
- pb->pb_op->o_private = NULL;
}
}