diff options
author | Anatol Belski <ab@php.net> | 2014-12-18 10:09:02 +0100 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2014-12-18 10:09:02 +0100 |
commit | 4b943c9c0dd4114adc78416c5241f11ad5c98a80 (patch) | |
tree | c9628d91eae3f580f9ebd73d2372e4c9089b2e00 /sapi/apache2handler | |
parent | 79354ba6d0d6a1a4596f9ac66ee9bc3a34ed972b (diff) | |
parent | dec8eb431adee340fb8dfb9ff33ed29d3279c35f (diff) | |
download | php-git-POST_NATIVE_TLS_MERGE.tar.gz |
Merge remote-tracking branch 'origin/native-tls'POST_NATIVE_TLS_MERGE
Diffstat (limited to 'sapi/apache2handler')
-rw-r--r-- | sapi/apache2handler/config.m4 | 2 | ||||
-rw-r--r-- | sapi/apache2handler/config.w32 | 6 | ||||
-rw-r--r-- | sapi/apache2handler/php_apache.h | 3 | ||||
-rw-r--r-- | sapi/apache2handler/php_functions.c | 30 | ||||
-rw-r--r-- | sapi/apache2handler/sapi_apache2.c | 82 |
5 files changed, 66 insertions, 57 deletions
diff --git a/sapi/apache2handler/config.m4 b/sapi/apache2handler/config.m4 index 59e17393dd..2e64b215e5 100644 --- a/sapi/apache2handler/config.m4 +++ b/sapi/apache2handler/config.m4 @@ -56,7 +56,7 @@ if test "$PHP_APXS2" != "no"; then esac done - APACHE_CFLAGS="$APACHE_CPPFLAGS -I$APXS_INCLUDEDIR $APR_CFLAGS $APU_CFLAGS" + APACHE_CFLAGS="$APACHE_CPPFLAGS -I$APXS_INCLUDEDIR $APR_CFLAGS $APU_CFLAGS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1" # Test that we're trying to configure with apache 2.x PHP_AP_EXTRACT_VERSION($APXS_HTTPD) diff --git a/sapi/apache2handler/config.w32 b/sapi/apache2handler/config.w32 index d15dcfaf03..8ea1305d4f 100644 --- a/sapi/apache2handler/config.w32 +++ b/sapi/apache2handler/config.w32 @@ -13,7 +13,7 @@ if (PHP_APACHE2HANDLER != "no") { ) { SAPI('apache2handler', 'mod_php7.c sapi_apache2.c apache_config.c php_functions.c', 'php' + PHP_VERSION + 'apache2.dll', - '/D PHP_APACHE2_EXPORTS /I win32'); + '/D PHP_APACHE2_EXPORTS /I win32 /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1'); } else { WARNING("Could not find apache2 libraries/headers"); } @@ -31,7 +31,7 @@ if (PHP_APACHE2_2HANDLER != "no") { ) { SAPI('apache2_2handler', 'mod_php7.c sapi_apache2.c apache_config.c php_functions.c', 'php' + PHP_VERSION + 'apache2_2.dll', - '/D PHP_APACHE2_EXPORTS /I win32', + '/D PHP_APACHE2_EXPORTS /I win32 /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1', 'sapi\\apache2_2handler'); } else { WARNING("Could not find apache2.2 libraries/headers"); @@ -49,7 +49,7 @@ if (PHP_APACHE2_4HANDLER != "no") { ) { SAPI('apache2_4handler', 'mod_php7.c sapi_apache2.c apache_config.c php_functions.c', 'php' + PHP_VERSION + 'apache2_4.dll', - '/D PHP_APACHE2_EXPORTS /I win32', + '/D PHP_APACHE2_EXPORTS /I win32 /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1', 'sapi\\apache2handler'); } else { WARNING("Could not find apache 2.4 libraries/headers"); diff --git a/sapi/apache2handler/php_apache.h b/sapi/apache2handler/php_apache.h index 22eabaafd4..8712b2b958 100644 --- a/sapi/apache2handler/php_apache.h +++ b/sapi/apache2handler/php_apache.h @@ -79,7 +79,8 @@ extern zend_module_entry apache2_module_entry; #ifdef ZTS extern int php_apache2_info_id; -#define AP2(v) TSRMG(php_apache2_info_id, php_apache2_info_struct *, v) +#define AP2(v) ZEND_TSRMG(php_apache2_info_id, php_apache2_info_struct *, v) +ZEND_TSRMLS_CACHE_EXTERN; #else extern php_apache2_info_struct php_apache2_info; #define AP2(v) (php_apache2_info.v) diff --git a/sapi/apache2handler/php_functions.c b/sapi/apache2handler/php_functions.c index 76bbad6194..2eb6a64c00 100644 --- a/sapi/apache2handler/php_functions.c +++ b/sapi/apache2handler/php_functions.c @@ -56,7 +56,7 @@ php_apache2_info_struct php_apache2_info; #define SECTION(name) PUTS("<h2>" name "</h2>\n") -static request_rec *php_apache_lookup_uri(char *filename TSRMLS_DC) +static request_rec *php_apache_lookup_uri(char *filename) { php_struct *ctx = SG(server_context); @@ -75,31 +75,31 @@ PHP_FUNCTION(virtual) size_t filename_len; request_rec *rr; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &filename, &filename_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &filename, &filename_len) == FAILURE) { return; } - if (!(rr = php_apache_lookup_uri(filename TSRMLS_CC))) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - URI lookup failed", filename); + if (!(rr = php_apache_lookup_uri(filename))) { + php_error_docref(NULL, E_WARNING, "Unable to include '%s' - URI lookup failed", filename); RETURN_FALSE; } if (rr->status != HTTP_OK) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - error finding URI", filename); + php_error_docref(NULL, E_WARNING, "Unable to include '%s' - error finding URI", filename); ap_destroy_sub_req(rr); RETURN_FALSE; } /* Flush everything. */ - php_output_end_all(TSRMLS_C); - php_header(TSRMLS_C); + php_output_end_all(); + php_header(); /* Ensure that the ap_r* layer for the main request is flushed, to * work around http://issues.apache.org/bugzilla/show_bug.cgi?id=17629 */ ap_rflush(rr->main); if (ap_run_sub_req(rr)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - request execution failed", filename); + php_error_docref(NULL, E_WARNING, "Unable to include '%s' - request execution failed", filename); ap_destroy_sub_req(rr); RETURN_FALSE; } @@ -121,12 +121,12 @@ PHP_FUNCTION(apache_lookup_uri) char *filename; size_t filename_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &filename, &filename_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &filename, &filename_len) == FAILURE) { return; } - if (!(rr = php_apache_lookup_uri(filename TSRMLS_CC))) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - URI lookup failed", filename); + if (!(rr = php_apache_lookup_uri(filename))) { + php_error_docref(NULL, E_WARNING, "Unable to include '%s' - URI lookup failed", filename); RETURN_FALSE; } @@ -163,7 +163,7 @@ PHP_FUNCTION(apache_lookup_uri) return; } - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - error finding URI", filename); + php_error_docref(NULL, E_WARNING, "Unable to include '%s' - error finding URI", filename); ap_destroy_sub_req(rr); RETURN_FALSE; } @@ -225,7 +225,7 @@ PHP_FUNCTION(apache_note) size_t note_name_len, note_val_len; char *old_note_val=NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", ¬e_name, ¬e_name_len, ¬e_val, ¬e_val_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", ¬e_name, ¬e_name_len, ¬e_val, ¬e_val_len) == FAILURE) { return; } @@ -259,7 +259,7 @@ PHP_FUNCTION(apache_setenv) int arg_count = ZEND_NUM_ARGS(); request_rec *r; - if (zend_parse_parameters(arg_count TSRMLS_CC, "ss|b", &variable, &variable_len, &string_val, &string_val_len, &walk_to_top) == FAILURE) { + if (zend_parse_parameters(arg_count, "ss|b", &variable, &variable_len, &string_val, &string_val_len, &walk_to_top) == FAILURE) { return; } @@ -295,7 +295,7 @@ PHP_FUNCTION(apache_getenv) char *env_val=NULL; request_rec *r; - if (zend_parse_parameters(arg_count TSRMLS_CC, "s|b", &variable, &variable_len, &walk_to_top) == FAILURE) { + if (zend_parse_parameters(arg_count, "s|b", &variable, &variable_len, &walk_to_top) == FAILURE) { return; } diff --git a/sapi/apache2handler/sapi_apache2.c b/sapi/apache2handler/sapi_apache2.c index 3b7eaf2283..5336b115c0 100644 --- a/sapi/apache2handler/sapi_apache2.c +++ b/sapi/apache2handler/sapi_apache2.c @@ -71,9 +71,12 @@ /* A way to specify the location of the php.ini dir in an apache directive */ char *apache2_php_ini_path_override = NULL; +#if defined(PHP_WIN32) && defined(ZTS) +ZEND_TSRMLS_CACHE_DEFINE; +#endif static size_t -php_apache_sapi_ub_write(const char *str, size_t str_length TSRMLS_DC) +php_apache_sapi_ub_write(const char *str, size_t str_length) { request_rec *r; php_struct *ctx; @@ -89,7 +92,7 @@ php_apache_sapi_ub_write(const char *str, size_t str_length TSRMLS_DC) } static int -php_apache_sapi_header_handler(sapi_header_struct *sapi_header, sapi_header_op_enum op, sapi_headers_struct *sapi_headers TSRMLS_DC) +php_apache_sapi_header_handler(sapi_header_struct *sapi_header, sapi_header_op_enum op, sapi_headers_struct *sapi_headers) { php_struct *ctx; char *val, *ptr; @@ -151,7 +154,7 @@ php_apache_sapi_header_handler(sapi_header_struct *sapi_header, sapi_header_op_e } static int -php_apache_sapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) +php_apache_sapi_send_headers(sapi_headers_struct *sapi_headers) { php_struct *ctx = SG(server_context); const char *sline = SG(sapi_headers).http_status_line; @@ -171,7 +174,7 @@ php_apache_sapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) /* call ap_set_content_type only once, else each time we call it, configured output filters for that content type will be added */ if (!ctx->content_type) { - ctx->content_type = sapi_get_default_content_type(TSRMLS_C); + ctx->content_type = sapi_get_default_content_type(); } ap_set_content_type(ctx->r, apr_pstrdup(ctx->r->pool, ctx->content_type)); efree(ctx->content_type); @@ -181,7 +184,7 @@ php_apache_sapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) } static apr_size_t -php_apache_sapi_read_post(char *buf, size_t count_bytes TSRMLS_DC) +php_apache_sapi_read_post(char *buf, size_t count_bytes) { apr_size_t len, tlen=0; php_struct *ctx = SG(server_context); @@ -213,7 +216,7 @@ php_apache_sapi_read_post(char *buf, size_t count_bytes TSRMLS_DC) } static zend_stat_t* -php_apache_sapi_get_stat(TSRMLS_D) +php_apache_sapi_get_stat(void) { php_struct *ctx = SG(server_context); @@ -238,7 +241,7 @@ php_apache_sapi_get_stat(TSRMLS_D) } static char * -php_apache_sapi_read_cookies(TSRMLS_D) +php_apache_sapi_read_cookies(void) { php_struct *ctx = SG(server_context); const char *http_cookie; @@ -250,7 +253,7 @@ php_apache_sapi_read_cookies(TSRMLS_D) } static char * -php_apache_sapi_getenv(char *name, size_t name_len TSRMLS_DC) +php_apache_sapi_getenv(char *name, size_t name_len) { php_struct *ctx = SG(server_context); const char *env_var; @@ -265,7 +268,7 @@ php_apache_sapi_getenv(char *name, size_t name_len TSRMLS_DC) } static void -php_apache_sapi_register_variables(zval *track_vars_array TSRMLS_DC) +php_apache_sapi_register_variables(zval *track_vars_array) { php_struct *ctx = SG(server_context); const apr_array_header_t *arr = apr_table_elts(ctx->r->subprocess_env); @@ -276,18 +279,18 @@ php_apache_sapi_register_variables(zval *track_vars_array TSRMLS_DC) if (!val) { val = ""; } - if (sapi_module.input_filter(PARSE_SERVER, key, &val, strlen(val), &new_val_len TSRMLS_CC)) { - php_register_variable_safe(key, val, new_val_len, track_vars_array TSRMLS_CC); + if (sapi_module.input_filter(PARSE_SERVER, key, &val, strlen(val), &new_val_len)) { + php_register_variable_safe(key, val, new_val_len, track_vars_array); } APR_ARRAY_FOREACH_CLOSE() - if (sapi_module.input_filter(PARSE_SERVER, "PHP_SELF", &ctx->r->uri, strlen(ctx->r->uri), &new_val_len TSRMLS_CC)) { - php_register_variable_safe("PHP_SELF", ctx->r->uri, new_val_len, track_vars_array TSRMLS_CC); + if (sapi_module.input_filter(PARSE_SERVER, "PHP_SELF", &ctx->r->uri, strlen(ctx->r->uri), &new_val_len)) { + php_register_variable_safe("PHP_SELF", ctx->r->uri, new_val_len, track_vars_array); } } static void -php_apache_sapi_flush(void *server_context TSRMLS_DC) +php_apache_sapi_flush(void *server_context) { php_struct *ctx; request_rec *r; @@ -302,7 +305,7 @@ php_apache_sapi_flush(void *server_context TSRMLS_DC) r = ctx->r; - sapi_send_headers(TSRMLS_C); + sapi_send_headers(); r->status = SG(sapi_headers).http_response_code; SG(headers_sent) = 1; @@ -312,7 +315,7 @@ php_apache_sapi_flush(void *server_context TSRMLS_DC) } } -static void php_apache_sapi_log_message(char *msg TSRMLS_DC) +static void php_apache_sapi_log_message(char *msg) { php_struct *ctx; @@ -325,16 +328,16 @@ static void php_apache_sapi_log_message(char *msg TSRMLS_DC) } } -static void php_apache_sapi_log_message_ex(char *msg, request_rec *r TSRMLS_DC) +static void php_apache_sapi_log_message_ex(char *msg, request_rec *r) { if (r) { ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, msg, r->filename); } else { - php_apache_sapi_log_message(msg TSRMLS_CC); + php_apache_sapi_log_message(msg); } } -static double php_apache_sapi_get_request_time(TSRMLS_D) +static double php_apache_sapi_get_request_time(void) { php_struct *ctx = SG(server_context); return ((double) apr_time_as_msec(ctx->r->request_time)) / 1000.0; @@ -403,7 +406,6 @@ static apr_status_t php_apache_child_shutdown(void *tmp) static void php_apache_add_version(apr_pool_t *p) { - TSRMLS_FETCH(); if (PG(expose_php)) { ap_add_version_component(p, "PHP/" PHP_VERSION); } @@ -451,6 +453,8 @@ php_apache_server_startup(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp } #ifdef ZTS tsrm_startup(1, 1, 0, NULL); + (void)ts_resource(0); + ZEND_TSRMLS_CACHE_UPDATE; #endif sapi_startup(&apache2_sapi_module); apache2_sapi_module.startup(&apache2_sapi_module); @@ -467,7 +471,7 @@ static apr_status_t php_server_context_cleanup(void *data_) return APR_SUCCESS; } -static int php_apache_request_ctor(request_rec *r, php_struct *ctx TSRMLS_DC) +static int php_apache_request_ctor(request_rec *r, php_struct *ctx) { char *content_length; const char *auth; @@ -494,7 +498,7 @@ static int php_apache_request_ctor(request_rec *r, php_struct *ctx TSRMLS_DC) apr_table_unset(r->headers_out, "ETag"); auth = apr_table_get(r->headers_in, "Authorization"); - php_handle_auth_data(auth TSRMLS_CC); + php_handle_auth_data(auth); if (SG(request_info).auth_user == NULL && r->user) { SG(request_info).auth_user = estrdup(r->user); @@ -502,18 +506,18 @@ static int php_apache_request_ctor(request_rec *r, php_struct *ctx TSRMLS_DC) ctx->r->user = apr_pstrdup(ctx->r->pool, SG(request_info).auth_user); - return php_request_startup(TSRMLS_C); + return php_request_startup(); } -static void php_apache_request_dtor(request_rec *r TSRMLS_DC) +static void php_apache_request_dtor(request_rec *r) { php_request_shutdown(NULL); } -static void php_apache_ini_dtor(request_rec *r, request_rec *p TSRMLS_DC) +static void php_apache_ini_dtor(request_rec *r, request_rec *p) { if (strcmp(r->protocol, "INCLUDED")) { - zend_try { zend_ini_deactivate(TSRMLS_C); } zend_end_try(); + zend_try { zend_ini_deactivate(); } zend_end_try(); } else { typedef struct { HashTable config; @@ -540,9 +544,13 @@ static int php_handler(request_rec *r) apr_bucket *bucket; apr_status_t rv; request_rec * volatile parent_req = NULL; - TSRMLS_FETCH(); +#ifdef ZTS + /* initial resource fetch */ + void ***tsrm_ls = ts_resource(0); + ZEND_TSRMLS_CACHE_UPDATE; +#endif -#define PHPAP_INI_OFF php_apache_ini_dtor(r, parent_req TSRMLS_CC); +#define PHPAP_INI_OFF php_apache_ini_dtor(r, parent_req); conf = ap_get_module_config(r->per_dir_config, &php7_module); @@ -587,12 +595,12 @@ normal: } if (r->finfo.filetype == 0) { - php_apache_sapi_log_message_ex("script '%s' not found or unable to stat", r TSRMLS_CC); + php_apache_sapi_log_message_ex("script '%s' not found or unable to stat", r); PHPAP_INI_OFF; return HTTP_NOT_FOUND; } if (r->finfo.filetype == APR_DIR) { - php_apache_sapi_log_message_ex("attempt to invoke directory '%s' as script", r TSRMLS_CC); + php_apache_sapi_log_message_ex("attempt to invoke directory '%s' as script", r); PHPAP_INI_OFF; return HTTP_FORBIDDEN; } @@ -614,7 +622,7 @@ zend_first_try { ctx = SG(server_context); ctx->brigade = brigade; - if (php_apache_request_ctor(r, ctx TSRMLS_CC)!=SUCCESS) { + if (php_apache_request_ctor(r, ctx)!=SUCCESS) { zend_bailout(); } } else { @@ -625,7 +633,7 @@ zend_first_try { strcmp(parent_req->handler, PHP_MAGIC_TYPE) && strcmp(parent_req->handler, PHP_SOURCE_MAGIC_TYPE) && strcmp(parent_req->handler, PHP_SCRIPT)) { - if (php_apache_request_ctor(r, ctx TSRMLS_CC)!=SUCCESS) { + if (php_apache_request_ctor(r, ctx)!=SUCCESS) { zend_bailout(); } } @@ -653,7 +661,7 @@ zend_first_try { if (strncmp(r->handler, PHP_SOURCE_MAGIC_TYPE, sizeof(PHP_SOURCE_MAGIC_TYPE) - 1) == 0) { zend_syntax_highlighter_ini syntax_highlighter_ini; php_get_highlight_struct(&syntax_highlighter_ini); - highlight_file((char *)r->filename, &syntax_highlighter_ini TSRMLS_CC); + highlight_file((char *)r->filename, &syntax_highlighter_ini); } else { zend_file_handle zfd; @@ -663,19 +671,19 @@ zend_first_try { zfd.opened_path = NULL; if (!parent_req) { - php_execute_script(&zfd TSRMLS_CC); + php_execute_script(&zfd); } else { - zend_execute_scripts(ZEND_INCLUDE TSRMLS_CC, NULL, 1, &zfd); + zend_execute_scripts(ZEND_INCLUDE, NULL, 1, &zfd); } apr_table_set(r->notes, "mod_php_memory_usage", - apr_psprintf(ctx->r->pool, "%" APR_SIZE_T_FMT, zend_memory_peak_usage(1 TSRMLS_CC))); + apr_psprintf(ctx->r->pool, "%" APR_SIZE_T_FMT, zend_memory_peak_usage(1))); } } zend_end_try(); if (!parent_req) { - php_apache_request_dtor(r TSRMLS_CC); + php_apache_request_dtor(r); ctx->request_processed = 1; bucket = apr_bucket_eos_create(r->connection->bucket_alloc); APR_BRIGADE_INSERT_TAIL(brigade, bucket); |