changeset 22133:9ccf1fdb6303

lib: guid_128_generate() needs to correctly convert usecs to nsecs The timestamp in the guid starts off with real time, but "runs ahead" if a lot of guids are generated. If not many guids are being generated, the timestamp is fast-forwarded to the current ioloop_timeval. The buggy comparison prevented fast forwarding when tv_sec matched, but tv_nsec value was > 0 (which was true most of the time).
author Josef 'Jeff' Sipek <jeff.sipek@dovecot.fi>
date Mon, 05 Jun 2017 12:53:23 +0300
parents 7ae75b9c0a23
children 69f9d0c724a3
files src/lib/guid.c
diffstat 1 files changed, 1 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/guid.c	Tue Jun 06 17:18:27 2017 +0300
+++ b/src/lib/guid.c	Mon Jun 05 12:53:23 2017 +0300
@@ -69,7 +69,7 @@
 		guid_128_host_hash_get(my_hostdomain(), guid_static+4);
 	} else if (ioloop_timeval.tv_sec > ts.tv_sec ||
 		   (ioloop_timeval.tv_sec == ts.tv_sec &&
-		    ioloop_timeval.tv_usec > ts.tv_nsec*1000)) {
+		    ioloop_timeval.tv_usec * 1000 > ts.tv_nsec)) {
 		/* use ioloop's time since we have it. it doesn't provide any
 		   more uniqueness, but it allows finding out more reliably
 		   when a GUID was created. */