mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-06 10:46:21 +08:00
Rework pre/post read controls to handle retry conditions...
(and plug leaks)
This commit is contained in:
parent
e23b0f677f
commit
8bca3b42f9
@ -49,6 +49,7 @@ bdb_add(Operation *op, SlapReply *rs )
|
|||||||
Entry *ctxcsn_e;
|
Entry *ctxcsn_e;
|
||||||
int ctxcsn_added = 0;
|
int ctxcsn_added = 0;
|
||||||
|
|
||||||
|
LDAPControl **postread_ctrl = NULL;
|
||||||
LDAPControl *ctrls[SLAP_MAX_RESPONSE_CONTROLS];
|
LDAPControl *ctrls[SLAP_MAX_RESPONSE_CONTROLS];
|
||||||
int num_ctrls = 0;
|
int num_ctrls = 0;
|
||||||
|
|
||||||
@ -60,6 +61,8 @@ bdb_add(Operation *op, SlapReply *rs )
|
|||||||
op->oq_add.rs_e->e_name.bv_val, 0, 0);
|
op->oq_add.rs_e->e_name.bv_val, 0, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
ctrls[num_ctrls] = 0;
|
||||||
|
|
||||||
/* check entry's schema */
|
/* check entry's schema */
|
||||||
rs->sr_err = entry_schema_check( op->o_bd, op->oq_add.rs_e,
|
rs->sr_err = entry_schema_check( op->o_bd, op->oq_add.rs_e,
|
||||||
NULL, &rs->sr_text, textbuf, textlen );
|
NULL, &rs->sr_text, textbuf, textlen );
|
||||||
@ -447,8 +450,12 @@ retry: /* transaction retry */
|
|||||||
|
|
||||||
/* post-read */
|
/* post-read */
|
||||||
if( op->o_postread ) {
|
if( op->o_postread ) {
|
||||||
|
if( postread_ctrl == NULL ) {
|
||||||
|
postread_ctrl = &ctrls[num_ctrls++];
|
||||||
|
ctrls[num_ctrls] = NULL;
|
||||||
|
}
|
||||||
if ( slap_read_controls( op, rs, op->oq_add.rs_e,
|
if ( slap_read_controls( op, rs, op->oq_add.rs_e,
|
||||||
&slap_post_read_bv, &ctrls[num_ctrls] ) )
|
&slap_post_read_bv, postread_ctrl ) )
|
||||||
{
|
{
|
||||||
#ifdef NEW_LOGGING
|
#ifdef NEW_LOGGING
|
||||||
LDAP_LOG ( OPERATION, DETAIL1,
|
LDAP_LOG ( OPERATION, DETAIL1,
|
||||||
@ -459,9 +466,6 @@ retry: /* transaction retry */
|
|||||||
#endif
|
#endif
|
||||||
goto return_results;
|
goto return_results;
|
||||||
}
|
}
|
||||||
ctrls[++num_ctrls] = NULL;
|
|
||||||
op->o_postread = 0; /* prevent redo on retry */
|
|
||||||
/* FIXME: should read entry on the last retry */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( op->o_noop ) {
|
if ( op->o_noop ) {
|
||||||
@ -557,5 +561,9 @@ done:
|
|||||||
op->o_private = NULL;
|
op->o_private = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( postread_ctrl != NULL ) {
|
||||||
|
slap_sl_free( (*postread_ctrl)->ldctl_value.bv_val, &op->o_tmpmemctx );
|
||||||
|
slap_sl_free( *postread_ctrl, &op->o_tmpmemctx );
|
||||||
|
}
|
||||||
return rs->sr_err;
|
return rs->sr_err;
|
||||||
}
|
}
|
||||||
|
@ -48,14 +48,18 @@ bdb_delete( Operation *op, SlapReply *rs )
|
|||||||
Entry *ctxcsn_e;
|
Entry *ctxcsn_e;
|
||||||
int ctxcsn_added = 0;
|
int ctxcsn_added = 0;
|
||||||
|
|
||||||
|
LDAPControl **preread_ctrl = NULL;
|
||||||
LDAPControl *ctrls[SLAP_MAX_RESPONSE_CONTROLS];
|
LDAPControl *ctrls[SLAP_MAX_RESPONSE_CONTROLS];
|
||||||
int num_ctrls = 0;
|
int num_ctrls = 0;
|
||||||
|
|
||||||
int parent_is_glue = 0;
|
int parent_is_glue = 0;
|
||||||
int parent_is_leaf = 0;
|
int parent_is_leaf = 0;
|
||||||
|
|
||||||
|
ctrls[num_ctrls] = 0;
|
||||||
|
|
||||||
#ifdef NEW_LOGGING
|
#ifdef NEW_LOGGING
|
||||||
LDAP_LOG ( OPERATION, ARGS, "==> bdb_delete: %s\n", op->o_req_dn.bv_val, 0, 0 );
|
LDAP_LOG ( OPERATION, ARGS, "==> bdb_delete: %s\n",
|
||||||
|
op->o_req_dn.bv_val, 0, 0 );
|
||||||
#else
|
#else
|
||||||
Debug( LDAP_DEBUG_ARGS, "==> bdb_delete: %s\n",
|
Debug( LDAP_DEBUG_ARGS, "==> bdb_delete: %s\n",
|
||||||
op->o_req_dn.bv_val, 0, 0 );
|
op->o_req_dn.bv_val, 0, 0 );
|
||||||
@ -346,8 +350,12 @@ retry: /* transaction retry */
|
|||||||
|
|
||||||
/* pre-read */
|
/* pre-read */
|
||||||
if( op->o_preread ) {
|
if( op->o_preread ) {
|
||||||
|
if( preread_ctrl == NULL ) {
|
||||||
|
preread_ctrl = &ctrls[num_ctrls++];
|
||||||
|
ctrls[num_ctrls] = NULL;
|
||||||
|
}
|
||||||
if( slap_read_controls( op, rs, e,
|
if( slap_read_controls( op, rs, e,
|
||||||
&slap_pre_read_bv, &ctrls[num_ctrls] ) )
|
&slap_pre_read_bv, preread_ctrl ) )
|
||||||
{
|
{
|
||||||
#ifdef NEW_LOGGING
|
#ifdef NEW_LOGGING
|
||||||
LDAP_LOG ( OPERATION, DETAIL1,
|
LDAP_LOG ( OPERATION, DETAIL1,
|
||||||
@ -358,9 +366,6 @@ retry: /* transaction retry */
|
|||||||
#endif
|
#endif
|
||||||
goto return_results;
|
goto return_results;
|
||||||
}
|
}
|
||||||
ctrls[++num_ctrls] = NULL;
|
|
||||||
op->o_preread = 0; /* prevent redo on retry */
|
|
||||||
/* FIXME: should read entry on the last retry */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* nested transaction */
|
/* nested transaction */
|
||||||
@ -637,5 +642,9 @@ done:
|
|||||||
op->o_private = NULL;
|
op->o_private = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( preread_ctrl != NULL ) {
|
||||||
|
slap_sl_free( (*preread_ctrl)->ldctl_value.bv_val, &op->o_tmpmemctx );
|
||||||
|
slap_sl_free( *preread_ctrl, &op->o_tmpmemctx );
|
||||||
|
}
|
||||||
return rs->sr_err;
|
return rs->sr_err;
|
||||||
}
|
}
|
||||||
|
@ -353,6 +353,8 @@ bdb_modify( Operation *op, SlapReply *rs )
|
|||||||
|
|
||||||
int num_retries = 0;
|
int num_retries = 0;
|
||||||
|
|
||||||
|
LDAPControl **preread_ctrl = NULL;
|
||||||
|
LDAPControl **postread_ctrl = NULL;
|
||||||
LDAPControl *ctrls[SLAP_MAX_RESPONSE_CONTROLS];
|
LDAPControl *ctrls[SLAP_MAX_RESPONSE_CONTROLS];
|
||||||
int num_ctrls = 0;
|
int num_ctrls = 0;
|
||||||
|
|
||||||
@ -364,11 +366,15 @@ bdb_modify( Operation *op, SlapReply *rs )
|
|||||||
int ctxcsn_added = 0;
|
int ctxcsn_added = 0;
|
||||||
|
|
||||||
#ifdef NEW_LOGGING
|
#ifdef NEW_LOGGING
|
||||||
LDAP_LOG ( OPERATION, ENTRY, "bdb_modify: %s\n", op->o_req_dn.bv_val, 0, 0 );
|
LDAP_LOG ( OPERATION, ENTRY, "bdb_modify: %s\n",
|
||||||
|
op->o_req_dn.bv_val, 0, 0 );
|
||||||
#else
|
#else
|
||||||
Debug( LDAP_DEBUG_ARGS, "bdb_modify: %s\n", op->o_req_dn.bv_val, 0, 0 );
|
Debug( LDAP_DEBUG_ARGS, "bdb_modify: %s\n",
|
||||||
|
op->o_req_dn.bv_val, 0, 0 );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
ctrls[num_ctrls] = NULL;
|
||||||
|
|
||||||
if( 0 ) {
|
if( 0 ) {
|
||||||
retry: /* transaction retry */
|
retry: /* transaction retry */
|
||||||
if( e != NULL ) {
|
if( e != NULL ) {
|
||||||
@ -462,7 +468,9 @@ retry: /* transaction retry */
|
|||||||
e = ei->bei_e;
|
e = ei->bei_e;
|
||||||
/* acquire and lock entry */
|
/* acquire and lock entry */
|
||||||
/* FIXME: dn2entry() should return non-glue entry */
|
/* FIXME: dn2entry() should return non-glue entry */
|
||||||
if (( rs->sr_err == DB_NOTFOUND ) || ( !manageDSAit && e && is_entry_glue( e ))) {
|
if (( rs->sr_err == DB_NOTFOUND ) ||
|
||||||
|
( !manageDSAit && e && is_entry_glue( e )))
|
||||||
|
{
|
||||||
if ( e != NULL ) {
|
if ( e != NULL ) {
|
||||||
rs->sr_matched = ch_strdup( e->e_dn );
|
rs->sr_matched = ch_strdup( e->e_dn );
|
||||||
rs->sr_ref = is_entry_referral( e )
|
rs->sr_ref = is_entry_referral( e )
|
||||||
@ -505,7 +513,9 @@ retry: /* transaction retry */
|
|||||||
rs->sr_ref = get_entry_referrals( op, e );
|
rs->sr_ref = get_entry_referrals( op, e );
|
||||||
|
|
||||||
#ifdef NEW_LOGGING
|
#ifdef NEW_LOGGING
|
||||||
LDAP_LOG ( OPERATION, DETAIL1, "bdb_modify: entry is referral\n", 0, 0, 0 );
|
LDAP_LOG ( OPERATION, DETAIL1,
|
||||||
|
"bdb_modify: entry is referral\n",
|
||||||
|
0, 0, 0 );
|
||||||
#else
|
#else
|
||||||
Debug( LDAP_DEBUG_TRACE,
|
Debug( LDAP_DEBUG_TRACE,
|
||||||
"bdb_modify: entry is referral\n",
|
"bdb_modify: entry is referral\n",
|
||||||
@ -538,8 +548,12 @@ retry: /* transaction retry */
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( op->o_preread ) {
|
if( op->o_preread ) {
|
||||||
|
if( preread_ctrl == NULL ) {
|
||||||
|
preread_ctrl = &ctrls[num_ctrls++];
|
||||||
|
ctrls[num_ctrls] = NULL;
|
||||||
|
}
|
||||||
if ( slap_read_controls( op, rs, e,
|
if ( slap_read_controls( op, rs, e,
|
||||||
&slap_pre_read_bv, &ctrls[num_ctrls] ) )
|
&slap_pre_read_bv, preread_ctrl ) )
|
||||||
{
|
{
|
||||||
#ifdef NEW_LOGGING
|
#ifdef NEW_LOGGING
|
||||||
LDAP_LOG ( OPERATION, DETAIL1,
|
LDAP_LOG ( OPERATION, DETAIL1,
|
||||||
@ -550,9 +564,6 @@ retry: /* transaction retry */
|
|||||||
#endif
|
#endif
|
||||||
goto return_results;
|
goto return_results;
|
||||||
}
|
}
|
||||||
ctrls[++num_ctrls] = NULL;
|
|
||||||
op->o_preread = 0; /* prevent redo on retry */
|
|
||||||
/* FIXME: should read entry on the last retry */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* nested transaction */
|
/* nested transaction */
|
||||||
@ -562,7 +573,8 @@ retry: /* transaction retry */
|
|||||||
if( rs->sr_err != 0 ) {
|
if( rs->sr_err != 0 ) {
|
||||||
#ifdef NEW_LOGGING
|
#ifdef NEW_LOGGING
|
||||||
LDAP_LOG ( OPERATION, ERR,
|
LDAP_LOG ( OPERATION, ERR,
|
||||||
"bdb_modify: txn_begin(2) failed: %s (%d)\n", db_strerror(rs->sr_err), rs->sr_err, 0 );
|
"bdb_modify: txn_begin(2) failed: %s (%d)\n",
|
||||||
|
db_strerror(rs->sr_err), rs->sr_err, 0 );
|
||||||
#else
|
#else
|
||||||
Debug( LDAP_DEBUG_TRACE,
|
Debug( LDAP_DEBUG_TRACE,
|
||||||
"bdb_modify: txn_begin(2) failed: %s (%d)\n",
|
"bdb_modify: txn_begin(2) failed: %s (%d)\n",
|
||||||
@ -635,8 +647,12 @@ retry: /* transaction retry */
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( op->o_postread ) {
|
if( op->o_postread ) {
|
||||||
|
if( postread_ctrl == NULL ) {
|
||||||
|
postread_ctrl = &ctrls[num_ctrls++];
|
||||||
|
ctrls[num_ctrls] = NULL;
|
||||||
|
}
|
||||||
if( slap_read_controls( op, rs, e,
|
if( slap_read_controls( op, rs, e,
|
||||||
&slap_post_read_bv, &ctrls[num_ctrls] ) )
|
&slap_post_read_bv, postread_ctrl ) )
|
||||||
{
|
{
|
||||||
#ifdef NEW_LOGGING
|
#ifdef NEW_LOGGING
|
||||||
LDAP_LOG ( OPERATION, DETAIL1,
|
LDAP_LOG ( OPERATION, DETAIL1,
|
||||||
@ -647,9 +663,6 @@ retry: /* transaction retry */
|
|||||||
#endif
|
#endif
|
||||||
goto return_results;
|
goto return_results;
|
||||||
}
|
}
|
||||||
ctrls[++num_ctrls] = NULL;
|
|
||||||
op->o_postread = 0; /* prevent redo on retry */
|
|
||||||
/* FIXME: should read entry on the last retry */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( op->o_noop ) {
|
if( op->o_noop ) {
|
||||||
@ -755,5 +768,14 @@ done:
|
|||||||
if( e != NULL ) {
|
if( e != NULL ) {
|
||||||
bdb_unlocked_cache_return_entry_w (&bdb->bi_cache, e);
|
bdb_unlocked_cache_return_entry_w (&bdb->bi_cache, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( preread_ctrl != NULL ) {
|
||||||
|
slap_sl_free( (*preread_ctrl)->ldctl_value.bv_val, &op->o_tmpmemctx );
|
||||||
|
slap_sl_free( *preread_ctrl, &op->o_tmpmemctx );
|
||||||
|
}
|
||||||
|
if( postread_ctrl != NULL ) {
|
||||||
|
slap_sl_free( (*postread_ctrl)->ldctl_value.bv_val, &op->o_tmpmemctx );
|
||||||
|
slap_sl_free( *postread_ctrl, &op->o_tmpmemctx );
|
||||||
|
}
|
||||||
return rs->sr_err;
|
return rs->sr_err;
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,8 @@ bdb_modrdn( Operation *op, SlapReply *rs )
|
|||||||
|
|
||||||
int num_retries = 0;
|
int num_retries = 0;
|
||||||
|
|
||||||
|
LDAPControl **preread_ctrl = NULL;
|
||||||
|
LDAPControl **postread_ctrl = NULL;
|
||||||
LDAPControl *ctrls[SLAP_MAX_RESPONSE_CONTROLS];
|
LDAPControl *ctrls[SLAP_MAX_RESPONSE_CONTROLS];
|
||||||
int num_ctrls = 0;
|
int num_ctrls = 0;
|
||||||
|
|
||||||
@ -73,6 +75,8 @@ bdb_modrdn( Operation *op, SlapReply *rs )
|
|||||||
int parent_is_glue = 0;
|
int parent_is_glue = 0;
|
||||||
int parent_is_leaf = 0;
|
int parent_is_leaf = 0;
|
||||||
|
|
||||||
|
ctrls[num_ctrls] = NULL;
|
||||||
|
|
||||||
#ifdef NEW_LOGGING
|
#ifdef NEW_LOGGING
|
||||||
LDAP_LOG ( OPERATION, ENTRY, "==>bdb_modrdn(%s,%s,%s)\n",
|
LDAP_LOG ( OPERATION, ENTRY, "==>bdb_modrdn(%s,%s,%s)\n",
|
||||||
op->o_req_dn.bv_val,op->oq_modrdn.rs_newrdn.bv_val,
|
op->o_req_dn.bv_val,op->oq_modrdn.rs_newrdn.bv_val,
|
||||||
@ -789,8 +793,12 @@ retry: /* transaction retry */
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( op->o_preread ) {
|
if( op->o_preread ) {
|
||||||
|
if( preread_ctrl == NULL ) {
|
||||||
|
preread_ctrl = &ctrls[num_ctrls++];
|
||||||
|
ctrls[num_ctrls] = NULL;
|
||||||
|
}
|
||||||
if( slap_read_controls( op, rs, e,
|
if( slap_read_controls( op, rs, e,
|
||||||
&slap_pre_read_bv, &ctrls[num_ctrls] ) )
|
&slap_pre_read_bv, preread_ctrl ) )
|
||||||
{
|
{
|
||||||
#ifdef NEW_LOGGING
|
#ifdef NEW_LOGGING
|
||||||
LDAP_LOG ( OPERATION, DETAIL1,
|
LDAP_LOG ( OPERATION, DETAIL1,
|
||||||
@ -801,9 +809,6 @@ retry: /* transaction retry */
|
|||||||
#endif
|
#endif
|
||||||
goto return_results;
|
goto return_results;
|
||||||
}
|
}
|
||||||
ctrls[++num_ctrls] = NULL;
|
|
||||||
op->o_preread = 0; /* prevent redo on retry */
|
|
||||||
/* FIXME: should read entry on the last retry */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* nested transaction */
|
/* nested transaction */
|
||||||
@ -992,8 +997,12 @@ retry: /* transaction retry */
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( op->o_postread ) {
|
if( op->o_postread ) {
|
||||||
|
if( postread_ctrl == NULL ) {
|
||||||
|
postread_ctrl = &ctrls[num_ctrls++];
|
||||||
|
ctrls[num_ctrls] = NULL;
|
||||||
|
}
|
||||||
if( slap_read_controls( op, rs, e,
|
if( slap_read_controls( op, rs, e,
|
||||||
&slap_post_read_bv, &ctrls[num_ctrls] ) )
|
&slap_post_read_bv, postread_ctrl ) )
|
||||||
{
|
{
|
||||||
#ifdef NEW_LOGGING
|
#ifdef NEW_LOGGING
|
||||||
LDAP_LOG ( OPERATION, DETAIL1,
|
LDAP_LOG ( OPERATION, DETAIL1,
|
||||||
@ -1004,9 +1013,6 @@ retry: /* transaction retry */
|
|||||||
#endif
|
#endif
|
||||||
goto return_results;
|
goto return_results;
|
||||||
}
|
}
|
||||||
ctrls[++num_ctrls] = NULL;
|
|
||||||
op->o_postread = 0; /* prevent redo on retry */
|
|
||||||
/* FIXME: should read entry on the last retry */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( op->o_noop ) {
|
if( op->o_noop ) {
|
||||||
@ -1155,5 +1161,13 @@ done:
|
|||||||
op->o_private = NULL;
|
op->o_private = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( preread_ctrl != NULL ) {
|
||||||
|
slap_sl_free( (*preread_ctrl)->ldctl_value.bv_val, &op->o_tmpmemctx );
|
||||||
|
slap_sl_free( *preread_ctrl, &op->o_tmpmemctx );
|
||||||
|
}
|
||||||
|
if( postread_ctrl != NULL ) {
|
||||||
|
slap_sl_free( (*postread_ctrl)->ldctl_value.bv_val, &op->o_tmpmemctx );
|
||||||
|
slap_sl_free( *postread_ctrl, &op->o_tmpmemctx );
|
||||||
|
}
|
||||||
return rs->sr_err;
|
return rs->sr_err;
|
||||||
}
|
}
|
||||||
|
@ -1668,7 +1668,14 @@ int slap_read_controls(
|
|||||||
c.ldctl_oid = oid->bv_val;
|
c.ldctl_oid = oid->bv_val;
|
||||||
c.ldctl_iscritical = 0;
|
c.ldctl_iscritical = 0;
|
||||||
|
|
||||||
*ctrl = slap_sl_calloc( 1, sizeof(LDAPControl), NULL );
|
if ( ctrl == NULL ) {
|
||||||
|
/* first try */
|
||||||
|
*ctrl = (LDAPControl *) slap_sl_calloc( 1, sizeof(LDAPControl), NULL );
|
||||||
|
} else {
|
||||||
|
/* retry: free previous try */
|
||||||
|
slap_sl_free( (*ctrl)->ldctl_value.bv_val, &op->o_tmpmemctx );
|
||||||
|
}
|
||||||
|
|
||||||
**ctrl = c;
|
**ctrl = c;
|
||||||
return LDAP_SUCCESS;
|
return LDAP_SUCCESS;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user