X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Fliblutil%2Fcsn.c;h=4eb29bcce2aa14d85ebb41c4a987956914e2ed64;hb=10595e7e5877b224077ae388913f96dbf26e9138;hp=62247fd098c232ca6bb3ba71b08ea65994174cd5;hpb=327880b984a0c36da7dd502dbfb12fdd0b89e82a;p=openldap
diff --git a/libraries/liblutil/csn.c b/libraries/liblutil/csn.c
index 62247fd098..4eb29bcce2 100644
--- a/libraries/liblutil/csn.c
+++ b/libraries/liblutil/csn.c
@@ -2,7 +2,7 @@
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software .
*
- * Copyright 2000-2003 The OpenLDAP Foundation.
+ * Copyright 2000-2007 The OpenLDAP Foundation.
* Portions Copyright 2000-2003 Kurt D. Zeilenga.
* All rights reserved.
*
@@ -35,8 +35,8 @@
* where s is a counter of operations within a timeslice, r is
* the replica id (normally zero), and c is a counter of
* modifications within this operation. s, r, and c are
- * represented in hex and zero padded to lengths of 6, 2, and
- * 6, respectively.
+ * represented in hex and zero padded to lengths of 6, 3, and
+ * 6, respectively. (In previous implementations r was only 2 digits.)
*
* Calls to this routine MUST be serialized with other calls
* to gmtime().
@@ -48,29 +48,19 @@
#include
+/* 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)
{
- static time_t csntime;
- static unsigned int csnop;
-
- time_t t;
- unsigned int op;
- struct tm *ltm;
+ struct lutil_tm tm;
int n;
- time( &t );
- if ( t > csntime ) {
- csntime = t;
- csnop = 0;
- }
- op = ++csnop;
+ lutil_gettime( &tm );
- ltm = gmtime( &t );
n = snprintf( buf, len,
- "%4d%02d%02d%02d%02d%02dZ#%06x#%02x#%06x",
- ltm->tm_year + 1900, ltm->tm_mon + 1, ltm->tm_mday, ltm->tm_hour,
- ltm->tm_min, ltm->tm_sec, op, replica, mod );
+ "%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, tm.tm_usub, replica, mod );
if( n < 0 ) return 0;
return ( (size_t) n < len ) ? n : 0;