From: Josef 'Jeff' Sipek Date: Mon, 5 Jun 2017 09:53:23 +0000 (+0300) Subject: lib: guid_128_generate() needs to correctly convert usecs to nsecs X-Git-Tag: 2.3.0.rc1~1503 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c104ea8f180db4be2b491ef5b1f2626958dce80d;p=thirdparty%2Fdovecot%2Fcore.git 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). --- diff --git a/src/lib/guid.c b/src/lib/guid.c index ccc706a285..0feb745a5a 100644 --- a/src/lib/guid.c +++ b/src/lib/guid.c @@ -69,7 +69,7 @@ void guid_128_generate(guid_128_t guid_r) 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. */