mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Allow get_request_time() hook to fail
In particular, this allows using the hook without server_context. The apache2handler implementation now checks that server_context is available itself, as that's the implementation that cares about it.
This commit is contained in:
@@ -1073,9 +1073,8 @@ SAPI_API double sapi_get_request_time(void)
|
||||
{
|
||||
if(SG(global_request_time)) return SG(global_request_time);
|
||||
|
||||
if (sapi_module.get_request_time && SG(server_context)) {
|
||||
SG(global_request_time) = sapi_module.get_request_time();
|
||||
} else {
|
||||
if (!sapi_module.get_request_time
|
||||
|| sapi_module.get_request_time(&SG(global_request_time)) == FAILURE) {
|
||||
struct timeval tp = {0};
|
||||
if (!gettimeofday(&tp, NULL)) {
|
||||
SG(global_request_time) = (double)(tp.tv_sec + tp.tv_usec / 1000000.00);
|
||||
|
||||
@@ -236,7 +236,7 @@ struct _sapi_module_struct {
|
||||
|
||||
void (*register_server_variables)(zval *track_vars_array);
|
||||
void (*log_message)(const char *message, int syslog_type_int);
|
||||
double (*get_request_time)(void);
|
||||
zend_result (*get_request_time)(double *request_time);
|
||||
void (*terminate_process)(void);
|
||||
|
||||
char *php_ini_path_override;
|
||||
|
||||
@@ -363,10 +363,15 @@ static void php_apache_sapi_log_message_ex(const char *msg, request_rec *r)
|
||||
}
|
||||
}
|
||||
|
||||
static double php_apache_sapi_get_request_time(void)
|
||||
static zend_result php_apache_sapi_get_request_time(double *request_time)
|
||||
{
|
||||
php_struct *ctx = SG(server_context);
|
||||
return ((double) ctx->r->request_time) / 1000000.0;
|
||||
if (!ctx) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
*request_time = ((double) ctx->r->request_time) / 1000000.0;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
extern zend_module_entry php_apache_module;
|
||||
|
||||
Reference in New Issue
Block a user