From: Kurt Zeilenga Date: Mon, 10 Sep 2001 01:37:32 +0000 (+0000) Subject: Import for slurpd millionth second bug (ITS#1323) X-Git-Tag: OPENLDAP_REL_ENG_2_0_14~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=af82e8ada224c5754016982ec4dc583348d10cf8;p=thirdparty%2Fopenldap.git Import for slurpd millionth second bug (ITS#1323) --- diff --git a/CHANGES b/CHANGES index e23870f7a2..107d262dd5 100644 --- a/CHANGES +++ b/CHANGES @@ -1,7 +1,7 @@ OpenLDAP 2.0 Change Log OpenLDAP 2.0.14 Engineering - + Fixed slurpd millionth second bug (ITS#1323) OpenLDAP 2.0.13 Release Fixed slapd substring filter_free bug diff --git a/servers/slurpd/re.c b/servers/slurpd/re.c index 2718ede4e8..400b8fecd6 100644 --- a/servers/slurpd/re.c +++ b/servers/slurpd/re.c @@ -84,7 +84,6 @@ Re_free( ldap_pvt_thread_mutex_destroy( &re->re_mutex ); - ch_free( re->re_timestamp ); if (( rh = re->re_replicas ) != NULL ) { for ( i = 0; rh[ i ].rh_hostname != NULL; i++ ) { free( rh[ i ].rh_hostname ); @@ -176,7 +175,7 @@ Re_parse( /* there was a sequence number */ *p++ = '\0'; } - re->re_timestamp = strdup( value ); + re->re_timestamp = atol( value ); if ( p != NULL && isdigit( (unsigned char) *p )) { re->re_seq = atoi( p ); } @@ -459,7 +458,7 @@ Re_dump( } fprintf( fp, "Re_dump: ******\n" ); fprintf( fp, "re_refcnt: %d\n", re->re_refcnt ); - fprintf( fp, "re_timestamp: %s\n", re->re_timestamp ); + fprintf( fp, "re_timestamp: %ld\n", (long) re->re_timestamp ); fprintf( fp, "re_seq: %d\n", re->re_seq ); for ( i = 0; re->re_replicas && re->re_replicas[ i ].rh_hostname != NULL; i++ ) { @@ -545,7 +544,7 @@ Re_write( } } } - if ( fprintf( fp, "time: %s.%d\n", re->re_timestamp, re->re_seq ) < 0 ) { + if ( fprintf( fp, "time: %ld.%d\n", (long) re->re_timestamp, re->re_seq ) < 0 ) { rc = -1; goto bad; } @@ -709,7 +708,7 @@ Re_init( /* Initialize private data */ (*re)->re_refcnt = sglob->num_replicas; - (*re)->re_timestamp = NULL; + (*re)->re_timestamp = (time_t) 0L; (*re)->re_replicas = NULL; (*re)->re_dn = NULL; (*re)->re_changetype = 0; diff --git a/servers/slurpd/ri.c b/servers/slurpd/ri.c index f22da31626..78b8f75335 100644 --- a/servers/slurpd/ri.c +++ b/servers/slurpd/ri.c @@ -234,12 +234,12 @@ isnew( Re *re ) { - int x; + long x; int ret; /* Lock the St struct to avoid a race */ sglob->st->st_lock( sglob->st ); - x = strcmp( re->re_timestamp, ri->ri_stel->last ); + x = re->re_timestamp - ri->ri_stel->last; if ( x > 0 ) { /* re timestamp is newer */ ret = 1; diff --git a/servers/slurpd/rq.c b/servers/slurpd/rq.c index 1706ac0222..79fec15253 100644 --- a/servers/slurpd/rq.c +++ b/servers/slurpd/rq.c @@ -183,7 +183,7 @@ Rq_add( /* set the sequence number */ re->re_seq = 0; - if ( !wasempty && !strcmp(rq->rq_tail->re_timestamp, re->re_timestamp )) { + if ( !wasempty && ( rq->rq_tail->re_timestamp == re->re_timestamp )) { /* * Our new re has the same timestamp as the tail's timestamp. * Increment the seq number in the tail and use it as our seq number. diff --git a/servers/slurpd/slurp.h b/servers/slurpd/slurp.h index 6dcd42554f..c5c405c2e3 100644 --- a/servers/slurpd/slurp.h +++ b/servers/slurpd/slurp.h @@ -255,7 +255,7 @@ struct re { ldap_pvt_thread_mutex_t re_mutex; /* mutex for this Re */ int re_refcnt; /* ref count, 0 = done */ - char *re_timestamp; /* timestamp of this re */ + time_t re_timestamp; /* timestamp of this re */ int re_seq; /* sequence number */ Rh *re_replicas; /* array of replica info */ char *re_dn; /* dn of entry being modified */ @@ -325,7 +325,7 @@ struct rq { typedef struct stel { char *hostname; /* host name of replica */ int port; /* port number of replica */ - char last[ 64 ]; /* timestamp of last successful repl */ + time_t last; /* timestamp of last successful repl */ int seq; /* Sequence number of last repl */ } Stel; diff --git a/servers/slurpd/st.c b/servers/slurpd/st.c index f0addb7fa6..347fff3026 100644 --- a/servers/slurpd/st.c +++ b/servers/slurpd/st.c @@ -63,7 +63,7 @@ St_add( st->st_data[ ind ]->hostname = strdup( ri->ri_hostname ); st->st_data[ ind ]->port = ri->ri_port; - memset( st->st_data[ ind ]->last, '\0', sizeof( st->st_data[ ind ]->last )); + st->st_data[ ind ]->last = 0; st->st_data[ ind ]->seq = 0; ldap_pvt_thread_mutex_unlock( &(st->st_mutex )); @@ -110,8 +110,9 @@ St_write ( fseek( st->st_fp, 0L, 0 ); for ( i = 0; i < st->st_nreplicas; i++ ) { stel = st->st_data[ i ]; - fprintf( st->st_fp, "%s:%d:%s:%d\n", stel->hostname, stel->port, - stel->last, stel->seq ); + fprintf( st->st_fp, "%s:%d:%ld:%d\n", + stel->hostname, stel->port, + (long) stel->last, stel->seq ); } fflush( st->st_fp ); @@ -138,7 +139,7 @@ St_update( } ldap_pvt_thread_mutex_lock( &(st->st_mutex )); - strcpy( stel->last, re->re_timestamp ); + stel->last = re->re_timestamp; stel->seq = re->re_seq; ldap_pvt_thread_mutex_unlock( &(st->st_mutex )); return 0; @@ -216,7 +217,7 @@ St_read( if ( !strcmp( hostname, sglob->st->st_data[ i ]->hostname ) && atoi( port ) == sglob->st->st_data[ i ]->port ) { found = 1; - strcpy( sglob->st->st_data[ i ]->last, timestamp ); + sglob->st->st_data[ i ]->last = atol( timestamp ); sglob->st->st_data[ i ]->seq = atoi( seq ); break; }