You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Greg Stein <gs...@lyra.org> on 2000/06/08 03:07:20 UTC

Re: cvs commit: apache-2.0/src/os/win32 os.h

On Thu, Jun 08, 2000 at 12:28:35AM -0000, rbb@locus.apache.org wrote:
>...
>   --- mod_unique_id.c	2000/05/27 22:40:37	1.11
>   +++ mod_unique_id.c	2000/06/08 00:28:34	1.12
>   @@ -169,9 +169,7 @@
>    #endif
>        char str[MAXHOSTNAMELEN + 1];
>        struct hostent *hent;
>   -#ifdef HAVE_GETTIMEOFDAY
>   -    struct timeval tv;
>   -#endif
>   +    ap_time_t tv;
>    
>        /*
>         * Calculate the sizes and offsets in cur_unique_id.
>   @@ -232,26 +230,14 @@
>         * But protecting against it is relatively cheap.  We just sleep into the
>         * next second.
>         */
>   -#ifndef HAVE_GETTIMEOFDAY
>   -    sleep(1);
>   -#else
>   -    if (gettimeofday(&tv, NULL) == -1) {
>   -        sleep(1);
>   -    }
>   -    else if (tv.tv_usec) {
>   -        tv.tv_sec = 0;
>   -        tv.tv_usec = 1000000 - tv.tv_usec;
>   -        select(0, NULL, NULL, NULL, &tv);
>   -    }
>   -#endif
>   +    tv = ap_now();
>   +    ap_sleep(
>    }

That doesn't look right :-)  I'm not sure what is supposed to happen in
there, but that ap_sleep() call needs a bit of work.

Should the whole block be ap_sleep(), or do you need the ap_now() and do
some kind of sub-second sleep?

>    
>    static void unique_id_child_init(ap_pool_t *p, server_rec *s)
>    {
>        pid_t pid;
>   -#ifdef HAVE_GETTIMEOFDAY
>   -    struct timeval tv;
>   -#endif
>   +    time_t tv;

Should be an "ap_time_t"

>        /*
>         * Note that we use the pid because it's possible that on the same
>   @@ -283,19 +269,8 @@
>         * against restart problems, and a little less protection against a clock
>         * going backwards in time.
>         */
>   -#ifdef HAVE_GETTIMEOFDAY
>   -    if (gettimeofday(&tv, NULL) == -1) {
>   -        cur_unique_id.counter = 0;
>   -    }
>   -    else {
>   -	/* Some systems have very low variance on the low end of their
>   -	 * system counter, defend against that.
>   -	 */
>   -        cur_unique_id.counter = tv.tv_usec / 10;
>   -    }
>   -#else
>   -    cur_unique_id.counter = 0;
>   -#endif
>   +    tv = ap_now();
>   +    cur_unique_id.counter = tv % APR_USEC_PER_SEC / 10;

It is probably important to keep the comment about why the "/ 10" is
occurring. Otherwise, people will scratch their heads...


Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/