]> git.sur5r.net Git - openldap/commitdiff
Merge op->o_sync_mode into op->o_sync
authorHoward Chu <hyc@openldap.org>
Thu, 25 Nov 2004 18:31:31 +0000 (18:31 +0000)
committerHoward Chu <hyc@openldap.org>
Thu, 25 Nov 2004 18:31:31 +0000 (18:31 +0000)
servers/slapd/back-bdb/ctxcsn.c
servers/slapd/back-sql/search.c
servers/slapd/controls.c
servers/slapd/daemon.c
servers/slapd/ldapsync.c
servers/slapd/overlays/syncprov.c
servers/slapd/slap.h

index 716ce8edbceb9fd7d2ca0949018dabf8f30b5593..f0a04117d9eb5af0836b487bb00fa81236df7870 100644 (file)
@@ -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 :
index 10af5af114131244ad71a99e6be19a1a08b19e3b..613fa4b54731ca4992be1469e783feaf59d324c6 100644 (file)
@@ -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;
index dccb75fbfbf06c199fc562ecf2ab9e51d554ab9b..faf48b0b12728eaa68255591b126f4eb47a8726c 100644 (file)
@@ -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;
 }
index b4755a80b2d6ce2e002ccb90c4ace6d34982eedc..206c401777c1dcb3575aa1c8c4566d7ddc36d085 100644 (file)
@@ -40,6 +40,8 @@
 
 #include "ldap_rq.h"
 
+#undef HAVE_EPOLL
+
 #if defined(HAVE_SYS_EPOLL_H) && defined(HAVE_EPOLL)
 #include <sys/epoll.h>
 #endif
index c0b916193666aa78780447c2de20611ae3e09564..e456ebc14f2ca182ec1b1339001471f2957338af 100644 (file)
@@ -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;
                }
        }
 
index e260d772559d7f98d4eaefbbcbbcd5ac40340f54..49122d92d41931669a5626e060827b4f913b2bdc 100644 (file)
@@ -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
index e2848762c2ba4baf0e90b876ac4d163e6a2da035..8f993fd1b1a5e24653d5b2c630fee62f9611a556 100644 (file)
@@ -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<<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;