httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <dgau...@arctic.org>
Subject Re: [PATCH] mod_unique_id.c
Date Sat, 16 Aug 1997 22:01:06 GMT
I actually need a 16-bit somewhat random integer ... and I figured the low
end of tv_usec would be good enough.  Other suggestions are welcome ...
but I don't think drand/random are sufficient unless we also seed the RNG
with something more random than time(0).  The problem I'm trying to work
around are server restarts in the same one second interval... or clocks
that have gone backwards... but the latter is admittedly not a huge
concern.

Dean

On Sat, 16 Aug 1997, Jim Jagielski wrote:

> Also, I don't think gettimeofday() is universally available.
> We do have a #define already, HAVE_GETTIMEOFDAY which indicates
> whether it is or not. What I've done is use times() if
> gettimeofday() doesn't exist.
> > +
> > +    /* If we use 0 as the initial counter we have a little less protection
> > +     * against restart problems, and a little less protection against a
> > +     * clock going backwards in time.
> > +     */
> > +    if (gettimeofday (&tv, NULL) == -1) {
> > +	/* ugh */
> > +	cur_unique_id.stamp = time(0);
> > +	cur_unique_id.counter = 0;
> > +    } else {
> > +	cur_unique_id.stamp = tv.tv_sec;
> > +	cur_unique_id.counter = tv.tv_usec;
> > +    }
> > +
> 
> -- 
> ====================================================================
>       Jim Jagielski            |       jaguNET Access Services
>      jim@jaguNET.com           |       http://www.jaguNET.com/
>             "Look at me! I'm wearing a cardboard belt!"
> 


Mime
View raw message