syncinfo_t *si;
u_int32_t ctxcsn_locker = 0;
- if ( op->o_sync_mode != SLAP_SYNC_NONE &&
+ if ( (op->o_sync_mode & SLAP_SYNC_REFRESH) &&
!LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
char substr[67];
struct berval ctxcsn_ndn = BER_BVNULL;
*search_context_csn = NULL;
}
}
- } else if ( op->o_sync_mode != SLAP_SYNC_NONE &&
+ } else if ( (op->o_sync_mode & SLAP_SYNC_REFRESH) &&
LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
provider_ctxcsn_retry :
* TODO: introduce appropriate entryCSN filtering
* to support syncrepl as producer...
*/
- if ( bsi->bsi_op->o_sync_mode != SLAP_SYNC_REFRESH ) {
+ if ( bsi->bsi_op->o_sync_mode & SLAP_SYNC_PERSIST ) {
/* unsupported at present... */
bsi->bsi_status = LDAP_OTHER;
rc = -1;
(void) ber_free( ber, 1 );
- op->o_sync_mode = (char) mode;
-
op->o_sync = ctrl->ldctl_iscritical
? SLAP_CONTROL_CRITICAL
: SLAP_CONTROL_NONCRITICAL;
+ op->o_sync_mode |= mode; /* o_sync_mode shares o_sync */
+
return LDAP_SUCCESS;
}
#include "ldap_rq.h"
+#undef HAVE_EPOLL
+
#if defined(HAVE_SYS_EPOLL_H) && defined(HAVE_EPOLL)
#include <sys/epoll.h>
#endif
for ( a = e->e_attrs; a != NULL; a = a->a_next ) {
AttributeDescription *desc = a->a_desc;
if ( desc == slap_schema.si_ad_entryUUID ) {
- ber_dupbv( &entryuuid_bv, &a->a_nvals[0] );
+ entryuuid_bv = a->a_nvals[0];
+ break;
}
}
entry_sync_state, &entryuuid_bv );
}
- ch_free( entryuuid_bv.bv_val );
- entryuuid_bv.bv_val = NULL;
-
ctrls[num_ctrls]->ldctl_oid = LDAP_CONTROL_SYNC_STATE;
- ctrls[num_ctrls]->ldctl_iscritical = op->o_sync;
+ ctrls[num_ctrls]->ldctl_iscritical = (op->o_sync == SLAP_CONTROL_CRITICAL);
ret = ber_flatten2( ber, &ctrls[num_ctrls]->ldctl_value, 1 );
ber_free_buf( ber );
ber_printf( ber, "N}" );
ctrls[num_ctrls]->ldctl_oid = LDAP_CONTROL_SYNC_DONE;
- ctrls[num_ctrls]->ldctl_iscritical = op->o_sync;
+ ctrls[num_ctrls]->ldctl_iscritical = (op->o_sync == SLAP_CONTROL_CRITICAL);
ret = ber_flatten2( ber, &ctrls[num_ctrls]->ldctl_value, 1 );
ber_free_buf( ber );
ctrls[num_ctrls] = ch_malloc ( sizeof ( LDAPControl ) );
- ber_dupbv( &entryuuid_bv, &slog_e->sl_uuid );
+ entryuuid_bv = slog_e->sl_uuid;
if ( send_cookie && cookie ) {
ber_printf( ber, "{eOON}",
entry_sync_state, &entryuuid_bv );
}
- ch_free( entryuuid_bv.bv_val );
- entryuuid_bv.bv_val = NULL;
-
ctrls[num_ctrls]->ldctl_oid = LDAP_CONTROL_SYNC_STATE;
- ctrls[num_ctrls]->ldctl_iscritical = op->o_sync;
+ ctrls[num_ctrls]->ldctl_iscritical = (op->o_sync == SLAP_CONTROL_CRITICAL);
ret = ber_flatten2( ber, &ctrls[num_ctrls]->ldctl_value, 1 );
ber_free_buf( ber );
cookie->octet_str = NULL;
ber_bvarray_add( &cookie->octet_str, &slap_syncCookie );
- ber_dupbv( &ctxcsn, &octet_str );
- ctxcsn.bv_val += 4;
- ctxcsn.bv_len -= 4;
+ ctxcsn.bv_val = octet_str.bv_val + 4;
+ ctxcsn.bv_len = octet_str.bv_len - 4;
ber_dupbv( &ctxcsn_dup, &ctxcsn );
- ch_free( ctxcsn.bv_val );
ber_bvarray_add( &cookie->ctxcsn, &ctxcsn_dup );
return 0;
AttributeDescription *desc = a->a_desc;
if ( desc == slap_schema.si_ad_entryUUID ) {
ber_dupbv_x( &entryuuid_bv, &a->a_nvals[0], op->o_tmpmemctx );
+ break;
}
}
cb.sc_response = findbase_cb;
cb.sc_private = fc;
- fop.o_sync_mode = 0;
+ fop.o_sync_mode &= SLAP_CONTROL_MASK; /* turn off sync mode */
fop.o_callback = &cb;
fop.o_tag = LDAP_REQ_SEARCH;
fop.ors_scope = LDAP_SCOPE_BASE;
}
fop = *op;
- fop.o_sync_mode = 0;
+ fop.o_sync_mode &= SLAP_CONTROL_MASK; /* turn off sync_mode */
fbuf.bv_val = buf;
if ( mode == FIND_CSN ) {
a_uuid.a_nvals = &opc->suuid;
rs.sr_err = slap_build_sync_state_ctrl( &sop, &rs, &e_uuid,
mode, ctrls, 0, 1, &cookie );
+
rs.sr_entry = e;
rs.sr_ctrls = ctrls;
switch( mode ) {
op->o_tmpfree( rs->sr_ctrls, op->o_tmpmemctx );
}
if ( ss->ss_done )
- op->o_sync_mode = SLAP_SYNC_REFRESH_AND_PERSIST;
+ op->o_sync_mode |= SLAP_SYNC_REFRESH_AND_PERSIST;
return 0;
}
syncops *sop = NULL;
searchstate *ss;
- if ( !op->o_sync_mode ) return SLAP_CB_CONTINUE;
+ if ( !(op->o_sync_mode & SLAP_SYNC_REFRESH) ) return SLAP_CB_CONTINUE;
if ( op->ors_deref & LDAP_DEREF_SEARCHING ) {
send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR, "illegal value for derefAliases" );
}
/* If this is a persistent search, set it up right away */
- if ( op->o_sync_mode == SLAP_SYNC_REFRESH_AND_PERSIST ) {
+ if ( op->o_sync_mode & SLAP_SYNC_PERSIST ) {
syncops so;
fbase_cookie fc;
opcookie opc;
/* If just Refreshing and nothing has changed, shortcut it */
if ( bvmatch( op->o_sync_state.ctxcsn, &si->si_ctxcsn )) {
nochange = 1;
- if ( op->o_sync_mode == SLAP_SYNC_REFRESH ) {
+ if ( !(op->o_sync_mode & SLAP_SYNC_PERSIST) ) {
LDAPControl *ctrls[2];
ctrls[0] = NULL;
* doesn't get invoked. We can skip this after the back-bdb code is
* removed, and also delete ss->ss_done.
*/
- op->o_sync_mode = 0;
+ op->o_sync_mode &= SLAP_CONTROL_MASK;
/* If this is a persistent search and no changes were reported during
* the refresh phase, just invoke the response callback to transition
#define SLAP_CONTROL_MASK 3
/* spare bits for simple flags */
+#define SLAP_CONTROL_SHIFT 4 /* shift to reach data bits */
#define SLAP_CONTROL_DATA0 0x10
#define SLAP_CONTROL_DATA1 0x20
#define SLAP_CONTROL_DATA2 0x40
#define get_pagedresults(op) ((int)(op)->o_pagedresults)
#define o_sync o_ctrlflag[slap_cids.sc_LDAPsync]
+ /* o_sync_mode uses data bits of o_sync */
+#define o_sync_mode o_ctrlflag[slap_cids.sc_LDAPsync]
- char o_sync_mode;
-#define SLAP_SYNC_NONE LDAP_SYNC_NONE
-#define SLAP_SYNC_REFRESH LDAP_SYNC_REFRESH_ONLY
-#define SLAP_SYNC_PERSIST LDAP_SYNC_RESERVED
-#define SLAP_SYNC_REFRESH_AND_PERSIST LDAP_SYNC_REFRESH_AND_PERSIST
+#define SLAP_SYNC_NONE (LDAP_SYNC_NONE<<SLAP_CONTROL_SHIFT)
+#define SLAP_SYNC_REFRESH (LDAP_SYNC_REFRESH_ONLY<<SLAP_CONTROL_SHIFT)
+#define SLAP_SYNC_PERSIST (LDAP_SYNC_RESERVED<<SLAP_CONTROL_SHIFT)
+#define SLAP_SYNC_REFRESH_AND_PERSIST (LDAP_SYNC_REFRESH_AND_PERSIST<<SLAP_CONTROL_SHIFT)
struct sync_cookie o_sync_state;
int o_sync_rhint;
struct berval o_sync_cid;