mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-25 00:59:45 -05:00
Better fix for ITS#2512. Use callback to invoke replog before sending
result to client.
This commit is contained in:
parent
d8f9f4ee22
commit
e933f076cc
8 changed files with 55 additions and 52 deletions
|
|
@ -261,6 +261,7 @@ do_add( Operation *op, SlapReply *rs )
|
|||
int update = op->o_bd->be_update_ndn.bv_len;
|
||||
char textbuf[SLAP_TEXT_BUFLEN];
|
||||
size_t textlen = sizeof textbuf;
|
||||
slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
|
||||
|
||||
rs->sr_err = slap_mods_check( modlist, update, &rs->sr_text,
|
||||
textbuf, textlen, NULL );
|
||||
|
|
@ -308,14 +309,14 @@ do_add( Operation *op, SlapReply *rs )
|
|||
#endif /* LDAP_SLAPI */
|
||||
|
||||
op->ora_e = e;
|
||||
repstamp( op );
|
||||
if ( (op->o_bd->be_add)( op, rs ) == 0 ) {
|
||||
#ifdef SLAPD_MULTIMASTER
|
||||
if ( !repl_user )
|
||||
if ( !repl_user )
|
||||
#endif
|
||||
{
|
||||
replog( op );
|
||||
}
|
||||
{
|
||||
cb.sc_next = op->o_callback;
|
||||
op->o_callback = &cb;
|
||||
}
|
||||
if ( (op->o_bd->be_add)( op, rs ) == 0 ) {
|
||||
be_entry_release_w( op, e );
|
||||
e = NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -206,6 +206,7 @@ do_delete(
|
|||
if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo ))
|
||||
#endif
|
||||
{
|
||||
slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
|
||||
|
||||
if ( !repl_user ) {
|
||||
struct berval csn = { 0 , NULL };
|
||||
|
|
@ -213,15 +214,14 @@ do_delete(
|
|||
slap_get_csn( op, csnbuf, sizeof(csnbuf), &csn, 1 );
|
||||
}
|
||||
|
||||
repstamp( op );
|
||||
if ( (op->o_bd->be_delete)( op, rs ) == 0 ) {
|
||||
#ifdef SLAPD_MULTIMASTER
|
||||
if ( !op->o_bd->be_update_ndn.bv_len || !repl_user )
|
||||
if ( !op->o_bd->be_update_ndn.bv_len || !repl_user )
|
||||
#endif
|
||||
{
|
||||
replog( op );
|
||||
}
|
||||
{
|
||||
cb.sc_next = op->o_callback;
|
||||
op->o_callback = &cb;
|
||||
}
|
||||
op->o_bd->be_delete( op, rs );
|
||||
#ifndef SLAPD_MULTIMASTER
|
||||
} else {
|
||||
BerVarray defref = NULL;
|
||||
|
|
|
|||
|
|
@ -472,6 +472,7 @@ do_modify(
|
|||
int update = op->o_bd->be_update_ndn.bv_len;
|
||||
char textbuf[SLAP_TEXT_BUFLEN];
|
||||
size_t textlen = sizeof textbuf;
|
||||
slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
|
||||
|
||||
rs->sr_err = slap_mods_check( modlist, update, &rs->sr_text,
|
||||
textbuf, textlen, NULL );
|
||||
|
|
@ -498,15 +499,15 @@ do_modify(
|
|||
}
|
||||
|
||||
op->orm_modlist = modlist;
|
||||
repstamp( op );
|
||||
if ( (op->o_bd->be_modify)( op, rs ) == 0
|
||||
#ifdef SLAPD_MULTIMASTER
|
||||
&& !repl_user
|
||||
if ( !repl_user )
|
||||
#endif
|
||||
) {
|
||||
{
|
||||
/* but we log only the ones not from a replicator user */
|
||||
replog( op );
|
||||
cb.sc_next = op->o_callback;
|
||||
op->o_callback = &cb;
|
||||
}
|
||||
op->o_bd->be_modify( op, rs );
|
||||
|
||||
#ifndef SLAPD_MULTIMASTER
|
||||
/* send a referral */
|
||||
|
|
|
|||
|
|
@ -362,15 +362,17 @@ do_modrdn(
|
|||
if ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo ))
|
||||
#endif
|
||||
{
|
||||
slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
|
||||
op->orr_deleteoldrdn = deloldrdn;
|
||||
repstamp( op );
|
||||
if ( (op->o_bd->be_modrdn)( op, rs ) == 0
|
||||
#ifdef SLAPD_MULTIMASTER
|
||||
&& ( !op->o_bd->be_update_ndn.bv_len || !repl_user )
|
||||
if ( !op->o_bd->be_update_ndn.bv_len || !repl_user )
|
||||
#endif
|
||||
) {
|
||||
replog( op );
|
||||
{
|
||||
cb.sc_next = op->o_callback;
|
||||
op->o_callback = &cb;
|
||||
}
|
||||
op->o_bd->be_modrdn( op, rs );
|
||||
|
||||
#ifndef SLAPD_MULTIMASTER
|
||||
} else {
|
||||
BerVarray defref = NULL;
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ int passwd_extop(
|
|||
Modifications ml, **modtail;
|
||||
Operation op2;
|
||||
slap_callback cb = { NULL, slap_null_cb, NULL, NULL };
|
||||
slap_callback cb2 = { &cb, slap_replog_cb, NULL, NULL };
|
||||
|
||||
assert( ber_bvcmp( &slap_EXOP_MODIFY_PASSWD, &op->ore_reqoid ) == 0 );
|
||||
|
||||
|
|
@ -156,7 +157,7 @@ int passwd_extop(
|
|||
|
||||
op2 = *op;
|
||||
op2.o_tag = LDAP_REQ_MODIFY;
|
||||
op2.o_callback = &cb;
|
||||
op2.o_callback = &cb2;
|
||||
op2.o_req_dn = dn;
|
||||
op2.o_req_ndn = ndn;
|
||||
op2.orm_modlist = &ml;
|
||||
|
|
@ -166,11 +167,9 @@ int passwd_extop(
|
|||
NULL, 0 );
|
||||
|
||||
if ( rs->sr_err == LDAP_SUCCESS ) {
|
||||
repstamp( &op2 );
|
||||
rs->sr_err = op2.o_bd->be_modify( &op2, rs );
|
||||
}
|
||||
if ( rs->sr_err == LDAP_SUCCESS ) {
|
||||
replog( &op2 );
|
||||
rs->sr_rspdata = rsp;
|
||||
} else if ( rsp ) {
|
||||
ber_bvfree( rsp );
|
||||
|
|
|
|||
|
|
@ -46,6 +46,14 @@ int slap_null_cb( Operation *op, SlapReply *rs )
|
|||
return 0;
|
||||
}
|
||||
|
||||
int slap_replog_cb( Operation *op, SlapReply *rs )
|
||||
{
|
||||
if ( rs->sr_err == LDAP_SUCCESS ) {
|
||||
replog( op );
|
||||
}
|
||||
return SLAP_CB_CONTINUE;
|
||||
}
|
||||
|
||||
static char *v2ref( BerVarray ref, const char *text )
|
||||
{
|
||||
size_t len = 0, i = 0;
|
||||
|
|
|
|||
|
|
@ -559,12 +559,9 @@ slapi_delete_internal(
|
|||
if ( op->o_bd->be_delete ) {
|
||||
int repl_user = be_isupdate( op->o_bd, &op->o_ndn );
|
||||
if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
|
||||
if ( log_change ) repstamp( op );
|
||||
if ( (*op->o_bd->be_delete)( op, &rs ) == 0 ) {
|
||||
if ( log_change ) {
|
||||
replog( op );
|
||||
}
|
||||
} else {
|
||||
slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
|
||||
if ( log_change ) op->o_callback = &cb;
|
||||
if ( (*op->o_bd->be_delete)( op, &rs ) ) {
|
||||
rs.sr_err = LDAP_OTHER;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -641,11 +638,9 @@ slapi_add_entry_internal_locked(
|
|||
if ( op->o_bd->be_add ) {
|
||||
int repl_user = be_isupdate( op->o_bd, &op->o_ndn );
|
||||
if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
|
||||
if ( log_changes ) repstamp( op );
|
||||
slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
|
||||
if ( log_changes ) op->o_callback = &cb;
|
||||
if ( (*op->o_bd->be_add)( op, &rs ) == 0 ) {
|
||||
if ( log_changes ) {
|
||||
replog( op );
|
||||
}
|
||||
be_entry_release_w( op, *e );
|
||||
*e = NULL;
|
||||
}
|
||||
|
|
@ -834,12 +829,9 @@ slapi_modrdn_internal(
|
|||
if ( op->o_bd->be_modrdn ) {
|
||||
int repl_user = be_isupdate( op->o_bd, &op->o_ndn );
|
||||
if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
|
||||
if ( log_change ) repstamp( op );
|
||||
if ( (*op->o_bd->be_modrdn)( op, &rs ) == 0 ) {
|
||||
if ( log_change ) {
|
||||
replog( op );
|
||||
}
|
||||
} else {
|
||||
slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
|
||||
if ( log_change ) op->o_callback = &cb;
|
||||
if ( (*op->o_bd->be_modrdn)( op, &rs ) ) {
|
||||
rs.sr_err = LDAP_OTHER;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1032,6 +1024,7 @@ slapi_modify_internal(
|
|||
const char *text = NULL;
|
||||
char textbuf[SLAP_TEXT_BUFLEN];
|
||||
size_t textlen = sizeof( textbuf );
|
||||
slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
|
||||
|
||||
rs.sr_err = slap_mods_check( modlist, update,
|
||||
&text, textbuf, textlen, NULL );
|
||||
|
|
@ -1047,12 +1040,8 @@ slapi_modify_internal(
|
|||
goto cleanup;
|
||||
}
|
||||
}
|
||||
if ( log_change ) repstamp( op );
|
||||
if ( (*op->o_bd->be_modify)( op, &rs ) == 0 ) {
|
||||
if ( log_change ) {
|
||||
replog( op );
|
||||
}
|
||||
} else {
|
||||
if ( log_change ) op->o_callback = &cb;
|
||||
if ( (*op->o_bd->be_modify)( op, &rs ) ) {
|
||||
rs.sr_err = LDAP_OTHER;
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -62,6 +62,14 @@ slap_null_cb(
|
|||
assert(0);
|
||||
}
|
||||
|
||||
int
|
||||
slap_replog_cb(
|
||||
Operation *op, SlapReply *rs
|
||||
)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
void
|
||||
slap_send_ldap_extended(
|
||||
Operation *op, SlapReply *rs
|
||||
|
|
@ -194,11 +202,6 @@ const char * connection_state2str( int state )
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void repstamp( Operation *op )
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
void replog( Operation *op )
|
||||
{
|
||||
assert(0);
|
||||
|
|
|
|||
Loading…
Reference in a new issue