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

2004-08-11 Thread Rasmus Lerdorf
Ok, fixed that.  Are you going to commit your rp_cache stuff soon?
-Rasmus
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


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

2004-08-11 Thread Andi Gutmans
It's not ready to commit. Needs some improvements (such as hooking into INI 
directives). I will try and find time to work on it next week. No rush 
because it'll still take some time for 5.1.

Andi
At 11:19 PM 8/10/2004 -0700, Rasmus Lerdorf wrote:
Ok, fixed that.  Are you going to commit your rp_cache stuff soon?
-Rasmus
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


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

2004-08-10 Thread Andi Gutmans
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.

Andi
At 05:40 PM 8/10/2004 +, Rasmus Lerdorf wrote:
rasmus  Tue Aug 10 13:40:00 2004 EDT
  Modified files:
/php-srcNEWS
/php-src/main   SAPI.c SAPI.h
/php-src/sapi/apachemod_php5.c
/php-src/sapi/apache2filter sapi_apache2.c
/php-src/sapi/apache2handlersapi_apache2.c
  Log:
  Add SAPI hook to get the request time if provided by the web server,
  otherwise call time(0) on the first call and store it so subsequent
  calls will get the same time.  Hook support for Apache1/2 included.
http://cvs.php.net/diff.php/php-src/NEWS?r1=1.1789r2=1.1790ty=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.1789 php-src/NEWS:1.1790
--- php-src/NEWS:1.1789 Tue Aug 10 12:43:20 2004
+++ php-src/NEWSTue Aug 10 13:39:59 2004
@@ -1,6 +1,7 @@
 PHP 
   NEWS

|||
 ?? ??? 2004, PHP 5.1.0
+- Add SAPI hook to get the current request time. (Rasmus)
 - Fixed bug #29522 (accessing properties without connection) (Georg)
 - Fixed bug #29335 (fetch functions now use MYSQLI_BOTH as default) (Georg)
 - Fixed bug #29311 (calling parent constructor in mysqli). (Georg)
http://cvs.php.net/diff.php/php-src/main/SAPI.c?r1=1.187r2=1.188ty=u
Index: php-src/main/SAPI.c
diff -u php-src/main/SAPI.c:1.187 php-src/main/SAPI.c:1.188
--- php-src/main/SAPI.c:1.187   Tue Jun  8 09:23:38 2004
+++ php-src/main/SAPI.c Tue Aug 10 13:39:59 2004
@@ -18,7 +18,7 @@
+--+
 */
-/* $Id: SAPI.c,v 1.187 2004/06/08 13:23:38 iliaa Exp $ */
+/* $Id: SAPI.c,v 1.188 2004/08/10 17:39:59 rasmus Exp $ */
 #include ctype.h
 #include sys/stat.h
@@ -37,6 +37,9 @@
 #ifdef ZTS
 #include TSRM.h
 #endif
+#ifdef HAVE_SYS_TIME_H
+#include sys/time.h
+#endif
 #include rfc1867.h
@@ -860,7 +863,6 @@
}
 }
-
 SAPI_API char *sapi_getenv(char *name, size_t name_len TSRMLS_DC)
 {
if (sapi_module.getenv) {
@@ -907,6 +909,15 @@
}
 }
+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);
+   }
+}

 /*
  * Local variables:
http://cvs.php.net/diff.php/php-src/main/SAPI.h?r1=1.108r2=1.109ty=u
Index: php-src/main/SAPI.h
diff -u php-src/main/SAPI.h:1.108 php-src/main/SAPI.h:1.109
--- php-src/main/SAPI.h:1.108   Thu Jan  8 12:33:04 2004
+++ php-src/main/SAPI.h Tue Aug 10 13:40:00 2004
@@ -16,7 +16,7 @@
+--+
 */
-/* $Id: SAPI.h,v 1.108 2004/01/08 17:33:04 sniper Exp $ */
+/* $Id: SAPI.h,v 1.109 2004/08/10 17:40:00 rasmus Exp $ */
 #ifndef SAPI_H
 #define SAPI_H
@@ -122,6 +122,7 @@
long post_max_size;
int options;
zend_bool sapi_started;
+   time_t global_request_time;
 } sapi_globals_struct;
@@ -197,6 +198,7 @@
 SAPI_API int sapi_get_target_uid(uid_t * TSRMLS_DC);
 SAPI_API int sapi_get_target_gid(gid_t * TSRMLS_DC);
+SAPI_API time_t sapi_get_request_time(TSRMLS_D);
 END_EXTERN_C()
 struct _sapi_module_struct {
@@ -225,6 +227,7 @@
void (*register_server_variables)(zval *track_vars_array TSRMLS_DC);
void (*log_message)(char *message);
+   time_t (*get_request_time)(TSRMLS_D);
char *php_ini_path_override;
http://cvs.php.net/diff.php/php-src/sapi/apache/mod_php5.c?r1=1.11r2=1.12ty=u
Index: php-src/sapi/apache/mod_php5.c
diff -u php-src/sapi/apache/mod_php5.c:1.11 
php-src/sapi/apache/mod_php5.c:1.12
--- php-src/sapi/apache/mod_php5.c:1.11 Mon Jul 19 03:19:49 2004
+++ php-src/sapi/apache/mod_php5.c  Tue Aug 10 13:40:00 2004
@@ -17,7 +17,7 @@
| PHP 4.0 patches by Zeev Suraski [EMAIL PROTECTED]  |
+--+
  */
-/* $Id: mod_php5.c,v 1.11 2004/07/19 07:19:49 andi Exp $ */
+/* $Id: mod_php5.c,v 1.12 2004/08/10 17:40:00 rasmus Exp $ */

 #include php_apache_http.h
 #include http_conf_globals.h
@@ -401,6 +401,14 @@
 }
 /* }}} */
+/* {{{ php_apache_get_request_time
+ */
+static time_t php_apache_get_request_time(TSRMLS_D)
+{
+   return ((request_rec *)SG(server_context))-request_time;
+}
+/* }}} */
+
 /* {{{ sapi_module_struct apache_sapi_module
  */
 static sapi_module_struct apache_sapi_module = {
@@ -429,6 +437,7 @@
sapi_apache_register_server_variables,  /* register 
server variables */
php_apache_log_message, /* Log message */
+   php_apache_get_request_time,/* Get request time */


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

2004-08-10 Thread Rasmus Lerdorf
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.

-Rasmus
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


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

2004-08-10 Thread Andi Gutmans
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
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php