mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-30 13:30:57 +08:00
fix multiple response messages; add overall sleep time
This commit is contained in:
parent
40d75df606
commit
ac8c1f2a26
@ -73,6 +73,12 @@ response code.
|
||||
.B retcode\-indir
|
||||
Enables exploitation of in-directory stored errAbsObject.
|
||||
May result in a lot of unnecessary overhead.
|
||||
.TP
|
||||
.B retcode\-sleep [-]<n>
|
||||
Defines a sleep time in seconds that is spent before actually handling
|
||||
any operation.
|
||||
If negative, a random time between 0 and the absolute value of the argument
|
||||
is used.
|
||||
|
||||
.SH SCHEMA
|
||||
The
|
||||
|
@ -77,6 +77,8 @@ typedef struct retcode_t {
|
||||
struct berval rd_pdn;
|
||||
struct berval rd_npdn;
|
||||
|
||||
int rd_sleep;
|
||||
|
||||
retcode_item_t *rd_item;
|
||||
|
||||
unsigned rd_flags;
|
||||
@ -202,7 +204,6 @@ retcode_op_internal( Operation *op, SlapReply *rs )
|
||||
slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
|
||||
|
||||
Operation op2 = *op;
|
||||
SlapReply rs2 = { 0 };
|
||||
BackendDB db = *op->o_bd;
|
||||
slap_callback sc = { 0 };
|
||||
retcode_cb_t rdc;
|
||||
@ -236,7 +237,8 @@ retcode_op_internal( Operation *op, SlapReply *rs )
|
||||
sc.sc_private = &rdc;
|
||||
op2.o_callback = ≻
|
||||
|
||||
rc = op2.o_bd->be_search( &op2, &rs2 );
|
||||
rc = op2.o_bd->be_search( &op2, rs );
|
||||
op->o_abandon = op2.o_abandon;
|
||||
|
||||
filter_free_x( &op2, op2.ors_filter );
|
||||
ber_memfree_x( op2.ors_filterstr.bv_val, op2.o_tmpmemctx );
|
||||
@ -259,6 +261,14 @@ retcode_op_func( Operation *op, SlapReply *rs )
|
||||
|
||||
slap_callback *cb = NULL;
|
||||
|
||||
/* sleep as required */
|
||||
if ( rd->rd_sleep < 0 ) {
|
||||
sleep( rand() % ( - rd->rd_sleep ) );
|
||||
|
||||
} else if ( rd->rd_sleep > 0 ) {
|
||||
sleep( rd->rd_sleep );
|
||||
}
|
||||
|
||||
if ( !dnIsSuffix( &op->o_req_ndn, &rd->rd_npdn ) ) {
|
||||
if ( RETCODE_INDIR( rd ) ) {
|
||||
switch ( op->o_tag ) {
|
||||
@ -275,10 +285,18 @@ retcode_op_func( Operation *op, SlapReply *rs )
|
||||
case LDAP_REQ_SEARCH:
|
||||
if ( op->ors_scope == LDAP_SCOPE_BASE ) {
|
||||
rs->sr_err = retcode_op_internal( op, rs );
|
||||
if ( rs->sr_err == SLAP_CB_CONTINUE ) {
|
||||
switch ( rs->sr_err ) {
|
||||
case SLAP_CB_CONTINUE:
|
||||
if ( rs->sr_nentries == 0 ) {
|
||||
break;
|
||||
}
|
||||
rs->sr_err = LDAP_SUCCESS;
|
||||
/* fallthru */
|
||||
|
||||
default:
|
||||
send_ldap_result( op, rs );
|
||||
break;
|
||||
}
|
||||
send_ldap_result( op, rs );
|
||||
return rs->sr_err;
|
||||
}
|
||||
break;
|
||||
@ -874,6 +892,31 @@ retcode_db_config(
|
||||
} else if ( strcasecmp( argv0, "indir" ) == 0 ) {
|
||||
rd->rd_flags |= RETCODE_FINDIR;
|
||||
|
||||
} else if ( strcasecmp( argv0, "sleep" ) == 0 ) {
|
||||
switch ( argc ) {
|
||||
case 1:
|
||||
fprintf( stderr, "%s: line %d: retcode: "
|
||||
"\"retcode-sleep <time>\": missing <time>\n",
|
||||
fname, lineno );
|
||||
return 1;
|
||||
|
||||
case 2:
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf( stderr, "%s: line %d: retcode: "
|
||||
"\"retcode-sleep <time>\": extra cruft after <time>\n",
|
||||
fname, lineno );
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ( lutil_atoi( &rd->rd_sleep, argv[ 1 ] ) != 0 ) {
|
||||
fprintf( stderr, "%s: line %d: retcode: "
|
||||
"\"retcode-sleep <time>\": unable to parse <time>\n",
|
||||
fname, lineno );
|
||||
return 1;
|
||||
}
|
||||
|
||||
} else {
|
||||
return SLAP_CONF_UNKNOWN;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user