]> git.sur5r.net Git - openldap/commitdiff
Use a single sessionlog per context, delete sid
authorHoward Chu <hyc@openldap.org>
Thu, 13 Jan 2005 19:51:01 +0000 (19:51 +0000)
committerHoward Chu <hyc@openldap.org>
Thu, 13 Jan 2005 19:51:01 +0000 (19:51 +0000)
servers/slapd/config.c
servers/slapd/ldapsync.c
servers/slapd/overlays/syncprov.c
servers/slapd/proto-slap.h
servers/slapd/slap.h
servers/slapd/slapadd.c
servers/slapd/syncrepl.c

index eeb395379ef59909de5f561e02720ef7bcb9cc6b..6a91564813dd3bd913aa9454d715e18633873bb2 100644 (file)
@@ -1669,7 +1669,6 @@ add_syncrepl(
        si->si_retrynum = NULL;
        si->si_syncCookie.ctxcsn = NULL;
        si->si_syncCookie.octet_str = NULL;
-       si->si_syncCookie.sid = -1;
        si->si_manageDSAit = 0;
        si->si_tlimit = 0;
        si->si_slimit = 0;
index 9d5867cd1cd2da034c6184bf47bb745a1601f1b4..748361d70a63b05e3bd5a289ab0e007d7ffba031 100644 (file)
@@ -39,45 +39,24 @@ slap_compose_sync_cookie(
        Operation *op,
        struct berval *cookie,
        struct berval *csn,
-       int sid,
        int rid )
 {
        char cookiestr[ LDAP_LUTIL_CSNSTR_BUFSIZE + 20 ];
 
        if ( csn->bv_val == NULL ) {
-               if ( sid == -1 ) {
-                       if ( rid == -1 ) {
-                               cookiestr[0] = '\0';
-                       } else {
-                               snprintf( cookiestr, LDAP_LUTIL_CSNSTR_BUFSIZE + 20,
-                                               "rid=%03d", rid );
-                       }
+               if ( rid == -1 ) {
+                       cookiestr[0] = '\0';
                } else {
-                       if ( rid == -1 ) {
-                               snprintf( cookiestr, LDAP_LUTIL_CSNSTR_BUFSIZE + 20,
-                                               "sid=%03d", sid );
-                       } else {
-                               snprintf( cookiestr, LDAP_LUTIL_CSNSTR_BUFSIZE + 20,
-                                               "sid=%03d,rid=%03d", sid, rid );
-                       }
+                       snprintf( cookiestr, LDAP_LUTIL_CSNSTR_BUFSIZE + 20,
+                                       "rid=%03d", rid );
                }
        } else {
-               if ( sid == -1 ) {
-                       if ( rid == -1 ) {
-                               snprintf( cookiestr, LDAP_LUTIL_CSNSTR_BUFSIZE + 20,
-                                               "csn=%s", csn->bv_val );
-                       } else {
-                               snprintf( cookiestr, LDAP_LUTIL_CSNSTR_BUFSIZE + 20,
-                                               "csn=%s,rid=%03d", csn->bv_val, rid );
-                       }
+               if ( rid == -1 ) {
+                       snprintf( cookiestr, LDAP_LUTIL_CSNSTR_BUFSIZE + 20,
+                                       "csn=%s", csn->bv_val );
                } else {
-                       if ( rid == -1 ) {
-                               snprintf( cookiestr, LDAP_LUTIL_CSNSTR_BUFSIZE + 20,
-                                               "csn=%s,sid=%03d", csn->bv_val, sid );
-                       } else {
-                               snprintf( cookiestr, LDAP_LUTIL_CSNSTR_BUFSIZE + 20,
-                                               "csn=%s,sid=%03d,rid=%03d", csn->bv_val, sid, rid );
-                       }
+                       snprintf( cookiestr, LDAP_LUTIL_CSNSTR_BUFSIZE + 20,
+                                       "csn=%s,rid=%03d", csn->bv_val, rid );
                }
        }
        ber_str2bv( cookiestr, strlen(cookiestr), 1, cookie );
@@ -118,8 +97,6 @@ slap_parse_sync_cookie(
        char *csn_str;
        int csn_str_len;
        int valid = 0;
-       char *sid_ptr;
-       char *sid_str;
        char *rid_ptr;
        char *rid_str;
        char *cval;
@@ -159,18 +136,6 @@ slap_parse_sync_cookie(
                cookie->ctxcsn = NULL;
        }
 
-       if (( sid_ptr = strstr( cookie->octet_str->bv_val, "sid=" )) != NULL ) {
-               sid_str = SLAP_STRNDUP( sid_ptr,
-                                                       SLAP_SYNC_SID_SIZE + sizeof("sid=") - 1 );
-               if ( (cval = strchr( sid_str, ',' )) != NULL ) {
-                       *cval = '\0';
-               }
-               cookie->sid = atoi( sid_str + sizeof("sid=") - 1 );
-               ch_free( sid_str );
-       } else {
-               cookie->sid = -1;
-       }
-
        if (( rid_ptr = strstr( cookie->octet_str->bv_val, "rid=" )) != NULL ) {
                rid_str = SLAP_STRNDUP( rid_ptr,
                                                        SLAP_SYNC_RID_SIZE + sizeof("rid=") - 1 );
@@ -238,7 +203,6 @@ slap_dup_sync_cookie(
                                ch_calloc( 1, sizeof( struct sync_cookie ));
        }
 
-       new->sid = src->sid;
        new->rid = src->rid;
 
        if ( src->ctxcsn ) {
index fcb25fc175b9d3ea9d2cfcba5972941d8099ffe8..99d5cdb1bf2027e68c688ec663ceb4600849e44f 100644 (file)
@@ -56,7 +56,6 @@ typedef struct syncops {
        struct berval   s_base;         /* ndn of search base */
        ID              s_eid;          /* entryID of search base */
        Operation       *s_op;          /* search op */
-       int             s_sid;
        int             s_rid;
        struct berval s_filterstr;
        int             s_flags;        /* search status */
@@ -101,8 +100,6 @@ typedef struct slog_entry {
 } slog_entry;
 
 typedef struct sessionlog {
-       struct sessionlog *sl_next;
-       int             sl_sid;
        struct berval   sl_mincsn;
        int             sl_num;
        int             sl_size;
@@ -771,8 +768,7 @@ syncprov_sendresp( Operation *op, opcookie *opc, syncops *so, Entry *e, int mode
        }
 
        ctrls[1] = NULL;
-       slap_compose_sync_cookie( op, &cookie, &opc->sctxcsn,
-               so->s_sid, so->s_rid );
+       slap_compose_sync_cookie( op, &cookie, &opc->sctxcsn, so->s_rid );
 
        e_uuid.e_attrs = &a_uuid;
        a_uuid.a_desc = slap_schema.si_ad_entryUUID;
@@ -1097,7 +1093,7 @@ syncprov_add_slog( Operation *op, struct berval *csn )
        sessionlog *sl;
        slog_entry *se;
 
-       for ( sl = si->si_logs; sl; sl=sl->sl_next ) {
+       for ( sl = si->si_logs; sl; ) {
                /* Allocate a record. UUIDs are not NUL-terminated. */
                se = ch_malloc( sizeof( slog_entry ) + opc->suuid.bv_len + 
                        csn->bv_len + 1 );
@@ -1626,7 +1622,7 @@ syncprov_search_response( Operation *op, SlapReply *rs )
 
                slap_compose_sync_cookie( op, &cookie,
                        &op->ors_filter->f_and->f_ava->aa_value,
-                       srs->sr_state.sid, srs->sr_state.rid );
+                       srs->sr_state.rid );
 
                /* Is this a regular refresh? */
                if ( !ss->ss_so ) {
@@ -1746,7 +1742,6 @@ syncprov_op_search( Operation *op, SlapReply *rs )
                sop = ch_malloc( sizeof( syncops ));
                *sop = so;
                ldap_pvt_thread_mutex_init( &sop->s_mutex );
-               sop->s_sid = srs->sr_state.sid;
                sop->s_rid = srs->sr_state.rid;
                sop->s_inuse = 1;
 
@@ -1788,8 +1783,7 @@ syncprov_op_search( Operation *op, SlapReply *rs )
                        goto shortcut;
                }
                /* Do we have a sessionlog for this search? */
-               for ( sl=si->si_logs; sl; sl=sl->sl_next )
-                       if ( sl->sl_sid == srs->sr_state.sid ) break;
+               sl=si->si_logs;
                if ( sl ) {
                        ldap_pvt_thread_mutex_lock( &sl->sl_mutex );
                        if ( ber_bvcmp( srs->sr_state.ctxcsn, &sl->sl_mincsn ) >= 0 ) {
@@ -1947,44 +1941,30 @@ syncprov_db_config(
 
        } else if ( strcasecmp( argv[0], "syncprov-sessionlog" ) == 0 ) {
                sessionlog *sl;
-               int sid, size;
-               if ( argc != 3 ) {
+               int size;
+               if ( argc != 2 ) {
                        fprintf( stderr, "%s: line %d: wrong number of arguments in "
-                               "\"syncprov-sessionlog <sid> <size>\"\n", fname, lineno );
-                       return -1;
-               }
-               sid = atoi( argv[1] );
-               if ( sid < 0 || sid > 999 ) {
-                       fprintf( stderr,
-                               "%s: line %d: session log id %d is out of range [0..999]\n",
-                               fname, lineno, sid );
+                               "\"syncprov-sessionlog <size>\"\n", fname, lineno );
                        return -1;
                }
-               size = atoi( argv[2] );
+               size = atoi( argv[1] );
                if ( size < 0 ) {
                        fprintf( stderr,
                                "%s: line %d: session log size %d is negative\n",
                                fname, lineno, size );
                        return -1;
                }
-               for ( sl = si->si_logs; sl; sl=sl->sl_next ) {
-                       if ( sl->sl_sid == sid ) {
-                               sl->sl_size = size;
-                               break;
-                       }
-               }
+               sl = si->si_logs;
                if ( !sl ) {
                        sl = ch_malloc( sizeof( sessionlog ) + LDAP_LUTIL_CSNSTR_BUFSIZE );
                        sl->sl_mincsn.bv_val = (char *)(sl+1);
                        sl->sl_mincsn.bv_len = 0;
-                       sl->sl_sid = sid;
-                       sl->sl_size = size;
                        sl->sl_num = 0;
                        sl->sl_head = sl->sl_tail = NULL;
-                       sl->sl_next = si->si_logs;
                        ldap_pvt_thread_mutex_init( &sl->sl_mutex );
                        si->si_logs = sl;
                }
+               sl->sl_size = size;
                return 0;
        }
 
index fba93ea7dfe45a6ce5af19baf01d24d52ba32c39..2f91d7928f2deb98a6a1a3a35ddcfe6020a60585 100644 (file)
@@ -753,7 +753,7 @@ LDAP_SLAPD_V (int)  krbv4_ldap_auth();
  * ldapsync.c
  */
 LDAP_SLAPD_F (void) slap_compose_sync_cookie LDAP_P((
-                               Operation *, struct berval *, struct berval *, int, int ));
+                               Operation *, struct berval *, struct berval *, int ));
 LDAP_SLAPD_F (void) slap_sync_cookie_free LDAP_P((
                                struct sync_cookie *, int free_cookie ));
 LDAP_SLAPD_F (int) slap_parse_sync_cookie LDAP_P((
index 265962596ade81263ebe81a9b9b6124547f21ee5..380ee9a53ef1e0e2b8a519151e26cff79f3c30b4 100644 (file)
@@ -1465,7 +1465,6 @@ struct nonpresent_entry {
 
 struct sync_cookie {
        struct berval *ctxcsn;
-       long sid;
        struct berval *octet_str;
        long rid;
        LDAP_STAILQ_ENTRY(sync_cookie) sc_next;
index cdc10e76d61ddaa5f7cfd35c33b549e6451876e0..5616b44fb9bf20c6f90dfe8a15cfa777b88aef42 100644 (file)
@@ -472,7 +472,7 @@ done:;
                }
        }
 
-       slap_compose_sync_cookie( NULL, &mc, &maxcsn, -1, -1 );
+       slap_compose_sync_cookie( NULL, &mc, &maxcsn, -1 );
 
        if ( SLAP_LASTMOD(be) && replica_promotion ) {
                if ( provider_subentry || update_ctxcsn == SLAP_TOOL_CTXCSN_BATCH ||
index a4d2e7c3d60fa2e7c0ac8e197f4f26111213b9e2..50b1dc49f3853f92b62eda76b687a39203f48685 100644 (file)
@@ -444,10 +444,6 @@ do_syncrep1(
                        ber_bvarray_free( si->si_syncCookie.octet_str );
                        si->si_syncCookie.octet_str = NULL;
                        ber_bvarray_free_x( cookie, op->o_tmpmemctx );
-                       if ( sc->sid != -1 ) {
-                               /* command line cookie wins */
-                               si->si_syncCookie.sid = sc->sid;
-                       }
                        if ( sc->ctxcsn != NULL ) {
                                /* command line cookie wins */
                                if ( si->si_syncCookie.ctxcsn ) {
@@ -465,7 +461,7 @@ do_syncrep1(
                        sc = NULL;
                        slap_compose_sync_cookie( NULL, &newcookie,
                                        &si->si_syncCookie.ctxcsn[0],
-                                       si->si_syncCookie.sid, si->si_syncCookie.rid );
+                                       si->si_syncCookie.rid );
                        ber_bvarray_add( &si->si_syncCookie.octet_str, &newcookie );
                }
 
@@ -527,8 +523,8 @@ do_syncrep2(
 
        int             syncstate;
        struct berval   syncUUID = BER_BVNULL;
-       struct sync_cookie      syncCookie = { NULL, -1, NULL };
-       struct sync_cookie      syncCookie_req = { NULL, -1, NULL };
+       struct sync_cookie      syncCookie = { NULL };
+       struct sync_cookie      syncCookie_req = { NULL };
        struct berval           cookie = BER_BVNULL;
 
        int     rc, err, i;