]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: guid_128_generate() needs to correctly convert usecs to nsecs
authorJosef 'Jeff' Sipek <jeff.sipek@dovecot.fi>
Mon, 5 Jun 2017 09:53:23 +0000 (12:53 +0300)
committerJosef 'Jeff' Sipek <jeff.sipek@dovecot.fi>
Wed, 7 Jun 2017 10:05:23 +0000 (13:05 +0300)
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).

src/lib/guid.c

index ccc706a285401a5ce8a42be70692183ecc7902ee..0feb745a5a1055a778445299ea09d43c4421eb81 100644 (file)
@@ -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. */