/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2005-2007 The OpenLDAP Foundation.
+ * Copyright 2005-2008 The OpenLDAP Foundation.
* Portions copyright 2004-2005 Symas Corporation.
* All rights reserved.
*
if ( li->li_task ) {
struct re_s *re = li->li_task;
li->li_task = NULL;
+ ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
if ( ldap_pvt_runqueue_isrunning( &slapd_rq, re ))
ldap_pvt_runqueue_stoptask( &slapd_rq, re );
ldap_pvt_runqueue_remove( &slapd_rq, re );
+ ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
}
li->li_age = 0;
li->li_cycle = 0;
struct re_s *re = li->li_task;
if ( re )
re->interval.tv_sec = li->li_cycle;
- else
+ else {
+ ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
li->li_task = ldap_pvt_runqueue_insert( &slapd_rq,
li->li_cycle, accesslog_purge, li,
"accesslog_purge", li->li_db ?
li->li_db->be_suffix[0].bv_val :
c->be->be_suffix[0].bv_val );
+ ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
+ }
}
}
break;
return SLAP_CB_CONTINUE;
if ( lo->mask & LOG_OP_WRITES ) {
+ slap_callback *cb;
ldap_pvt_thread_mutex_lock( &li->li_log_mutex );
old = li->li_old;
li->li_old = NULL;
+ /* Disarm mod_cleanup */
+ for ( cb = op->o_callback->sc_next; cb; cb = cb->sc_next ) {
+ if ( cb->sc_private == (void *)on ) {
+ cb->sc_private = NULL;
+ break;
+ }
+ }
ldap_pvt_thread_rmutex_unlock( &li->li_op_rmutex, op->o_tid );
}
return SLAP_CB_CONTINUE;
}
+static int
+accesslog_mod_cleanup( Operation *op, SlapReply *rs )
+{
+ slap_callback *sc = op->o_callback;
+ slap_overinst *on = sc->sc_private;
+ op->o_callback = sc->sc_next;
+
+ op->o_tmpfree( sc, op->o_tmpmemctx );
+
+ if ( on ) {
+ BackendInfo *bi = op->o_bd->bd_info;
+ op->o_bd->bd_info = (BackendInfo *)on;
+ accesslog_response( op, rs );
+ op->o_bd->bd_info = bi;
+ }
+ return 0;
+}
+
static int
accesslog_op_mod( Operation *op, SlapReply *rs )
{
log_info *li = on->on_bi.bi_private;
if ( li->li_ops & LOG_OP_WRITES ) {
+ slap_callback *cb = op->o_tmpalloc( sizeof( slap_callback ), op->o_tmpmemctx ), *cb2;
+ cb->sc_cleanup = accesslog_mod_cleanup;
+ cb->sc_response = NULL;
+ cb->sc_private = on;
+ cb->sc_next = NULL;
+ for ( cb2 = op->o_callback; cb2->sc_next; cb2 = cb2->sc_next );
+ cb2->sc_next = cb;
+
ldap_pvt_thread_rmutex_lock( &li->li_op_rmutex, op->o_tid );
if ( li->li_oldf && ( op->o_tag == LDAP_REQ_DELETE ||
op->o_tag == LDAP_REQ_MODIFY ||
slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
log_info *li = on->on_bi.bi_private;
+ if ( op->o_sync != SLAP_CONTROL_NONE )
+ return SLAP_CB_CONTINUE;
+
if ( rs->sr_entry != NULL
&& dn_match( &op->o_bd->be_nsuffix[0], &rs->sr_entry->e_nname ) )
{
ber_dupbv( &li->li_db->be_rootndn, li->li_db->be_nsuffix );
}
+ ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
ldap_pvt_runqueue_insert( &slapd_rq, 3600, accesslog_db_root, on,
"accesslog_db_root", li->li_db->be_suffix[0].bv_val );
+ ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
return 0;
}