]> git.sur5r.net Git - openldap/commitdiff
Don't let timestamps go backward
authorHoward Chu <hyc@openldap.org>
Tue, 6 Feb 2007 04:48:35 +0000 (04:48 +0000)
committerHoward Chu <hyc@openldap.org>
Tue, 6 Feb 2007 04:48:35 +0000 (04:48 +0000)
libraries/liblutil/csn.c

index 647eabe4ec9ee03d28fee8793872b549f55bda5c..bab1dd9a8bd1261e7a1ad7f9ccbdfa6fd5421d82 100644 (file)
@@ -60,10 +60,14 @@ lutil_csnstr(char *buf, size_t len, unsigned int replica, unsigned int mod)
 
        lutil_gettime( &tm );
 
-       if ( tm.tm_usec != prev_usec || tm.tm_sec != prev_sec ) {
+       if ( tm.tm_sec > prev_sec || ( tm.tm_sec == prev_sec &&
+               tm.tm_usec > prev_usec )) {
                prev_sec = tm.tm_sec;
                prev_usec = tm.tm_usec;
                csnop = 0;
+       } else {
+               tm.tm_sec = prev_sec;
+               tm.tm_usec = prev_usec;
        }
        op = csnop++;