From: Howard Chu Date: Thu, 25 Nov 2004 18:31:31 +0000 (+0000) Subject: Merge op->o_sync_mode into op->o_sync X-Git-Tag: OPENLDAP_REL_ENG_2_3_0ALPHA~225 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=618cc562654ef66429b90a5362d94dc995b0eb18;p=openldap Merge op->o_sync_mode into op->o_sync --- diff --git a/servers/slapd/back-bdb/ctxcsn.c b/servers/slapd/back-bdb/ctxcsn.c index 716ce8edbc..f0a04117d9 100644 --- a/servers/slapd/back-bdb/ctxcsn.c +++ b/servers/slapd/back-bdb/ctxcsn.c @@ -262,7 +262,7 @@ bdb_get_commit_csn( 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; @@ -332,7 +332,7 @@ consumer_ctxcsn_retry : *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 : diff --git a/servers/slapd/back-sql/search.c b/servers/slapd/back-sql/search.c index 10af5af114..613fa4b547 100644 --- a/servers/slapd/back-sql/search.c +++ b/servers/slapd/back-sql/search.c @@ -676,7 +676,7 @@ backsql_process_filter( backsql_srch_info *bsi, Filter *f ) * 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; diff --git a/servers/slapd/controls.c b/servers/slapd/controls.c index dccb75fbfb..faf48b0b12 100644 --- a/servers/slapd/controls.c +++ b/servers/slapd/controls.c @@ -1372,11 +1372,11 @@ static int parseLDAPsync ( (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; } diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index b4755a80b2..206c401777 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -40,6 +40,8 @@ #include "ldap_rq.h" +#undef HAVE_EPOLL + #if defined(HAVE_SYS_EPOLL_H) && defined(HAVE_EPOLL) #include #endif diff --git a/servers/slapd/ldapsync.c b/servers/slapd/ldapsync.c index c0b9161936..e456ebc14f 100644 --- a/servers/slapd/ldapsync.c +++ b/servers/slapd/ldapsync.c @@ -63,7 +63,8 @@ slap_build_sync_state_ctrl( 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; } } @@ -75,11 +76,8 @@ slap_build_sync_state_ctrl( 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 ); @@ -124,7 +122,7 @@ slap_build_sync_done_ctrl( 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 ); @@ -167,7 +165,7 @@ slap_build_sync_state_ctrl_from_slog( 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}", @@ -177,11 +175,8 @@ slap_build_sync_state_ctrl_from_slog( 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 ); @@ -430,11 +425,9 @@ slap_init_sync_cookie_ctxcsn( 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; @@ -498,6 +491,7 @@ slap_build_syncUUID_set( 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; } } diff --git a/servers/slapd/overlays/syncprov.c b/servers/slapd/overlays/syncprov.c index e260d77255..49122d92d4 100644 --- a/servers/slapd/overlays/syncprov.c +++ b/servers/slapd/overlays/syncprov.c @@ -146,7 +146,7 @@ syncprov_findbase( Operation *op, fbase_cookie *fc ) 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; @@ -300,7 +300,7 @@ syncprov_findcsn( Operation *op, int mode ) } 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 ) { @@ -402,6 +402,7 @@ syncprov_sendresp( Operation *op, opcookie *opc, syncops *so, Entry *e, int mode 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 ) { @@ -710,7 +711,7 @@ syncprov_search_cleanup( Operation *op, SlapReply *rs ) 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; } @@ -783,7 +784,7 @@ syncprov_op_search( Operation *op, SlapReply *rs ) 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" ); @@ -791,7 +792,7 @@ syncprov_op_search( Operation *op, SlapReply *rs ) } /* 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; @@ -844,7 +845,7 @@ syncprov_op_search( Operation *op, SlapReply *rs ) /* 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; @@ -922,7 +923,7 @@ shortcut: * 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 diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index e2848762c2..8f993fd1b1 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -2230,6 +2230,7 @@ typedef struct slap_op { #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 @@ -2295,12 +2296,13 @@ typedef struct slap_op { #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<