From: Howard Chu Date: Thu, 13 Jan 2005 19:51:01 +0000 (+0000) Subject: Use a single sessionlog per context, delete sid X-Git-Tag: OPENLDAP_REL_ENG_2_3_BP~392 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=93c56951edb85cdbfc7a4a777abd7d21372ddfba;p=openldap Use a single sessionlog per context, delete sid --- diff --git a/servers/slapd/config.c b/servers/slapd/config.c index eeb395379e..6a91564813 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -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; diff --git a/servers/slapd/ldapsync.c b/servers/slapd/ldapsync.c index 9d5867cd1c..748361d70a 100644 --- a/servers/slapd/ldapsync.c +++ b/servers/slapd/ldapsync.c @@ -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 ) { diff --git a/servers/slapd/overlays/syncprov.c b/servers/slapd/overlays/syncprov.c index fcb25fc175..99d5cdb1bf 100644 --- a/servers/slapd/overlays/syncprov.c +++ b/servers/slapd/overlays/syncprov.c @@ -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 \"\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 \"\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; } diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index fba93ea7df..2f91d7928f 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -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(( diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 265962596a..380ee9a53e 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -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; diff --git a/servers/slapd/slapadd.c b/servers/slapd/slapadd.c index cdc10e76d6..5616b44fb9 100644 --- a/servers/slapd/slapadd.c +++ b/servers/slapd/slapadd.c @@ -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 || diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index a4d2e7c3d6..50b1dc49f3 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -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;