You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Matthew Rushton <mr...@yahoo.com> on 2009/02/04 23:06:32 UTC
random number generation
Hi,
I'm writing an apache module and need to generate a random number to handle a request. The random numbers must be unique across requests and thus across forks. My problem is coming up with a way to seed the random numbers in an efficient way. I imagine I'll need to use some combination of a timestamp and process/thread id. Perhaps this is already handled by apache or another module? What have other people done? That's it. Thanks in advance.
-Matt
Re: random number generation
Posted by Ruediger Pluem <rp...@apache.org>.
On 02/04/2009 11:06 PM, Matthew Rushton wrote:
> Hi,
> I'm writing an apache module and need to generate a random number to handle a request.
> The random numbers must be unique across requests and thus across forks. My problem is
> coming up with a way to seed the random numbers in an efficient way. I imagine I'll need to
> use some combination of a timestamp and process/thread id. Perhaps this is already handled by
> apache or another module? What have other people done? That's it. Thanks in advance.
> -Matt
The following might be helpful to you:
http://apr.apache.org/docs/apr/1.3/group__apr__random.html
http://httpd.apache.org/docs/2.2/en/mod/mod_unique_id.html
Regards
Rüdiger