/* syncprov.c - syncrepl provider */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2004-2012 The OpenLDAP Foundation.
+ * Copyright 2004-2013 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
typedef struct modtarget {
struct modinst *mt_mods;
struct modinst *mt_tail;
- Operation *mt_op;
+ struct berval mt_dn;
ldap_pvt_thread_mutex_t mt_mutex;
} modtarget;
int rc;
m1 = c1; m2 = c2;
- rc = m1->mt_op->o_req_ndn.bv_len - m2->mt_op->o_req_ndn.bv_len;
+ rc = m1->mt_dn.bv_len - m2->mt_dn.bv_len;
if ( rc ) return rc;
- return ber_bvcmp( &m1->mt_op->o_req_ndn, &m2->mt_op->o_req_ndn );
+ return ber_bvcmp( &m1->mt_dn, &m2->mt_dn );
}
/* syncprov_findbase:
mt->mt_mods = mt->mt_mods->mi_next;
/* If there are more, promote the next one */
if ( mt->mt_mods ) {
- mt->mt_op = mt->mt_mods->mi_op;
ldap_pvt_thread_mutex_unlock( &mt->mt_mutex );
} else {
ldap_pvt_thread_mutex_unlock( &mt->mt_mutex );
avl_delete( &si->si_mods, mt, sp_avl_cmp );
ldap_pvt_thread_mutex_unlock( &si->si_mods_mutex );
ldap_pvt_thread_mutex_destroy( &mt->mt_mutex );
+ ch_free( mt->mt_dn.bv_val );
ch_free( mt );
}
}
mi->mi_op = op;
/* See if we're already modifying this entry... */
- mtdummy.mt_op = op;
+ mtdummy.mt_dn = op->o_req_ndn;
ldap_pvt_thread_mutex_lock( &si->si_mods_mutex );
mt = avl_find( si->si_mods, &mtdummy, sp_avl_cmp );
if ( mt ) {
mt = ch_malloc( sizeof(modtarget) );
mt->mt_mods = mi;
mt->mt_tail = mi;
- mt->mt_op = mi->mi_op;
+ ber_dupbv( &mt->mt_dn, &mi->mi_op->o_req_ndn );
ldap_pvt_thread_mutex_init( &mt->mt_mutex );
avl_insert( &si->si_mods, mt, sp_avl_cmp, avl_dup_error );
ldap_pvt_thread_mutex_unlock( &si->si_mods_mutex );
#ifdef SLAP_CONFIG_DELETE
if ( !slapd_shutdown ) {
+ ldap_pvt_thread_mutex_lock( &si->si_ops_mutex );
for ( so=si->si_ops, sonext=so; so; so=sonext ) {
SlapReply rs = {REP_RESULT};
rs.sr_err = LDAP_UNAVAILABLE;
syncprov_drop_psearch( so, 0);
}
si->si_ops=NULL;
+ ldap_pvt_thread_mutex_unlock( &si->si_ops_mutex );
}
overlay_unregister_control( be, LDAP_CONTROL_SYNC );
#endif /* SLAP_CONFIG_DELETE */