]> git.sur5r.net Git - openldap/blobdiff - libraries/liblutil/csn.c
ITS#6419
[openldap] / libraries / liblutil / csn.c
index bab1dd9a8bd1261e7a1ad7f9ccbdfa6fd5421d82..19a74487ff6ae1974cc95da09f44c88bb01db6c5 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2007 The OpenLDAP Foundation.
+ * Copyright 2000-2009 The OpenLDAP Foundation.
  * Portions Copyright 2000-2003 Kurt D. Zeilenga.
  * All rights reserved.
  *
 
 #include <lutil.h>
 
+/* Must be mutex-protected, because lutil_gettime needs mutex protection */
 size_t
 lutil_csnstr(char *buf, size_t len, unsigned int replica, unsigned int mod)
 {
        struct lutil_tm tm;
-       static unsigned int csnop;
-       static int prev_sec, prev_usec;
-
-       unsigned int op;
        int n;
 
        lutil_gettime( &tm );
 
-       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++;
-
        n = snprintf( buf, len,
                "%4d%02d%02d%02d%02d%02d.%06dZ#%06x#%03x#%06x",
            tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour,
-           tm.tm_min, tm.tm_sec, tm.tm_usec, op, replica, mod );
+           tm.tm_min, tm.tm_sec, tm.tm_usec, tm.tm_usub, replica, mod );
 
        if( n < 0 ) return 0;
        return ( (size_t) n < len ) ? n : 0;