mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-21 03:10:25 +08:00
Eliminate unnecessary Op copies
This commit is contained in:
parent
0e3db5ac3e
commit
d3531c6d79
@ -282,7 +282,11 @@ static int translucent_modrdn(Operation *op, SlapReply *rs) {
|
|||||||
op->o_bd->bd_info = (BackendInfo *) on;
|
op->o_bd->bd_info = (BackendInfo *) on;
|
||||||
return(rs->sr_err);
|
return(rs->sr_err);
|
||||||
}
|
}
|
||||||
if(!ov->no_glue) glue_parent(op);
|
if(!ov->no_glue) {
|
||||||
|
op->o_tag = LDAP_REQ_ADD;
|
||||||
|
glue_parent(op);
|
||||||
|
op->o_tag = LDAP_REQ_MODRDN;
|
||||||
|
}
|
||||||
return(SLAP_CB_CONTINUE);
|
return(SLAP_CB_CONTINUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,13 +331,13 @@ translucent_tag_cb( Operation *op, SlapReply *rs )
|
|||||||
|
|
||||||
static int translucent_modify(Operation *op, SlapReply *rs) {
|
static int translucent_modify(Operation *op, SlapReply *rs) {
|
||||||
SlapReply nrs = { REP_RESULT };
|
SlapReply nrs = { REP_RESULT };
|
||||||
Operation nop = *op;
|
|
||||||
|
|
||||||
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
|
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
|
||||||
translucent_info *ov = on->on_bi.bi_private;
|
translucent_info *ov = on->on_bi.bi_private;
|
||||||
Entry *e = NULL, *re = NULL;
|
Entry *e = NULL, *re = NULL;
|
||||||
Attribute *a, *ax;
|
Attribute *a, *ax;
|
||||||
Modifications *m, **mm;
|
Modifications *m, **mm;
|
||||||
|
BackendDB *db;
|
||||||
int del, rc, erc = 0;
|
int del, rc, erc = 0;
|
||||||
slap_callback cb = { 0 };
|
slap_callback cb = { 0 };
|
||||||
|
|
||||||
@ -352,14 +356,15 @@ static int translucent_modify(Operation *op, SlapReply *rs) {
|
|||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
|
|
||||||
nop.o_bd = &ov->db;
|
db = op->o_bd;
|
||||||
rc = ov->db.bd_info->bi_entry_get_rw(&nop, &nop.o_req_ndn, NULL, NULL, 0, &re);
|
op->o_bd = &ov->db;
|
||||||
|
rc = ov->db.bd_info->bi_entry_get_rw(op, &op->o_req_ndn, NULL, NULL, 0, &re);
|
||||||
if(rc != LDAP_SUCCESS || re == NULL ) {
|
if(rc != LDAP_SUCCESS || re == NULL ) {
|
||||||
send_ldap_error((&nop), rs, LDAP_NO_SUCH_OBJECT,
|
send_ldap_error((op), rs, LDAP_NO_SUCH_OBJECT,
|
||||||
"attempt to modify nonexistent local record");
|
"attempt to modify nonexistent local record");
|
||||||
return(rs->sr_err);
|
return(rs->sr_err);
|
||||||
}
|
}
|
||||||
nop = *op;
|
op->o_bd = db;
|
||||||
/*
|
/*
|
||||||
** fetch entry from local backend;
|
** fetch entry from local backend;
|
||||||
** if it exists:
|
** if it exists:
|
||||||
@ -413,9 +418,11 @@ static int translucent_modify(Operation *op, SlapReply *rs) {
|
|||||||
erc = SLAP_CB_CONTINUE;
|
erc = SLAP_CB_CONTINUE;
|
||||||
release:
|
release:
|
||||||
if(re) {
|
if(re) {
|
||||||
if(ov->db.bd_info->bi_entry_release_rw)
|
if(ov->db.bd_info->bi_entry_release_rw) {
|
||||||
ov->db.bd_info->bi_entry_release_rw(&nop, re, 0);
|
op->o_bd = &ov->db;
|
||||||
else
|
ov->db.bd_info->bi_entry_release_rw(op, re, 0);
|
||||||
|
op->o_bd = db;
|
||||||
|
} else
|
||||||
entry_free(re);
|
entry_free(re);
|
||||||
}
|
}
|
||||||
op->o_bd->bd_info = (BackendInfo *) on->on_info;
|
op->o_bd->bd_info = (BackendInfo *) on->on_info;
|
||||||
@ -432,9 +439,11 @@ release:
|
|||||||
|
|
||||||
/* don't leak remote entry copy */
|
/* don't leak remote entry copy */
|
||||||
if(re) {
|
if(re) {
|
||||||
if(ov->db.bd_info->bi_entry_release_rw)
|
if(ov->db.bd_info->bi_entry_release_rw) {
|
||||||
ov->db.bd_info->bi_entry_release_rw(&nop, re, 0);
|
op->o_bd = &ov->db;
|
||||||
else
|
ov->db.bd_info->bi_entry_release_rw(op, re, 0);
|
||||||
|
op->o_bd = db;
|
||||||
|
} else
|
||||||
entry_free(re);
|
entry_free(re);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -495,28 +504,28 @@ release:
|
|||||||
ber_dupbv( &e->e_nname, &op->o_req_ndn );
|
ber_dupbv( &e->e_nname, &op->o_req_ndn );
|
||||||
e->e_attrs = a;
|
e->e_attrs = a;
|
||||||
|
|
||||||
nop.o_tag = LDAP_REQ_ADD;
|
op->o_tag = LDAP_REQ_ADD;
|
||||||
nop.oq_add.rs_e = e;
|
|
||||||
|
|
||||||
glue_parent(&nop);
|
|
||||||
|
|
||||||
cb.sc_response = translucent_tag_cb;
|
cb.sc_response = translucent_tag_cb;
|
||||||
cb.sc_private = op->orm_modlist;
|
cb.sc_private = op->orm_modlist;
|
||||||
cb.sc_next = nop.o_callback;
|
op->oq_add.rs_e = e;
|
||||||
nop.o_callback = &cb;
|
|
||||||
rc = on->on_info->oi_orig->bi_op_add(&nop, &nrs);
|
glue_parent(op);
|
||||||
if ( nop.ora_e == e )
|
|
||||||
|
cb.sc_next = op->o_callback;
|
||||||
|
op->o_callback = &cb;
|
||||||
|
rc = on->on_info->oi_orig->bi_op_add(op, &nrs);
|
||||||
|
if ( op->ora_e == e )
|
||||||
entry_free( e );
|
entry_free( e );
|
||||||
|
|
||||||
return(rc);
|
return(rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int translucent_compare(Operation *op, SlapReply *rs) {
|
static int translucent_compare(Operation *op, SlapReply *rs) {
|
||||||
Operation nop = *op;
|
|
||||||
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
|
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
|
||||||
translucent_info *ov = on->on_bi.bi_private;
|
translucent_info *ov = on->on_bi.bi_private;
|
||||||
AttributeAssertion *ava = op->orc_ava;
|
AttributeAssertion *ava = op->orc_ava;
|
||||||
Entry *e;
|
Entry *e;
|
||||||
|
BackendDB *db;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
Debug(LDAP_DEBUG_TRACE, "==> translucent_compare: <%s> %s:%s\n",
|
Debug(LDAP_DEBUG_TRACE, "==> translucent_compare: <%s> %s:%s\n",
|
||||||
@ -527,14 +536,11 @@ static int translucent_compare(Operation *op, SlapReply *rs) {
|
|||||||
** CONTINUE and let it do the compare;
|
** CONTINUE and let it do the compare;
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
op->o_bd->bd_info = (BackendInfo *) on->on_info;
|
rc = overlay_entry_get_ov(op, &op->o_req_ndn, NULL, ava->aa_desc, 0, &e, on);
|
||||||
rc = be_entry_get_rw(op, &op->o_req_ndn, NULL, ava->aa_desc, 0, &e);
|
|
||||||
if(e && rc == LDAP_SUCCESS) {
|
if(e && rc == LDAP_SUCCESS) {
|
||||||
be_entry_release_r(op, e);
|
overlay_entry_release_ov(op, e, 0, on);
|
||||||
op->o_bd->bd_info = (BackendInfo *) on;
|
|
||||||
return(SLAP_CB_CONTINUE);
|
return(SLAP_CB_CONTINUE);
|
||||||
}
|
}
|
||||||
op->o_bd->bd_info = (BackendInfo *) on;
|
|
||||||
|
|
||||||
if(ov->defer_db_open) {
|
if(ov->defer_db_open) {
|
||||||
send_ldap_error(op, rs, LDAP_UNAVAILABLE,
|
send_ldap_error(op, rs, LDAP_UNAVAILABLE,
|
||||||
@ -546,9 +552,11 @@ static int translucent_compare(Operation *op, SlapReply *rs) {
|
|||||||
** return the result;
|
** return the result;
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
nop.o_bd = &ov->db;
|
db = op->o_bd;
|
||||||
nop.o_callback = NULL;
|
op->o_bd = &ov->db;
|
||||||
rc = ov->db.bd_info->bi_op_compare(&nop, rs);
|
op->o_callback = NULL;
|
||||||
|
rc = ov->db.bd_info->bi_op_compare(op, rs);
|
||||||
|
op->o_bd = db;
|
||||||
|
|
||||||
return(rc);
|
return(rc);
|
||||||
}
|
}
|
||||||
@ -672,8 +680,9 @@ static int translucent_search(Operation *op, SlapReply *rs) {
|
|||||||
|
|
||||||
static int translucent_bind(Operation *op, SlapReply *rs) {
|
static int translucent_bind(Operation *op, SlapReply *rs) {
|
||||||
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
|
slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
|
||||||
Operation nop = *op;
|
|
||||||
translucent_info *ov = on->on_bi.bi_private;
|
translucent_info *ov = on->on_bi.bi_private;
|
||||||
|
BackendDB *db;
|
||||||
|
int rc;
|
||||||
|
|
||||||
Debug(LDAP_DEBUG_TRACE, "translucent_bind: <%s> method %d\n",
|
Debug(LDAP_DEBUG_TRACE, "translucent_bind: <%s> method %d\n",
|
||||||
op->o_req_dn.bv_val, op->orb_method, 0);
|
op->o_req_dn.bv_val, op->orb_method, 0);
|
||||||
@ -683,8 +692,11 @@ static int translucent_bind(Operation *op, SlapReply *rs) {
|
|||||||
"remote DB not available");
|
"remote DB not available");
|
||||||
return(rs->sr_err);
|
return(rs->sr_err);
|
||||||
}
|
}
|
||||||
nop.o_bd = &ov->db;
|
db = op->o_bd;
|
||||||
return (ov->db.bd_info->bi_op_bind(&nop, rs));
|
op->o_bd = &ov->db;
|
||||||
|
rc = ov->db.bd_info->bi_op_bind(op, rs);
|
||||||
|
op->o_bd = db;
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user