httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug MacEachern <>
Subject srand() usage
Date Thu, 29 Nov 2001 00:15:29 GMT
mod_rewrite has a race condition with threaded mpms:

static int rewrite_rand_init_done = 0;

static void rewrite_rand_init(void)
    if (!rewrite_rand_init_done) {
        rewrite_rand_init_done = 1;

and mod_ssl calls srand(time(NULL)) on *every* request if
'SSLRandomSeed connect builtin' is configured.

i was thinking there should be an ap_srand() that can be called by modules
in the child_init hook.  something like:

static int ap_srand_init = 0;

AP_DECLARE(void) ap_srand(void)
    if (!ap_srand_init) {
        ap_srand_init = 1;

this will help ensure srand() is only called once per-process and avoid
the race condition.  thoughts?

only snag is it looks like all MPMs except for beos call
ap_run_child_init(), any reason the beos mpm shouldn't be calling it?

View raw message