Skip to content

Commit

Permalink
lib: guid_128_generate() needs to correctly convert usecs to nsecs
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
Josef 'Jeff' Sipek committed Jun 7, 2017
1 parent e8760ad commit c104ea8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/guid.c
Expand Up @@ -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. */
Expand Down

0 comments on commit c104ea8

Please sign in to comment.