--- modules/metadata/mod_unique_id.c (revision 661940) +++ modules/metadata/mod_unique_id.c (working copy) @@ -23,7 +23,7 @@ #define APR_WANT_BYTEFUNC /* for htons() et al */ #include "apr_want.h" -#include "apr_general.h" /* for APR_OFFSETOF */ +#include "apr_general.h" /* for APR_OFFSETOF and apr_generate_random_bytes */ #include "apr_network_io.h" #include "httpd.h" @@ -215,8 +215,8 @@ static void unique_id_child_init(apr_pool_t *p, server_rec *s) { pid_t pid; - apr_time_t tv; - + unsigned short num; + apr_status_t rv = APR_EGENERAL; /* * Note that we use the pid because it's possible that on the same * physical machine there are multiple servers (i.e. using Listen). But @@ -247,12 +247,19 @@ * against restart problems, and a little less protection against a clock * going backwards in time. */ - tv = apr_time_now(); - /* Some systems have very low variance on the low end of their system - * counter, defend against that. - */ - cur_unique_id.counter = (unsigned short)(apr_time_usec(tv) / 10); +#if APR_HAS_RANDOM + rv = apr_generate_random_bytes((unsigned char*) &num, sizeof(num)); +#endif + if(rv != APR_SUCCESS){ + apr_time_t tv = apr_time_now(); + /* Some systems have very low variance on the low end of their system + * counter, defend against that. + */ + num = (unsigned short)(apr_time_usec(tv) / 10); + } + cur_unique_id.counter = num; + /* * We must always use network ordering for these bytes, so that * identifiers are comparable between machines of different byte