Use higher resolution timer for random client id generation.

pull/1229/head
Roger A. Light 7 years ago
parent 5e8199323b
commit f4e24f9524

@ -6,6 +6,10 @@ Broker:
case where a client connects using a username, and the anonymous ACL list is
defined but specific user ACLs are not defined. Closes #1162.
Library:
- Use higher resolution timer for random initialisation of client id
generation. Closes #1177.
1.5.7 - 20190213
================

@ -46,6 +46,16 @@ int mosquitto_lib_init(void)
{
#ifdef WIN32
srand(GetTickCount64());
#elif _POSIX_TIMERS>0 && defined(_POSIX_MONOTONIC_CLOCK)
struct timespec tp;
clock_gettime(CLOCK_MONOTONIC, &tp);
srand(tp.tv_nsec);
#elif defined(__APPLE__)
uint64_t ticks;
ticks = mach_absolute_time();
srand((unsigned int)ticks);
#else
struct timeval tv;

Loading…
Cancel
Save