struct berval rd_pdn;
struct berval rd_npdn;
+ int rd_sleep;
+
retcode_item_t *rd_item;
unsigned rd_flags;
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;
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 );
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 ) {
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;
} 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;
}