View | Details | Raw Unified | Return to bug 45110
Collapse All | Expand All

(-)modules/metadata/mod_unique_id.c (-8 / +15 lines)
Lines 23-29 Link Here
23
23
24
#define APR_WANT_BYTEFUNC   /* for htons() et al */
24
#define APR_WANT_BYTEFUNC   /* for htons() et al */
25
#include "apr_want.h"
25
#include "apr_want.h"
26
#include "apr_general.h"    /* for APR_OFFSETOF                */
26
#include "apr_general.h"    /* for APR_OFFSETOF and apr_generate_random_bytes */
27
#include "apr_network_io.h"
27
#include "apr_network_io.h"
28
28
29
#include "httpd.h"
29
#include "httpd.h"
Lines 215-222 Link Here
215
static void unique_id_child_init(apr_pool_t *p, server_rec *s)
215
static void unique_id_child_init(apr_pool_t *p, server_rec *s)
216
{
216
{
217
    pid_t pid;
217
    pid_t pid;
218
    apr_time_t tv;
218
    unsigned short num;
219
219
    apr_status_t rv = APR_EGENERAL;
220
    /*
220
    /*
221
     * Note that we use the pid because it's possible that on the same
221
     * Note that we use the pid because it's possible that on the same
222
     * physical machine there are multiple servers (i.e. using Listen). But
222
     * physical machine there are multiple servers (i.e. using Listen). But
Lines 247-258 Link Here
247
     * against restart problems, and a little less protection against a clock
247
     * against restart problems, and a little less protection against a clock
248
     * going backwards in time.
248
     * going backwards in time.
249
     */
249
     */
250
    tv = apr_time_now();
250
#if APR_HAS_RANDOM
251
    /* Some systems have very low variance on the low end of their system
251
    rv = apr_generate_random_bytes((unsigned char*) &num, sizeof(num));
252
     * counter, defend against that.
252
#endif
253
     */
253
    if(rv != APR_SUCCESS){
254
    cur_unique_id.counter = (unsigned short)(apr_time_usec(tv) / 10);
254
        apr_time_t tv = apr_time_now();
255
        /* Some systems have very low variance on the low end of their system
256
         * counter, defend against that.
257
         */
258
        num = (unsigned short)(apr_time_usec(tv) / 10);
259
    }
255
260
261
    cur_unique_id.counter = num;
262
256
    /*
263
    /*
257
     * We must always use network ordering for these bytes, so that
264
     * We must always use network ordering for these bytes, so that
258
     * identifiers are comparable between machines of different byte
265
     * identifiers are comparable between machines of different byte

Return to bug 45110