/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2004-2012 The OpenLDAP Foundation.
+ * Copyright 2004-2014 The OpenLDAP Foundation.
* Portions Copyright 2004 Symas Corporation.
* All rights reserved.
*
dependent_data *dp;
SlapReply rs = {REP_RESULT};
Operation op2;
+ unsigned long opid;
int rc;
op->o_callback->sc_response = refint_search_cb;
Debug( LDAP_DEBUG_TRACE,
"refint_repair: search failed: %d\n",
rc, 0, 0 );
- return 0;
+ return rc;
}
/* safety? paranoid just in case */
*
*/
+ opid = op->o_opid;
op2 = *op;
for ( dp = rq->attrs; dp; dp = dp->next ) {
SlapReply rs2 = {REP_RESULT};
/* Internal ops, never replicate these */
op2.orm_no_opattrs = 1;
op2.o_dont_replicate = 1;
+ op2.o_opid = 0;
/* Set our ModifiersName */
if ( SLAP_LASTMOD( op->o_bd ) ) {
op2.o_tmpfree( m, op2.o_tmpmemctx );
}
}
+ op2.o_opid = opid;
return 0;
}
Filter ftop, *fptr;
refint_q *rq;
refint_attrs *ip;
+ int pausing = 0, rc = 0;
connection_fake_init( &conn, &opbuf, ctx );
op = &opbuf.ob_op;
dependent_data *dp, *dp_next;
refint_attrs *ra, *ra_next;
+ if ( ldap_pvt_thread_pool_pausing( &connection_pool ) > 0 ) {
+ pausing = 1;
+ break;
+ }
+
/* Dequeue an op */
ldap_pvt_thread_mutex_lock( &id->qmutex );
rq = id->qhead;
if ( rq->db != NULL ) {
op->o_bd = rq->db;
- refint_repair( op, id, rq );
+ rc = refint_repair( op, id, rq );
} else {
BackendDB *be;
if ( be->be_search && be->be_modify ) {
op->o_bd = be;
- refint_repair( op, id, rq );
+ rc = refint_repair( op, id, rq );
}
}
}
op->o_tmpfree( dp, op->o_tmpmemctx );
}
op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx );
+ if ( rc == LDAP_BUSY ) {
+ pausing = 1;
+ /* re-queue this op */
+ ldap_pvt_thread_mutex_lock( &id->qmutex );
+ rq->next = id->qhead;
+ id->qhead = rq;
+ if ( !id->qtail )
+ id->qtail = rq;
+ ldap_pvt_thread_mutex_unlock( &id->qmutex );
+ break;
+ }
if ( !BER_BVISNULL( &rq->newndn )) {
ch_free( rq->newndn.bv_val );
/* wait until we get explicitly scheduled again */
ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
ldap_pvt_runqueue_stoptask( &slapd_rq, id->qtask );
- ldap_pvt_runqueue_resched( &slapd_rq,id->qtask, 1 );
+ if ( pausing ) {
+ /* try to run again as soon as the pause is done */
+ id->qtask->interval.tv_sec = 0;
+ ldap_pvt_runqueue_resched( &slapd_rq, id->qtask, 0 );
+ id->qtask->interval.tv_sec = RUNQ_INTERVAL;
+ } else {
+ ldap_pvt_runqueue_resched( &slapd_rq,id->qtask, 1 );
+ }
ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
return NULL;