diff --git a/ChangeLog.txt b/ChangeLog.txt index 38eb9efe..38079896 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -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 ================ diff --git a/lib/mosquitto.c b/lib/mosquitto.c index eab1d99a..6ac3bcb6 100644 --- a/lib/mosquitto.c +++ b/lib/mosquitto.c @@ -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;