]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
backport millionth second bug fix from HEAD
authorKurt Zeilenga <kurt@openldap.org>
Mon, 10 Sep 2001 17:21:22 +0000 (17:21 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Mon, 10 Sep 2001 17:21:22 +0000 (17:21 +0000)
CHANGES
servers/slurpd/re.c
servers/slurpd/ri.c
servers/slurpd/rq.c
servers/slurpd/slurp.h
servers/slurpd/st.c

diff --git a/CHANGES b/CHANGES
index b12a7b4fe4929be253557a0dad98085d4b5249c3..091c0cfb222774d5ed18421c9daa4fa7d7119289 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,7 +1,8 @@
 OpenLDAP 1.x Change Log
 
-Changes included in OpenLDAP 1.2.12 Engineering
+Changes included in OpenLDAP 1.2.13 Engineering
        CVS Tag: OPENLDAP_REL_ENG_1_2
+       Fixed slurpd millionth second bug (ITS#1323)
        Fixed libldap result error memory leak (ITS#1161)
 
 Changes included in OpenLDAP 1.2.12
index e180a74c8aef81cb69005325af7de8777e5fbd74..353ceacae2595a7b7313833ce5ea9fe538fe5adb 100644 (file)
@@ -83,7 +83,6 @@ Re_free(
     /* This seems to have problems under SunOS lwp */
     ldap_pvt_thread_mutex_destroy( &re->re_mutex );
 #endif /* HAVE_LWP */
-    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 );
@@ -175,7 +174,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 );
            }
@@ -439,7 +438,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++ ) {
@@ -525,7 +524,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;
     }
@@ -688,7 +687,7 @@ Re_init(
 
     /* Initialize private data */
    (*re)->re_refcnt = sglob->num_replicas;
-   (*re)->re_timestamp = NULL;
+   (*re)->re_timestamp = 0;
    (*re)->re_replicas = NULL;
    (*re)->re_dn = NULL;
    (*re)->re_changetype = 0;
index 857cc5d07fb91ceb8e309632a5eb935605f58e0c..f49d59a719e55e8e8bc50df9e109dcf982e7b2d3 100644 (file)
@@ -226,12 +226,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;
index d2f5e50d5ad7c5bbf65fdd922a88bbf2a508aafc..015be8711b60346272150a55c03dc1d966a99fea 100644 (file)
@@ -180,7 +180,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.
index 28ae98a0845ad67d5f113e778ce16575667663c2..9c35b52362295dbfdd5858937207f245cea947d9 100644 (file)
@@ -217,7 +217,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 */
@@ -288,7 +288,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;
 
index fed678b88de87db306542436427afa048baf6f84..f1a72ec3450e1dec891113a0b498086a46d8db8e 100644 (file)
@@ -61,7 +61,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 = 0L
     st->st_data[ ind ]->seq = 0;
 
     ldap_pvt_thread_mutex_unlock( &(st->st_mutex ));
@@ -108,8 +108,8 @@ 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 );
 
@@ -136,7 +136,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;
@@ -214,7 +214,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;
            }