1 /* sessionlog.c -- Session History Management Routines */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2003 The OpenLDAP Foundation.
6 * Portions Copyright 2003 IBM Corporation.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted only as authorized by the OpenLDAP
13 * A copy of this license is available in the file LICENSE in the
14 * top-level directory of the distribution or, alternatively, at
15 * <http://www.OpenLDAP.org/license.html>.
22 #include <ac/string.h>
23 #include <ac/socket.h>
28 #include "lutil_ldap.h"
31 slap_send_session_log(
38 AttributeName uuid_attr[2];
39 LDAPControl *ctrls[SLAP_MAX_RESPONSE_CONTROLS];
41 struct slog_entry *slog_e;
46 uuid_attr[0].an_desc = NULL;
47 uuid_attr[0].an_oc = NULL;
48 uuid_attr[0].an_name.bv_len = 0;
49 uuid_attr[0].an_name.bv_val = NULL;
52 e.e_name.bv_val = NULL;
54 e.e_nname.bv_val = NULL;
58 num_ctrls < SLAP_MAX_RESPONSE_CONTROLS;
60 ctrls[num_ctrls] = NULL;
64 LDAP_STAILQ_FOREACH( slog_e, &sop->o_sync_slog_list, sl_link ) {
66 if ( op->o_sync_state.ctxcsn->bv_val == NULL ) {
69 value_match( &match, slap_schema.si_ad_entryCSN,
70 slap_schema.si_ad_entryCSN->ad_type->sat_ordering,
71 SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
72 op->o_sync_state.ctxcsn, &slog_e->sl_csn, &text );
76 rs->sr_err = slap_build_sync_state_ctrl_from_slog( op, rs, slog_e,
77 LDAP_SYNC_DELETE, ctrls, num_ctrls++, 0, NULL );
79 if ( rs->sr_err != LDAP_SUCCESS )
82 if ( e.e_name.bv_val )
83 ch_free( e.e_name.bv_val );
84 ber_dupbv( &e.e_name, &slog_e->sl_name );
87 rs->sr_attrs = uuid_attr;
89 result = send_search_entry( op, rs );
90 sl_free( ctrls[num_ctrls-1]->ldctl_value.bv_val, op->o_tmpmemctx );
91 sl_free( ctrls[--num_ctrls], op->o_tmpmemctx );
92 ctrls[num_ctrls] = NULL;
105 struct slog_entry* slog_e;
108 slog_e = (struct slog_entry *) ch_calloc (1, sizeof( struct slog_entry ));
109 a = attr_find( e->e_attrs, slap_schema.si_ad_entryUUID );
110 ber_dupbv( &slog_e->sl_uuid, &a->a_nvals[0] );
111 ber_dupbv( &slog_e->sl_name, &e->e_name );
112 ber_dupbv( &slog_e->sl_csn, &op->o_sync_csn );
113 LDAP_STAILQ_INSERT_TAIL( &sop->o_sync_slog_list, slog_e, sl_link );
114 sop->o_sync_slog_len++;
116 while ( sop->o_sync_slog_len > sop->o_sync_slog_size ) {
117 slog_e = LDAP_STAILQ_FIRST( &sop->o_sync_slog_list );
118 if ( sop->o_sync_slog_omitcsn.bv_val ) {
119 ch_free( sop->o_sync_slog_omitcsn.bv_val );
121 ber_dupbv( &sop->o_sync_slog_omitcsn, &slog_e->sl_csn );
122 LDAP_STAILQ_REMOVE_HEAD( &sop->o_sync_slog_list, sl_link );
123 ch_free( slog_e->sl_uuid.bv_val );
124 ch_free( slog_e->sl_name.bv_val );
125 ch_free( slog_e->sl_csn.bv_val );
127 sop->o_sync_slog_len--;