/* Record of a persistent search */
typedef struct syncops {
struct syncops *s_next;
+ struct syncprov_info_t *s_si;
struct berval s_base; /* ndn of search base */
ID s_eid; /* entryID of search base */
Operation *s_op; /* search op */
}
static int
-syncprov_free_syncop( syncops *so )
+syncprov_free_syncop( syncops *so, int unlink )
{
syncres *sr, *srnext;
GroupAssertion *ga, *gnext;
return 0;
}
ldap_pvt_thread_mutex_unlock( &so->s_mutex );
+ if ( unlink ) {
+ syncops **sop;
+ ldap_pvt_thread_mutex_lock( &so->s_si->si_ops_mutex );
+ for ( sop = &so->s_si->si_ops; *sop; sop = &(*sop)->s_next ) {
+ if ( *sop == so ) {
+ *sop = so->s_next;
+ break;
+ }
+ }
+ ldap_pvt_thread_mutex_unlock( &so->s_si->si_ops_mutex );
+ }
if ( so->s_flags & PS_IS_DETACHED ) {
filter_free( so->s_op->ors_filter );
for ( ga = so->s_op->o_groups; ga; ga=gnext ) {
rc = syncprov_qplay( op, so );
/* decrement use count... */
- syncprov_free_syncop( so );
+ syncprov_free_syncop( so, 1 );
return NULL;
}
if ( lock )
ldap_pvt_thread_mutex_unlock( &so->s_op->o_conn->c_mutex );
}
- return syncprov_free_syncop( so );
+ return syncprov_free_syncop( so, 0 );
}
static int
{
slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
syncprov_info_t *si = on->on_bi.bi_private;
- syncops *so, *soprev;
+ syncops *so = NULL, **sop;
ldap_pvt_thread_mutex_lock( &si->si_ops_mutex );
- for ( so=si->si_ops, soprev = (syncops *)&si->si_ops; so;
- soprev=so, so=so->s_next ) {
+ for ( sop=&si->si_ops; *sop; sop = &(*sop)->s_next ) {
+ so = *sop;
if ( so->s_op->o_connid == op->o_connid &&
so->s_op->o_msgid == op->orn_msgid ) {
so->s_op->o_abandon = 1;
- soprev->s_next = so->s_next;
+ *sop = so->s_next;
break;
}
}
* with saveit == TRUE
*/
snext = ss->s_next;
- if ( syncprov_free_syncop( ss ) ) {
+ if ( syncprov_free_syncop( ss, 0 ) ) {
*pss = snext;
gonext = 0;
}
for (sm = opc->smatches; sm; sm=snext) {
snext = sm->sm_next;
- syncprov_free_syncop( sm->sm_op );
+ syncprov_free_syncop( sm->sm_op, 1 );
op->o_tmpfree( sm, op->o_tmpmemctx );
}
ldap_pvt_thread_mutex_lock( &si->si_ops_mutex );
}
sop->s_next = si->si_ops;
+ sop->s_si = si;
si->si_ops = sop;
ldap_pvt_thread_mutex_unlock( &si->si_ops_mutex );
}