op2.o_tag = LDAP_REQ_SEARCH;
op2.o_ndn = op2.o_bd->be_rootndn;
op2.o_callback = &cb;
- op2.o_time = slap_get_time();
+ slap_op_time( &op2.o_time, &op2.o_tincr );
op2.o_do_not_cache = 1;
op2.o_is_auth_check = 0;
ber_dupbv_x( &op2.o_req_dn, &op2.o_req_ndn, cp->asc_op->o_tmpmemctx );
#include <ac/time.h>
#include <ac/socket.h>
+#include "lutil.h"
#include "slap.h"
int
}
done:;
- slap_graduate_commit_csn( op );
-
if ( modlist != NULL ) {
slap_mods_free( modlist, 0 );
}
}
- rs->sr_err = slap_mods_opattrs( op, modlist,
- modtail, &rs->sr_text,
- textbuf, textlen, 1 );
- if ( rs->sr_err != LDAP_SUCCESS ) {
- send_ldap_result( op, rs );
- goto done;
- }
-
/* check for duplicate values */
rs->sr_err = slap_mods_no_repl_user_mod_check( op,
modlist, &rs->sr_text, textbuf, textlen );
return LDAP_SUCCESS;
}
+int slap_add_opattrs(
+ Operation *op,
+ const char **text,
+ char *textbuf,
+ size_t textlen,
+ int manage_ctxcsn )
+{
+ struct berval name, timestamp, csn = BER_BVNULL;
+ struct berval nname, tmp;
+ char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
+ char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
+ Attribute *a;
+
+ a = attr_find( op->ora_e->e_attrs,
+ slap_schema.si_ad_structuralObjectClass );
+
+ if ( !a ) {
+ Attribute *oc;
+ int rc;
+
+ oc = attr_find( op->ora_e->e_attrs, slap_schema.si_ad_objectClass );
+ if ( oc ) {
+ rc = structural_class( oc->a_vals, &tmp, NULL, text,
+ textbuf, textlen );
+ if( rc != LDAP_SUCCESS ) return rc;
+
+ attr_merge_one( op->ora_e, slap_schema.si_ad_structuralObjectClass,
+ &tmp, NULL );
+ }
+ }
+
+ if ( SLAP_LASTMOD( op->o_bd ) ) {
+ char *ptr;
+ timestamp.bv_val = timebuf;
+ if ( BER_BVISEMPTY( &op->o_csn )) {
+ if ( SLAP_SHADOW( op->o_bd ))
+ manage_ctxcsn = 0;
+ csn.bv_val = csnbuf;
+ csn.bv_len = sizeof(csnbuf);
+ slap_get_csn( op, &csn, manage_ctxcsn );
+ } else {
+ csn = op->o_csn;
+ }
+ ptr = strchr( csn.bv_val, '#' );
+ if ( ptr ) {
+ timestamp.bv_len = ptr - csn.bv_val;
+ if ( timestamp.bv_len >= sizeof(timebuf) )
+ timestamp.bv_len = sizeof(timebuf) - 1;
+ strncpy( timebuf, csn.bv_val, timestamp.bv_len );
+ timebuf[timestamp.bv_len] = '\0';
+ } else {
+ time_t now = slap_get_time();
+
+ timestamp.bv_len = sizeof(timebuf);
+
+ slap_timestamp( &now, ×tamp );
+ }
+
+ if ( BER_BVISEMPTY( &op->o_dn ) ) {
+ BER_BVSTR( &name, SLAPD_ANONYMOUS );
+ nname = name;
+ } else {
+ name = op->o_dn;
+ nname = op->o_ndn;
+ }
+
+ a = attr_find( op->ora_e->e_attrs,
+ slap_schema.si_ad_entryUUID );
+ if ( !a ) {
+ char uuidbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE ];
+
+ tmp.bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) );
+ tmp.bv_val = uuidbuf;
+
+ attr_merge_normalize_one( op->ora_e,
+ slap_schema.si_ad_entryUUID, &tmp, op->o_tmpmemctx );
+ }
+
+ a = attr_find( op->ora_e->e_attrs,
+ slap_schema.si_ad_creatorsName );
+ if ( !a ) {
+ attr_merge_one( op->ora_e,
+ slap_schema.si_ad_creatorsName, &name, &nname );
+ }
+
+ a = attr_find( op->ora_e->e_attrs,
+ slap_schema.si_ad_createTimestamp );
+ if ( !a ) {
+ attr_merge_one( op->ora_e,
+ slap_schema.si_ad_createTimestamp, ×tamp, NULL );
+ }
+
+ a = attr_find( op->ora_e->e_attrs,
+ slap_schema.si_ad_entryCSN );
+ if ( !a ) {
+ attr_merge_one( op->ora_e,
+ slap_schema.si_ad_entryCSN, &csn, NULL );
+ }
+
+ a = attr_find( op->ora_e->e_attrs,
+ slap_schema.si_ad_modifiersName );
+ if ( !a ) {
+ attr_merge_one( op->ora_e,
+ slap_schema.si_ad_modifiersName, &name, &nname );
+ }
+
+ a = attr_find( op->ora_e->e_attrs,
+ slap_schema.si_ad_modifyTimestamp );
+ if ( !a ) {
+ attr_merge_one( op->ora_e,
+ slap_schema.si_ad_modifyTimestamp, ×tamp, NULL );
+ }
+
+ }
+ return LDAP_SUCCESS;
+}
ctrls[num_ctrls] = 0;
+ slap_add_opattrs( op, &rs->sr_text, textbuf, textlen, 1 );
+
/* check entry's schema */
rs->sr_err = entry_schema_check( op, op->oq_add.rs_e, NULL,
get_manageDIT(op), &rs->sr_text, textbuf, textlen );
"does not exist\n", 0, 0, 0 );
rs->sr_err = LDAP_REFERRAL;
- send_ldap_result( op, rs );
-
- ber_bvarray_free( rs->sr_ref );
- op->o_tmpfree( (char *)rs->sr_matched, op->o_tmpmemctx );
- rs->sr_ref = NULL;
- rs->sr_matched = NULL;
-
- goto done;
+ rs->sr_flags = REP_MATCHED_MUSTBEFREED | REP_REF_MUSTBEFREED;
+ goto return_results;
}
rs->sr_err = access_allowed( op, p,
if ( is_entry_referral( p ) ) {
/* parent is a referral, don't allow add */
- rs->sr_matched = p->e_name.bv_val;
+ rs->sr_matched = ber_strdup_x( p->e_name.bv_val,
+ op->o_tmpmemctx );
rs->sr_ref = get_entry_referrals( op, p );
-
+ bdb_unlocked_cache_return_entry_r( &bdb->bi_cache, p );
+ p = NULL;
Debug( LDAP_DEBUG_TRACE,
LDAP_XSTRING(bdb_add) ": parent is referral\n",
0, 0, 0 );
rs->sr_err = LDAP_REFERRAL;
- send_ldap_result( op, rs );
-
- ber_bvarray_free( rs->sr_ref );
- bdb_unlocked_cache_return_entry_r( &bdb->bi_cache, p );
- rs->sr_ref = NULL;
- rs->sr_matched = NULL;
- p = NULL;
- goto done;
+ rs->sr_flags = REP_MATCHED_MUSTBEFREED | REP_REF_MUSTBEFREED;
+ goto return_results;
}
#ifdef BDB_SUBENTRIES
return_results:
send_ldap_result( op, rs );
+ if ( !SLAP_SHADOW( op->o_bd ))
+ slap_graduate_commit_csn( op );
- if( rs->sr_err == LDAP_SUCCESS && bdb->bi_txn_cp ) {
- ldap_pvt_thread_yield();
- TXN_CHECKPOINT( bdb->bi_dbenv,
- bdb->bi_txn_cp_kbyte, bdb->bi_txn_cp_min, 0 );
- }
-
-done:
if( ltid != NULL ) {
TXN_ABORT( ltid );
op->o_private = NULL;
slap_sl_free( (*postread_ctrl)->ldctl_value.bv_val, op->o_tmpmemctx );
slap_sl_free( *postread_ctrl, op->o_tmpmemctx );
}
+
+ if( rs->sr_err == LDAP_SUCCESS && bdb->bi_txn_cp ) {
+ ldap_pvt_thread_yield();
+ TXN_CHECKPOINT( bdb->bi_dbenv,
+ bdb->bi_txn_cp_kbyte, bdb->bi_txn_cp_min, 0 );
+ }
return rs->sr_err;
}
#include <stdio.h>
#include <ac/string.h>
+#include "lutil.h"
#include "back-bdb.h"
int
Debug( LDAP_DEBUG_ARGS, "==> " LDAP_XSTRING(bdb_delete) ": %s\n",
op->o_req_dn.bv_val, 0, 0 );
+ /* allocate CSN */
+ if ( !SLAP_SHADOW( op->o_bd )) {
+ struct berval csn;
+ char csnbuf[LDAP_LUTIL_CSNSTR_BUFSIZE];
+
+ csn.bv_val = csnbuf;
+ csn.bv_len = sizeof(csnbuf);
+ slap_get_csn( op, &csn, 1 );
+ }
+
if( 0 ) {
retry: /* transaction retry */
if( e != NULL ) {
}
rs->sr_err = LDAP_REFERRAL;
- send_ldap_result( op, rs );
-
- if ( rs->sr_ref != default_referral ) {
- ber_bvarray_free( rs->sr_ref );
- }
- free( (char *)rs->sr_matched );
- rs->sr_ref = NULL;
- rs->sr_matched = NULL;
-
- rs->sr_err = -1;
- goto done;
+ rs->sr_flags = REP_MATCHED_MUSTBEFREED | REP_REF_MUSTBEFREED;
+ goto return_results;
}
rc = bdb_cache_find_id( op, ltid, eip->bei_id, &eip, 0, locker, &plock );
0, 0, 0 );
rs->sr_err = LDAP_REFERRAL;
- rs->sr_matched = e->e_name.bv_val;
- send_ldap_result( op, rs );
-
- ber_bvarray_free( rs->sr_ref );
- rs->sr_ref = NULL;
- rs->sr_matched = NULL;
-
- rs->sr_err = 1;
- goto done;
+ rs->sr_matched = ch_strdup( e->e_name.bv_val );
+ rs->sr_flags = REP_MATCHED_MUSTBEFREED | REP_REF_MUSTBEFREED;
+ goto return_results;
}
/* pre-read */
if( num_ctrls ) rs->sr_ctrls = ctrls;
return_results:
- send_ldap_result( op, rs );
-
- if( rs->sr_err == LDAP_SUCCESS && bdb->bi_txn_cp ) {
- ldap_pvt_thread_yield();
- TXN_CHECKPOINT( bdb->bi_dbenv,
- bdb->bi_txn_cp_kbyte, bdb->bi_txn_cp_min, 0 );
- }
-
if ( rs->sr_err == LDAP_SUCCESS && parent_is_glue && parent_is_leaf ) {
op->o_delete_glue_parent = 1;
}
-done:
if ( p )
bdb_unlocked_cache_return_entry_r(&bdb->bi_cache, p);
op->o_private = NULL;
}
+ send_ldap_result( op, rs );
+ if ( !SLAP_SHADOW( op->o_bd ))
+ slap_graduate_commit_csn( op );
+
if( preread_ctrl != NULL ) {
slap_sl_free( (*preread_ctrl)->ldctl_value.bv_val, op->o_tmpmemctx );
slap_sl_free( *preread_ctrl, op->o_tmpmemctx );
}
+
+ if( rs->sr_err == LDAP_SUCCESS && bdb->bi_txn_cp ) {
+ ldap_pvt_thread_yield();
+ TXN_CHECKPOINT( bdb->bi_dbenv,
+ bdb->bi_txn_cp_kbyte, bdb->bi_txn_cp_min, 0 );
+ }
return rs->sr_err;
}
ctrls[num_ctrls] = NULL;
+ if ( !SLAP_SHADOW( op->o_bd ))
+ slap_mods_opattrs( op, op->orm_modlist, 1 );
+
if( 0 ) {
retry: /* transaction retry */
if ( dummy.e_attrs ) {
attrs_free( dummy.e_attrs );
}
send_ldap_result( op, rs );
+ if ( !SLAP_SHADOW( op->o_bd ))
+ slap_graduate_commit_csn( op );
if( rs->sr_err == LDAP_SUCCESS && bdb->bi_txn_cp ) {
ldap_pvt_thread_yield();
#include "back-ldbm.h"
#include "proto-back-ldbm.h"
+static int
+ldbm_csn_cb(
+ Operation *op,
+ SlapReply *rs )
+{
+ op->o_callback = op->o_callback->sc_next;
+ slap_graduate_commit_csn( op );
+ return SLAP_CB_CONTINUE;
+}
+
int
ldbm_back_add(
Operation *op,
AttributeDescription *entry = slap_schema.si_ad_entry;
char textbuf[SLAP_TEXT_BUFLEN];
size_t textlen = sizeof textbuf;
+ slap_callback cb = { NULL };
#ifdef LDBM_SUBENTRIES
int subentry;
#endif
Debug(LDAP_DEBUG_ARGS, "==> ldbm_back_add: %s\n",
op->o_req_dn.bv_val, 0, 0);
+ slap_add_opattrs( op, &rs->sr_text, textbuf, textlen, 1 );
+
+ cb.sc_cleanup = ldbm_csn_cb;
+ cb.sc_next = op->o_callback;
+ op->o_callback = &cb;
+
rs->sr_err = entry_schema_check( op, op->oq_add.rs_e, NULL,
get_manageDIT(op), &rs->sr_text, textbuf, textlen );
/* grab giant lock for writing */
ldap_pvt_thread_rdwr_wlock(&li->li_giant_rwlock);
+ /* allocate CSN */
+ if ( !SLAP_SHADOW( op->o_bd )) {
+ struct berval csn;
+ char csnbuf[LDAP_LUTIL_CSNSTR_BUFSIZE];
+
+ csn.bv_val = csnbuf;
+ csn.bv_len = sizeof(csnbuf);
+ slap_get_csn( op, &csn, 1 );
+ }
+
/* get entry with writer lock */
e = dn2entry_w( op->o_bd, &op->o_req_ndn, &matched );
&op->o_req_dn, LDAP_SCOPE_DEFAULT );
}
- ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock);
-
rs->sr_err = LDAP_REFERRAL;
- send_ldap_result( op, rs );
-
- if ( rs->sr_ref ) ber_bvarray_free( rs->sr_ref );
- free( (char *)rs->sr_matched );
- rs->sr_ref = NULL;
- rs->sr_matched = NULL;
- return( -1 );
+ rs->sr_flags |= REP_MATCHED_MUST_BE_FREED | REP_REF_MUSTBEFREED;
+ goto return_results;
}
/* check entry for "entry" acl */
"<=- ldbm_back_delete: no write access to entry\n", 0,
0, 0 );
- send_ldap_error( op, rs, LDAP_INSUFFICIENT_ACCESS,
- "no write access to entry" );
-
- rc = LDAP_INSUFFICIENT_ACCESS;
+ rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
+ rs->sr_text = "no write access to entry";
goto return_results;
}
0, 0 );
rs->sr_err = LDAP_REFERRAL;
- rs->sr_matched = e->e_name.bv_val;
- send_ldap_result( op, rs );
-
- if ( rs->sr_ref ) ber_bvarray_free( rs->sr_ref );
- rs->sr_ref = NULL;
- rs->sr_matched = NULL;
- rc = LDAP_REFERRAL;
+ rs->sr_matched = ch_strdup( e->e_name.bv_val );
+ rs->sr_flags = REP_MATCHED_MUSTBEFREED | REP_REF_MUSTBEFREED;
goto return_results;
}
Debug(LDAP_DEBUG_ARGS, "<=- ldbm_back_delete: non leaf %s\n",
op->o_req_dn.bv_val, 0, 0);
- send_ldap_error( op, rs, LDAP_NOT_ALLOWED_ON_NONLEAF,
- "subordinate objects must be deleted first");
+ rs->sr_err = LDAP_NOT_ALLOWED_ON_NONLEAF;
+ rs->sr_text = "subordinate objects must be deleted first";
goto return_results;
}
"<=- ldbm_back_delete: parent does not exist\n",
0, 0, 0);
- send_ldap_error( op, rs, LDAP_OTHER,
- "could not locate parent of entry" );
+ rs->sr_err = LDAP_OTHER;
+ rs->sr_text = "could not locate parent of entry";
goto return_results;
}
"<=- ldbm_back_delete: no access to parent\n", 0,
0, 0 );
- send_ldap_error( op, rs, LDAP_INSUFFICIENT_ACCESS,
- "no write access to parent" );
+ rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
+ rs->sr_text = "no write access to parent";
goto return_results;
}
"<=- ldbm_back_delete: no "
"access to parent\n", 0, 0, 0 );
- send_ldap_error( op, rs, LDAP_INSUFFICIENT_ACCESS,
- "no write access to parent" );
+ rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
+ rs->sr_text = "no write access to parent";
goto return_results;
}
"<=- ldbm_back_delete: no parent & "
"not root\n", 0, 0, 0);
- send_ldap_error( op, rs,
- LDAP_INSUFFICIENT_ACCESS,
- NULL );
+ rs->sr_err = LDAP_INSUFFICIENT_ACCESS;
goto return_results;
}
}
"<=- ldbm_back_delete: operations error %s\n",
op->o_req_dn.bv_val, 0, 0);
- send_ldap_error( op, rs, LDAP_OTHER,
- "DN index delete failed" );
+ rs->sr_err = LDAP_OTHER;
+ rs->sr_text = "DN index delete failed";
goto return_results;
}
"<=- ldbm_back_delete: operations error %s\n",
op->o_req_dn.bv_val, 0, 0);
- send_ldap_error( op, rs, LDAP_OTHER,
- "entry delete failed" );
+ rs->sr_err = LDAP_OTHER;
+ rs->sr_text = "entry delete failed";
goto return_results;
}
(void) index_entry_del( op, e );
rs->sr_err = LDAP_SUCCESS;
- send_ldap_result( op, rs );
- rc = LDAP_SUCCESS;
return_results:;
+ rc = rs->sr_err;
+
if( p != NULL ) {
/* free parent and writer lock */
cache_return_entry_w( &li->li_cache, p );
}
- /* free entry and writer lock */
- cache_return_entry_w( &li->li_cache, e );
+ if ( e != NULL ) {
+ /* free entry and writer lock */
+ cache_return_entry_w( &li->li_cache, e );
+ }
ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock);
+ send_ldap_result( op, rs );
+ if ( !SLAP_SHADOW( op->o_bd ))
+ slap_graduate_commit_csn( op );
+
return rc;
}
Debug(LDAP_DEBUG_ARGS, "ldbm_back_modify:\n", 0, 0, 0);
+ if ( !SLAP_SHADOW( op->o_bd ))
+ slap_mods_opattrs( op, op->orm_modlist, 1 );
+
/* grab giant lock for writing */
ldap_pvt_thread_rdwr_wlock(&li->li_giant_rwlock);
/* FIXME: dn2entry() should return non-glue entry */
if (( e == NULL ) || ( !manageDSAit && e && is_entry_glue( e ))) {
if ( matched != NULL ) {
- rs->sr_matched = ch_strdup( matched->e_dn );
+ rs->sr_matched = ber_strdup_x( matched->e_dn, op->o_tmpmemctx );
rs->sr_ref = is_entry_referral( matched )
? get_entry_referrals( op, matched )
: NULL;
&op->o_req_dn, LDAP_SCOPE_DEFAULT );
}
- ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock);
rs->sr_err = LDAP_REFERRAL;
- send_ldap_result( op, rs );
-
- if ( rs->sr_ref ) ber_bvarray_free( rs->sr_ref );
- free( (char *)rs->sr_matched );
-
- rs->sr_ref = NULL;
- rs->sr_matched = NULL;
- return rs->sr_err;
+ rs->sr_flags = REP_MATCHED_MUSTBEFREED | REP_REF_MUSTBEFREED;
+ goto return_results;
}
if ( !manageDSAit && is_entry_referral( e ) )
0, 0 );
rs->sr_err = LDAP_REFERRAL;
- rs->sr_matched = e->e_name.bv_val;
- send_ldap_result( op, rs );
-
- if ( rs->sr_ref ) ber_bvarray_free( rs->sr_ref );
- rs->sr_ref = NULL;
- rs->sr_matched = NULL;
- goto error_return;
+ rs->sr_matched = ber_strdup_x( e->e_name.bv_val, op->o_tmpmemctx );
+ rs->sr_flags = REP_MATCHED_MUSTBEFREED | REP_REF_MUSTBEFREED;
+ goto return_results;
}
/* Modify the entry */
rs->sr_err = ldbm_modify_internal( op, op->oq_modify.rs_modlist, e,
&rs->sr_text, textbuf, textlen );
- if( rs->sr_err != LDAP_SUCCESS ) {
- if( rs->sr_err != SLAPD_ABANDON ) {
- send_ldap_result( op, rs );
- }
-
- goto error_return;
- }
-
/* change the entry itself */
- if ( id2entry_add( op->o_bd, e ) != 0 ) {
- send_ldap_error( op, rs, LDAP_OTHER,
- "id2entry failure" );
- rs->sr_err = LDAP_OTHER;
- goto error_return;
+ if( rs->sr_err == LDAP_SUCCESS ) {
+ if ( id2entry_add( op->o_bd, e ) != 0 ) {
+ rs->sr_err = LDAP_OTHER;
+ rs->sr_text = "id2entry failure";
+ }
}
- rs->sr_text = NULL;
- send_ldap_error( op, rs, LDAP_SUCCESS,
- NULL );
-
+return_results:;
cache_return_entry_w( &li->li_cache, e );
ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock);
- return LDAP_SUCCESS;
+ send_ldap_result( op, rs );
+ if ( !SLAP_SHADOW( op->o_bd ))
+ slap_graduate_commit_csn( op );
-error_return:;
- cache_return_entry_w( &li->li_cache, e );
- ldap_pvt_thread_rdwr_wunlock(&li->li_giant_rwlock);
rs->sr_text = NULL;
return rs->sr_err;
}
int statres;
char textbuf[SLAP_TEXT_BUFLEN];
+ slap_add_opattrs( op, &rs->sr_text, textbuf, sizeof( textbuf ), 1 );
+
rs->sr_err = entry_schema_check(op, e, NULL, 0,
&rs->sr_text, textbuf, sizeof( textbuf ) );
if ( rs->sr_err != LDAP_SUCCESS ) goto send_res;
send_res:
send_ldap_result(op, rs);
+ if ( !SLAP_SHADOW( op->o_bd ))
+ slap_graduate_commit_csn( op );
return 0;
}
Entry * entry = NULL;
int spew_res;
+ if ( !SLAP_SHADOW( op->o_bd ))
+ slap_mods_opattrs( op, op->orm_modlist, 1 );
+
ldap_pvt_thread_mutex_lock(&ni->li_mutex);
dn2path(&op->o_req_ndn, &op->o_bd->be_nsuffix[0], &ni->li_base_path,
&path);
rs->sr_text = NULL;
ldap_pvt_thread_mutex_unlock(&ni->li_mutex);
send_ldap_result(op, rs);
+ if ( !SLAP_SHADOW( op->o_bd ))
+ slap_graduate_commit_csn( op );
return 0;
}
struct berval path = BER_BVNULL;
int res = 0;
+ if ( !SLAP_SHADOW( op->o_bd )) {
+ struct berval csn;
+ char csnbuf[LDAP_LUTIL_CSNSTR_BUFSIZE];
+
+ csn.bv_val = csnbuf;
+ csn.bv_len = sizeof( csnbuf );
+ slap_get_csn( op, &csn, 1 );
+ }
+
ldap_pvt_thread_mutex_lock(&ni->li_mutex);
dn2path(&op->o_req_ndn, &op->o_bd->be_nsuffix[0], &ni->li_base_path, &path);
SLAP_FREE(path.bv_val);
ldap_pvt_thread_mutex_unlock(&ni->li_mutex);
send_ldap_result(op, rs);
+ if ( !SLAP_SHADOW( op->o_bd ))
+ slap_graduate_commit_csn( op );
return 0;
}
*/
if ( op->o_sync ) {
char buf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
- struct berval csn = BER_BVNULL;
+ struct berval csn;
- slap_get_csn( op, buf, sizeof( buf ), &csn, 1 );
+ csn.bv_val = buf;
+ csn.bv_len = sizeof( buf );
+ slap_get_csn( op, &csn, 1 );
rs->sr_err = LDAP_SUCCESS;
send_ldap_result( op, rs );
oc = backsql_id2oc( bi, e_id.eid_oc_id );
rs->sr_err = backsql_modify_internal( op, rs, dbh, oc, &e_id, mod );
+ slap_graduate_commit_csn( op );
if ( rs->sr_err != LDAP_SUCCESS ) {
e = &r;
goto done;
} else
#endif /* BACKSQL_SYNCPROV */
{
- slap_get_csn( op, csnbuf, sizeof(csnbuf), &entryCSN, 0 );
+ entryCSN.bv_val = csnbuf;
+ entryCSN.bv_len = sizeof( csnbuf );
+ slap_get_csn( op, &entryCSN, 0 );
}
ber_dupbv( &a->a_vals[ 0 ], &entryCSN );
op->o_connid = op->o_conn->c_connid;
connection_init_log_prefix( op );
- op->o_time = slap_get_time();
+ slap_op_time( &op->o_time, &op->o_tincr );
}
void
if ( csne->ce_opid == op->o_opid && csne->ce_connid == op->o_connid ) {
LDAP_TAILQ_REMOVE( op->o_bd->be_pending_csn_list,
csne, ce_csn_link );
+ if ( op->o_csn.bv_val == csne->ce_csn.bv_val ) {
+ BER_BVZERO( &op->o_csn );
+ }
ch_free( csne->ce_csn.bv_val );
ch_free( csne );
break;
ldap_pvt_thread_mutex_lock( op->o_bd->be_pcl_mutexp );
ber_dupbv( &pending->ce_csn, csn );
+ op->o_csn = pending->ce_csn;
pending->ce_connid = op->o_connid;
pending->ce_opid = op->o_opid;
pending->ce_state = SLAP_CSN_PENDING;
int
slap_get_csn(
Operation *op,
- char *csnbuf,
- int len,
struct berval *csn,
int manage_ctxcsn )
{
#ifndef HAVE_GMTIME_R
ldap_pvt_thread_mutex_lock( &gmtime_mutex );
#endif
- csn->bv_len = lutil_csnstr( csnbuf, len, 0, 0 );
+ csn->bv_len = lutil_csnstr( csn->bv_val, csn->bv_len, 0, 0 );
#ifndef HAVE_GMTIME_R
ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
#endif
- csn->bv_val = csnbuf;
if ( manage_ctxcsn )
slap_queue_csn( op, csn );
rs->sr_err = frontendDB->be_delete( op, rs );
cleanup:;
- slap_graduate_commit_csn( op );
-
op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
return rs->sr_err;
op->o_bd = op_be;
- if ( !repl_user ) {
- struct berval csn = BER_BVNULL;
- char csnbuf[LDAP_LUTIL_CSNSTR_BUFSIZE];
- slap_get_csn( op, csnbuf, sizeof(csnbuf), &csn, 1 );
- }
-
#ifdef SLAPD_MULTIMASTER
if ( !op->o_bd->be_update_ndn.bv_len || !repl_user )
#endif
rs->sr_err = frontendDB->be_modify( op, rs );
cleanup:
- slap_graduate_commit_csn( op );
-
op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
if ( op->orm_modlist != NULL ) slap_mods_free( op->orm_modlist, 1 );
}
}
- if ( !repl_user ) {
- for( modtail = &modlist;
- *modtail != NULL;
- modtail = &(*modtail)->sml_next )
- {
- /* empty */
- }
-
- rs->sr_err = slap_mods_opattrs( op, modlist, modtail,
- &rs->sr_text, textbuf, textlen, 1 );
- if( rs->sr_err != LDAP_SUCCESS ) {
- send_ldap_result( op, rs );
- goto cleanup;
- }
- }
-
op->orm_modlist = modlist;
#ifdef SLAPD_MULTIMASTER
if ( !repl_user )
#endif
}
-int slap_mods_opattrs(
+/* modify only calls this for non-replicas. modrdn always calls.
+ */
+void slap_mods_opattrs(
Operation *op,
Modifications *mods,
- Modifications **modtail,
- const char **text,
- char *textbuf, size_t textlen,
int manage_ctxcsn )
{
- struct berval name, timestamp, csn;
+ struct berval name, timestamp, csn = BER_BVNULL;
struct berval nname;
char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
- Modifications *mod;
-
- int mop = op->o_tag == LDAP_REQ_ADD
- ? LDAP_MOD_ADD : LDAP_MOD_REPLACE;
-
- assert( modtail != NULL );
- assert( *modtail == NULL );
+ Modifications *mod, **modtail;
if ( SLAP_LASTMOD( op->o_bd ) ) {
- time_t now = slap_get_time();
-
- slap_get_csn( op, csnbuf, sizeof(csnbuf), &csn, manage_ctxcsn );
-
+ char *ptr;
timestamp.bv_val = timebuf;
- timestamp.bv_len = sizeof(timebuf);
+ if ( BER_BVISEMPTY( &op->o_csn )) {
+ csn.bv_val = csnbuf;
+ csn.bv_len = sizeof( csnbuf );
+ slap_get_csn( op, &csn, manage_ctxcsn );
+ } else {
+ csn = op->o_csn;
+ }
+ ptr = strchr( csn.bv_val, '#' );
+ if ( ptr ) {
+ timestamp.bv_len = ptr - csn.bv_val;
+ if ( timestamp.bv_len >= sizeof( timebuf ))
+ timestamp.bv_len = sizeof( timebuf ) - 1;
+ strncpy( timebuf, csn.bv_val, timestamp.bv_len );
+ timebuf[timestamp.bv_len] = '\0';
+ } else {
+ time_t now = slap_get_time();
- slap_timestamp( &now, ×tamp );
+ timestamp.bv_len = sizeof(timebuf);
+
+ slap_timestamp( &now, ×tamp );
+ }
if ( BER_BVISEMPTY( &op->o_dn ) ) {
BER_BVSTR( &name, SLAPD_ANONYMOUS );
name = op->o_dn;
nname = op->o_ndn;
}
- }
-
- if ( op->o_tag == LDAP_REQ_ADD ) {
- struct berval tmpval;
-
- mod = *modtail;
- if ( get_manageDIT( op ) ) {
- for ( mod = mods; mod != *modtail; mod = mod->sml_next ) {
- if ( mod->sml_desc == slap_schema.si_ad_structuralObjectClass ) {
- break;
- }
- }
-
- }
-
- if ( mod == *modtail ) {
- int rc = mods_structural_class( mods, &tmpval,
- text, textbuf, textlen );
- if( rc != LDAP_SUCCESS ) return rc;
-
- mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
- mod->sml_op = mop;
- mod->sml_flags = SLAP_MOD_INTERNAL;
- mod->sml_next = NULL;
- BER_BVZERO( &mod->sml_type );
- mod->sml_desc = slap_schema.si_ad_structuralObjectClass;
- mod->sml_values =
- (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
- ber_dupbv( &mod->sml_values[0], &tmpval );
- BER_BVZERO( &mod->sml_values[1] );
- assert( !BER_BVISNULL( &mod->sml_values[0] ) );
- mod->sml_nvalues =
- (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
- ber_dupbv( &mod->sml_nvalues[0], &tmpval );
- BER_BVZERO( &mod->sml_nvalues[1] );
- assert( !BER_BVISNULL( &mod->sml_nvalues[0] ) );
- *modtail = mod;
- modtail = &mod->sml_next;
- }
- if ( SLAP_LASTMOD( op->o_bd ) ) {
- mod = *modtail;
- if ( get_manageDIT( op ) ) {
- for ( mod = mods; mod != *modtail; mod = mod->sml_next ) {
- if ( mod->sml_desc == slap_schema.si_ad_entryUUID ) {
- break;
- }
- }
- }
-
- if ( mod == *modtail ) {
- char uuidbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE ];
-
- tmpval.bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) );
- tmpval.bv_val = uuidbuf;
-
- mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
- mod->sml_op = mop;
- mod->sml_flags = SLAP_MOD_INTERNAL;
- mod->sml_next = NULL;
- BER_BVZERO( &mod->sml_type );
- mod->sml_desc = slap_schema.si_ad_entryUUID;
- mod->sml_values =
- (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
- ber_dupbv( &mod->sml_values[0], &tmpval );
- BER_BVZERO( &mod->sml_values[1] );
- assert( !BER_BVISNULL( &mod->sml_values[0] ) );
- mod->sml_nvalues =
- (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
- (*mod->sml_desc->ad_type->sat_equality->smr_normalize)(
- SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
- mod->sml_desc->ad_type->sat_syntax,
- mod->sml_desc->ad_type->sat_equality,
- mod->sml_values, mod->sml_nvalues, NULL );
- BER_BVZERO( &mod->sml_nvalues[1] );
- *modtail = mod;
- modtail = &mod->sml_next;
- }
-
- mod = *modtail;
- if ( get_manageDIT( op ) ) {
- for ( mod = mods; mod != *modtail; mod = mod->sml_next ) {
- if ( mod->sml_desc == slap_schema.si_ad_creatorsName ) {
- break;
- }
- }
- }
-
- if ( mod == *modtail ) {
- mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
- mod->sml_op = mop;
- mod->sml_flags = SLAP_MOD_INTERNAL;
- mod->sml_next = NULL;
- BER_BVZERO( &mod->sml_type );
- mod->sml_desc = slap_schema.si_ad_creatorsName;
- mod->sml_values =
- (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
- ber_dupbv( &mod->sml_values[0], &name );
- BER_BVZERO( &mod->sml_values[1] );
- assert( !BER_BVISNULL( &mod->sml_values[0] ) );
- mod->sml_nvalues =
- (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
- ber_dupbv( &mod->sml_nvalues[0], &nname );
- BER_BVZERO( &mod->sml_nvalues[1] );
- assert( !BER_BVISNULL( &mod->sml_nvalues[0] ) );
- *modtail = mod;
- modtail = &mod->sml_next;
- }
-
- mod = *modtail;
- if ( get_manageDIT( op ) ) {
- for ( mod = mods; mod != *modtail; mod = mod->sml_next ) {
- if ( mod->sml_desc == slap_schema.si_ad_createTimestamp ) {
- break;
- }
- }
- }
-
- if ( mod == *modtail ) {
- mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
- mod->sml_op = mop;
- mod->sml_flags = SLAP_MOD_INTERNAL;
- mod->sml_next = NULL;
- BER_BVZERO( &mod->sml_type );
- mod->sml_desc = slap_schema.si_ad_createTimestamp;
- mod->sml_values =
- (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
- ber_dupbv( &mod->sml_values[0], ×tamp );
- BER_BVZERO( &mod->sml_values[1] );
- assert( !BER_BVISNULL( &mod->sml_values[0] ) );
- mod->sml_nvalues = NULL;
- *modtail = mod;
- modtail = &mod->sml_next;
- }
- }
- }
+ for ( mod = mods; mod->sml_next; mod = mod->sml_next )
+ ;
+ modtail = &mod->sml_next;
- if ( SLAP_LASTMOD( op->o_bd ) ) {
mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
- mod->sml_op = mop;
+ mod->sml_op = LDAP_MOD_REPLACE;
mod->sml_flags = SLAP_MOD_INTERNAL;
mod->sml_next = NULL;
BER_BVZERO( &mod->sml_type );
mod = *modtail;
if ( get_manageDIT( op ) ) {
- for ( mod = mods; mod != *modtail; mod = mod->sml_next ) {
+ for ( mod = mods; mod->sml_next; mod = mod->sml_next ) {
if ( mod->sml_desc == slap_schema.si_ad_modifiersName ) {
break;
}
if ( mod == *modtail ) {
mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
- mod->sml_op = mop;
+ mod->sml_op = LDAP_MOD_REPLACE;
mod->sml_flags = SLAP_MOD_INTERNAL;
mod->sml_next = NULL;
BER_BVZERO( &mod->sml_type );
mod = *modtail;
if ( get_manageDIT( op ) ) {
- for ( mod = mods; mod != *modtail; mod = mod->sml_next ) {
+ for ( mod = mods; mod->sml_next; mod = mod->sml_next ) {
if ( mod->sml_desc == slap_schema.si_ad_modifyTimestamp ) {
break;
}
if ( mod == *modtail ) {
mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
- mod->sml_op = mop;
+ mod->sml_op = LDAP_MOD_REPLACE;
mod->sml_flags = SLAP_MOD_INTERNAL;
mod->sml_next = NULL;
BER_BVZERO( &mod->sml_type );
BER_BVZERO( &mod->sml_values[1] );
assert( !BER_BVISNULL( &mod->sml_values[0] ) );
mod->sml_nvalues = NULL;
- *modtail = mod;
- modtail = &mod->sml_next;
}
}
-
- *modtail = NULL;
- return LDAP_SUCCESS;
}
rs->sr_err = frontendDB->be_modrdn( op, rs );
cleanup:
- slap_graduate_commit_csn( op );
-
op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
Modifications **pmod )
{
Modifications *mod = NULL;
- Modifications **modtail = &mod;
int a_cnt, d_cnt;
int repl_user;
done:
if ( rs->sr_err == LDAP_SUCCESS && !repl_user ) {
- char textbuf[ SLAP_TEXT_BUFLEN ];
- size_t textlen = sizeof textbuf;
-
- for( modtail = &mod;
- *modtail != NULL;
- modtail = &(*modtail)->sml_next )
- {
- /* empty */
- }
-
- rs->sr_err = slap_mods_opattrs( op, mod, modtail,
- &rs->sr_text, textbuf, textlen, 1 );
+ slap_mods_opattrs( op, mod, 1 );
}
/* LDAP v2 supporting correct attribute handling. */
ldap_pvt_thread_mutex_unlock( &slap_op_mutex );
}
+void
+slap_op_time(time_t *t, int *nop)
+{
+ *t = slap_get_time();
+ ldap_pvt_thread_mutex_lock( &slap_op_mutex );
+ if ( *t == last_time ) {
+ *nop = ++last_incr;
+ } else {
+ last_time = *t;
+ last_incr = 0;
+ *nop = 0;
+ }
+ ldap_pvt_thread_mutex_unlock( &slap_op_mutex );
+}
+
Operation *
slap_op_alloc(
BerElement *ber,
op->o_msgid = msgid;
op->o_tag = tag;
- op->o_time = slap_get_time();
- if ( op->o_time == last_time ) {
- op->o_tincr = ++last_incr;
- } else {
- last_time = op->o_time;
- last_incr = 0; /* o_tincr is alredy zero */
- }
+ slap_op_time( &op->o_time, &op->o_tincr );
op->o_opid = id;
op->o_res_ber = NULL;
int li_cycle;
struct re_s *li_task;
int li_success;
+ ldap_pvt_thread_mutex_t li_op_mutex;
+ ldap_pvt_thread_mutex_t li_log_mutex;
} log_info;
static ConfigDriver log_cf_gen;
Modifications *m;
struct berval *b;
time_t endtime;
- int i;
+ int i, nop;
int logop;
slap_verbmasks *lo;
Entry *e;
- char timebuf[LDAP_LUTIL_GENTIME_BUFSIZE];
+ char timebuf[LDAP_LUTIL_GENTIME_BUFSIZE+8];
struct berval bv;
char *ptr;
BerVarray vals;
if ( rs->sr_type != REP_RESULT && rs->sr_type != REP_EXTENDED )
return SLAP_CB_CONTINUE;
- if ( li->li_success && rs->sr_err != LDAP_SUCCESS )
- return SLAP_CB_CONTINUE;
-
switch ( op->o_tag ) {
case LDAP_REQ_ADD: logop = LOG_EN_ADD; break;
case LDAP_REQ_DELETE: logop = LOG_EN_DELETE; break;
if ( !( li->li_ops & lo->mask ))
return SLAP_CB_CONTINUE;
- endtime = slap_get_time();
+ if ( lo->mask & LOG_OP_WRITES ) {
+ ldap_pvt_thread_mutex_lock( &li->li_log_mutex );
+ ldap_pvt_thread_mutex_unlock( &li->li_op_mutex );
+ }
+
+ if ( li->li_success && rs->sr_err != LDAP_SUCCESS )
+ goto done;
+
+ slap_op_time( &endtime, &nop );
e = accesslog_entry( op, logop );
bv.bv_val = timebuf;
bv.bv_len = sizeof(timebuf);
slap_timestamp( &endtime, &bv );
+ sprintf( bv.bv_val + bv.bv_len-1, ".%06dZ", nop );
+ bv.bv_len += 7;
- attr_merge_one( e, ad_reqEnd, &bv, NULL );
+ attr_merge_normalize_one( e, ad_reqEnd, &bv, op->o_tmpmemctx );
attr_merge_one( e, ad_reqDN, &op->o_req_dn, &op->o_req_ndn );
op2.ora_e = e;
op2.o_callback = &nullsc;
- if ( lo->mask & LOG_OP_WRITES ) {
- slap_get_commit_csn( op, NULL, &bv );
- attr_merge_one( e, slap_schema.si_ad_entryCSN, &bv, NULL );
- slap_queue_csn( &op2, &bv );
+ if (( lo->mask & LOG_OP_WRITES ) && !BER_BVISEMPTY( &op->o_csn )) {
+ slap_queue_csn( &op2, &op->o_csn );
}
op2.o_bd->be_add( &op2, &rs2 );
- slap_graduate_commit_csn( &op2 );
entry_free( e );
+done:
+ ldap_pvt_thread_mutex_unlock( &li->li_log_mutex );
+ return SLAP_CB_CONTINUE;
+}
+
+static int
+accesslog_op_mod( Operation *op, SlapReply *rs )
+{
+ slap_overinst *on = (slap_overinst *)op->o_bd->bd_info;
+ log_info *li = on->on_bi.bi_private;
+
+ if ( li->li_ops & LOG_OP_WRITES ) {
+ /* FIXME: this needs to be a recursive mutex to allow
+ * overlays like refint to keep working.
+ */
+ ldap_pvt_thread_mutex_lock( &li->li_op_mutex );
+ }
return SLAP_CB_CONTINUE;
}
log_info *li = ch_calloc(1, sizeof(log_info));
on->on_bi.bi_private = li;
+ ldap_pvt_thread_mutex_init( &li->li_op_mutex );
+ ldap_pvt_thread_mutex_init( &li->li_log_mutex );
return 0;
}
slap_overinst *on = (slap_overinst *)be->bd_info;
log_info *li = on->on_bi.bi_private;
+ ldap_pvt_thread_mutex_destroy( &li->li_log_mutex );
+ ldap_pvt_thread_mutex_destroy( &li->li_op_mutex );
free( li );
return LDAP_SUCCESS;
}
accesslog.on_bi.bi_db_init = accesslog_db_init;
accesslog.on_bi.bi_db_destroy = accesslog_db_destroy;
+ accesslog.on_bi.bi_op_add = accesslog_op_mod;
+ accesslog.on_bi.bi_op_delete = accesslog_op_mod;
+ accesslog.on_bi.bi_op_modify = accesslog_op_mod;
+ accesslog.on_bi.bi_op_modrdn = accesslog_op_mod;
accesslog.on_bi.bi_op_unbind = accesslog_unbind;
accesslog.on_bi.bi_op_abandon = accesslog_abandon;
accesslog.on_response = accesslog_response;
char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
struct berval entryCSN;
- slap_get_csn( NULL, csnbuf, sizeof(csnbuf), &entryCSN, 0 );
+ entryCSN.bv_val = csnbuf;
+ entryCSN.bv_len = sizeof( csnbuf );
+ slap_get_csn( NULL, &entryCSN, 0 );
ber_dupbv( bv_entryCSN, &entryCSN );
ber_dupbv( bv_nentryCSN, &entryCSN );
timestamp.bv_len = sizeof(tmbuf);
slap_timestamp( &starttime, ×tamp );
- slap_get_csn( NULL, csnbuf, sizeof(csnbuf), &entryCSN, 0 );
+ entryCSN.bv_val = csnbuf;
+ entryCSN.bv_len = sizeof( csnbuf );
+ slap_get_csn( NULL, &entryCSN, 0 );
if ( BER_BVISNULL( &lmi->lmi_rdnvalue ) ) {
ber_str2bv( "Lastmod", 0, 1, &lmi->lmi_rdnvalue );
*/
for(dp = dd.mods; dp; dp = dp->next) {
- Modifications **tail, *m;
-
- for(m = dp->mm; m && m->sml_next; m = m->sml_next);
- tail = &m->sml_next;
nop.o_req_dn = dp->dn;
nop.o_req_ndn = dp->dn;
nop.o_bd = select_backend(&dp->dn, 0, 1);
nop.orm_modlist = dp->mm; /* callback did all the work */
nop.o_dn = refint_dn;
nop.o_ndn = refint_dn;
- rs->sr_err = slap_mods_opattrs( &nop, nop.orm_modlist,
- tail, &rs->sr_text, NULL, 0, 1 );
nop.o_dn = nop.o_bd->be_rootdn;
nop.o_ndn = nop.o_bd->be_rootndn;
if(rs->sr_err != LDAP_SUCCESS) goto done;
}
if ( BER_BVISEMPTY( &si->si_ctxcsn ) ) {
- slap_get_csn( op, si->si_ctxcsnbuf, sizeof(si->si_ctxcsnbuf),
- &si->si_ctxcsn, 0 );
+ si->si_ctxcsn.bv_len = sizeof( si->si_ctxcsnbuf );
+ slap_get_csn( op, &si->si_ctxcsn, 0 );
}
/* If our ctxcsn is different from what was read from the root
cb2.sc_private = qpw; /* let Modify know this was pwdMod,
* if it cares... */
- rs->sr_err = slap_mods_opattrs( op, ml, qpw->rs_modtail, &rs->sr_text,
- NULL, 0, 1 );
-
- if ( rs->sr_err == LDAP_SUCCESS ) {
- rs->sr_err = op->o_bd->be_modify( op, rs );
- }
+ rs->sr_err = op->o_bd->be_modify( op, rs );
if ( rs->sr_err == LDAP_SUCCESS ) {
rs->sr_rspdata = rsp;
} else if ( rsp ) {
LDAP_SLAPD_F (int) slap_entry2mods LDAP_P(( Entry *e,
Modifications **mods, const char **text,
char *textbuf, size_t textlen ));
+LDAP_SLAPD_F( int ) slap_add_opattrs(
+ Operation *op,
+ const char **text,
+ char *textbuf, size_t textlen,
+ int manage_ctxcsn );
+
/*
* at.c
LDAP_SLAPD_F (void) slap_rewind_commit_csn LDAP_P(( Operation * ));
LDAP_SLAPD_F (void) slap_graduate_commit_csn LDAP_P(( Operation * ));
LDAP_SLAPD_F (Entry *) slap_create_context_csn_entry LDAP_P(( Backend *, struct berval *));
-LDAP_SLAPD_F (int) slap_get_csn LDAP_P(( Operation *, char *, int, struct berval *, int ));
+LDAP_SLAPD_F (int) slap_get_csn LDAP_P(( Operation *, struct berval *, int ));
LDAP_SLAPD_F (void) slap_queue_csn LDAP_P(( Operation *, struct berval * ));
/*
time_t *tm,
struct berval *bv );
-LDAP_SLAPD_F( int ) slap_mods_opattrs(
+LDAP_SLAPD_F( void ) slap_mods_opattrs(
Operation *op,
Modifications *mods,
- Modifications **modlist,
- const char **text,
- char *textbuf, size_t textlen,
int manage_ctxcsn );
/*
LDAP_SLAPD_F (void) slap_op_init LDAP_P(( void ));
LDAP_SLAPD_F (void) slap_op_destroy LDAP_P(( void ));
LDAP_SLAPD_F (void) slap_op_free LDAP_P(( Operation *op ));
+LDAP_SLAPD_F (void) slap_op_time LDAP_P(( time_t *t, int *n ));
LDAP_SLAPD_F (Operation *) slap_op_alloc LDAP_P((
BerElement *ber, ber_int_t msgid,
ber_tag_t tag, ber_int_t id ));
op.o_tag = LDAP_REQ_SEARCH;
op.o_ndn = conn->c_ndn;
op.o_callback = &cb;
- op.o_time = slap_get_time();
+ slap_op_time( &op.o_time, &op.o_tincr );
op.o_do_not_cache = 1;
op.o_is_auth_check = 1;
op.o_req_dn = op.o_req_ndn;
&text, textbuf, textlen );
if ( rc == LDAP_SUCCESS ) {
- rc = slap_mods_opattrs( &op, modlist, modtail,
- &text, textbuf, textlen, 1 );
-
- if ( rc == LDAP_SUCCESS ) {
- op.o_hdr = conn->c_sasl_bindop->o_hdr;
- op.o_tag = LDAP_REQ_MODIFY;
- op.o_ndn = op.o_req_ndn;
- op.o_callback = &cb;
- op.o_time = slap_get_time();
- op.o_do_not_cache = 1;
- op.o_is_auth_check = 1;
- op.o_req_dn = op.o_req_ndn;
- op.orm_modlist = modlist;
-
- rc = op.o_bd->be_modify( &op, &rs );
- }
+ op.o_hdr = conn->c_sasl_bindop->o_hdr;
+ op.o_tag = LDAP_REQ_MODIFY;
+ op.o_ndn = op.o_req_ndn;
+ op.o_callback = &cb;
+ slap_op_time( &op.o_time, &op.o_tincr );
+ op.o_do_not_cache = 1;
+ op.o_is_auth_check = 1;
+ op.o_req_dn = op.o_req_ndn;
+ op.orm_modlist = modlist;
+
+ rc = op.o_bd->be_modify( &op, &rs );
}
}
slap_mods_free( modlist, 1 );
op.o_tag = LDAP_REQ_SEARCH;
op.o_ndn = *authc;
op.o_callback = &cb;
- op.o_time = slap_get_time();
+ slap_op_time( &op.o_time, &op.o_tincr );
op.o_do_not_cache = 1;
op.o_is_auth_check = 1;
/* use req_ndn as req_dn instead of non-pretty base of uri */
op.o_tag = LDAP_REQ_SEARCH;
op.o_ndn = opx->o_conn->c_ndn;
op.o_callback = &cb;
- op.o_time = slap_get_time();
+ slap_op_time( &op.o_time, &op.o_tincr );
op.o_do_not_cache = 1;
op.o_is_auth_check = 1;
op.ors_deref = LDAP_DEREF_NEVER;
BerElement *o_res_ber; /* ber of the CLDAP reply or readback control */
slap_callback *o_callback; /* callback pointers */
LDAPControl **o_ctrls; /* controls */
+ struct berval o_csn;
void *o_private; /* anything the backend needs */
PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_DELETE );
slapi_int_func_internal_pb( pb, op_delete );
- slap_graduate_commit_csn( pb->pb_op );
return 0;
}
}
cleanup:
- slap_graduate_commit_csn( pb->pb_op );
if ( pb->pb_op->ora_e != NULL ) {
slapi_entry_free( pb->pb_op->ora_e );
slapi_int_func_internal_pb( pb, op_modrdn );
cleanup:
- slap_graduate_commit_csn( pb->pb_op );
return 0;
}
slapi_int_func_internal_pb( pb, op_modify );
cleanup:
- slap_graduate_commit_csn( pb->pb_op );
return 0;
}
switch ( syncstate ) {
case LDAP_SYNC_ADD:
case LDAP_SYNC_MODIFY:
+ {
+ Attribute *a = attr_find( entry->e_attrs, slap_schema.si_ad_entryCSN );
+ if ( a )
+ op->o_csn = a->a_vals[0];
+ }
retry_add:;
if ( BER_BVISNULL( &dni.dn )) {
if ( !BER_BVISNULL( &dni.dn ) ) {
op->o_tmpfree( dni.dn.bv_val, op->o_tmpmemctx );
}
+ BER_BVZERO( &op->o_csn );
return ret;
}