Re: cvs: php-src / NEWS /main SAPI.c SAPI.h /sapi/apache mod_php5.c /sapi/apache2filter sapi_apache2.c /sapi/apache2handler sapi_apache2.c

From: Date: Wed, 11 Aug 2004 05:30:57 +0000
Subject: Re: cvs: php-src / NEWS /main SAPI.c SAPI.h /sapi/apache mod_php5.c /sapi/apache2filter sapi_apache2.c /sapi/apache2handler sapi_apache2.c
References: 1 2  Groups: php.cvs 
Request: Send a blank email to php-cvs+get-28276@lists.php.net to get a copy of this message
At 09:52 PM 8/10/2004 -0700, Rasmus Lerdorf wrote:
On Tue, 10 Aug 2004, Andi Gutmans wrote:
Haven't run the code but it seems that if sapi_get_request_time() is not defined then you will return the same time() for each consecutive request (i.e. you don't reset it each request). It's probably better to move the time(0) initialization to sapi_globals ctor and/or dtor.
Hrm.. Isn't that what I did? The code is:
    SAPI_API time_t sapi_get_request_time(TSRMLS_D) {
        if (sapi_module.get_request_time) {
            return sapi_module.get_request_time(TSRMLS_C);
        } else {
            if(!SG(global_request_time)) SG(global_request_time) = time(0);
            return SG(global_request_time);
        }
    }
So I store the time in the sapi_globals_struct which is zeroed on each request, so only subsequent calls to sapi_get_request_time() during the same request will get the same time which is what I think people would expect.
It isn't 0'ed on each request, it's zeroed only at MINIT (or thread-init). Andi

« previous php.cvs (#28276) next »