diff options
author | Dmitry Stogov <dmitry@zend.com> | 2014-04-26 00:32:51 +0400 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2014-04-26 00:32:51 +0400 |
commit | f9927a6c97208c60d922f9a4e98feb8079c57d1f (patch) | |
tree | 35815b69d1bf7d47fb41e857ff8d2b024ddac153 /sapi/apache2filter | |
parent | 4e7cbf3f5842abe6688c11ce3cc11d2eabf0695f (diff) | |
parent | b82d077f988606580e5c06a9da18fe4f60ddb7cb (diff) | |
download | php-git-f9927a6c97208c60d922f9a4e98feb8079c57d1f.tar.gz |
Merge mainstream 'master' branch into refactoring
During merge I had to revert:
Nikita's patch for php_splice() (it probably needs to be applyed again)
Bob Weinand's patches related to constant expression handling (we need to review them carefully)
I also reverted all our attempts to support sapi/phpdbg (we didn't test it anyway)
Conflicts:
Zend/zend.h
Zend/zend_API.c
Zend/zend_ast.c
Zend/zend_compile.c
Zend/zend_compile.h
Zend/zend_constants.c
Zend/zend_exceptions.c
Zend/zend_execute.c
Zend/zend_execute.h
Zend/zend_execute_API.c
Zend/zend_hash.c
Zend/zend_highlight.c
Zend/zend_language_parser.y
Zend/zend_language_scanner.c
Zend/zend_language_scanner_defs.h
Zend/zend_variables.c
Zend/zend_vm_def.h
Zend/zend_vm_execute.h
ext/date/php_date.c
ext/dom/documenttype.c
ext/hash/hash.c
ext/iconv/iconv.c
ext/mbstring/tests/zend_multibyte-10.phpt
ext/mbstring/tests/zend_multibyte-11.phpt
ext/mbstring/tests/zend_multibyte-12.phpt
ext/mysql/php_mysql.c
ext/mysqli/mysqli.c
ext/mysqlnd/mysqlnd_reverse_api.c
ext/mysqlnd/php_mysqlnd.c
ext/opcache/ZendAccelerator.c
ext/opcache/zend_accelerator_util_funcs.c
ext/opcache/zend_persist.c
ext/opcache/zend_persist_calc.c
ext/pcre/php_pcre.c
ext/pdo/pdo_dbh.c
ext/pdo/pdo_stmt.c
ext/pdo_pgsql/pgsql_driver.c
ext/pgsql/pgsql.c
ext/reflection/php_reflection.c
ext/session/session.c
ext/spl/spl_array.c
ext/spl/spl_observer.c
ext/standard/array.c
ext/standard/basic_functions.c
ext/standard/html.c
ext/standard/mail.c
ext/standard/php_array.h
ext/standard/proc_open.c
ext/standard/streamsfuncs.c
ext/standard/user_filters.c
ext/standard/var_unserializer.c
ext/standard/var_unserializer.re
main/php_variables.c
sapi/phpdbg/phpdbg.c
sapi/phpdbg/phpdbg_bp.c
sapi/phpdbg/phpdbg_frame.c
sapi/phpdbg/phpdbg_help.c
sapi/phpdbg/phpdbg_list.c
sapi/phpdbg/phpdbg_print.c
sapi/phpdbg/phpdbg_prompt.c
Diffstat (limited to 'sapi/apache2filter')
-rw-r--r-- | sapi/apache2filter/php_apache.h | 8 | ||||
-rw-r--r-- | sapi/apache2filter/sapi_apache2.c | 59 |
2 files changed, 30 insertions, 37 deletions
diff --git a/sapi/apache2filter/php_apache.h b/sapi/apache2filter/php_apache.h index 47fe98b5fd..8410414dc0 100644 --- a/sapi/apache2filter/php_apache.h +++ b/sapi/apache2filter/php_apache.h @@ -36,14 +36,10 @@ typedef struct php_struct { int state; request_rec *r; ap_filter_t *f; /* downstream output filters after the PHP filter. */ - /* Length of post_data buffer */ - int post_len; - /* Index for reading from buffer */ - int post_idx; /* stat structure of the current file */ struct stat finfo; - /* Buffer for request body filter */ - char *post_data; + /* Set-aside request body bucket brigade */ + apr_bucket_brigade *post_data; /* Whether or not we've processed PHP in the output filters yet. */ int request_processed; } php_struct; diff --git a/sapi/apache2filter/sapi_apache2.c b/sapi/apache2filter/sapi_apache2.c index 6b56e78545..4fd45041ba 100644 --- a/sapi/apache2filter/sapi_apache2.c +++ b/sapi/apache2filter/sapi_apache2.c @@ -94,11 +94,9 @@ 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_struct *ctx; - ap_filter_t *f; char *val, *ptr; ctx = SG(server_context); - f = ctx->r->output_filters; switch(op) { case SAPI_HEADER_DELETE: @@ -155,24 +153,29 @@ php_apache_sapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) static int php_apache_sapi_read_post(char *buf, uint count_bytes TSRMLS_DC) { - int n; - int to_read; + apr_size_t len; php_struct *ctx = SG(server_context); - - to_read = ctx->post_len - ctx->post_idx; - n = MIN(to_read, count_bytes); - - if (n > 0) { - memcpy(buf, ctx->post_data + ctx->post_idx, n); - ctx->post_idx += n; - } else { - if (ctx->post_data) free(ctx->post_data); - ctx->post_data = NULL; + apr_bucket_brigade *brigade; + apr_bucket *partition; + + brigade = ctx->post_data; + len = count_bytes; + + switch (apr_brigade_partition(ctx->post_data, count_bytes, &partition)) { + case APR_SUCCESS: + apr_brigade_flatten(ctx->post_data, buf, &len); + brigade = apr_brigade_split(ctx->post_data, partition); + apr_brigade_destroy(ctx->post_data); + ctx->post_data = brigade; + break; + case APR_INCOMPLETE: + apr_brigade_flatten(ctx->post_data, buf, &len); + apr_brigade_cleanup(ctx->post_data); + break; } - return n; + return len; } - static struct stat* php_apache_sapi_get_stat(TSRMLS_D) { @@ -359,10 +362,6 @@ static int php_input_filter(ap_filter_t *f, apr_bucket_brigade *bb, ap_input_mode_t mode, apr_read_type_e block, apr_off_t readbytes) { php_struct *ctx; - long old_index; - apr_bucket *b; - const char *str; - apr_size_t n; apr_status_t rv; TSRMLS_FETCH(); @@ -381,15 +380,15 @@ static int php_input_filter(ap_filter_t *f, apr_bucket_brigade *bb, return rv; } - for (b = APR_BRIGADE_FIRST(bb); b != APR_BRIGADE_SENTINEL(bb); b = APR_BUCKET_NEXT(b)) { - apr_bucket_read(b, &str, &n, APR_NONBLOCK_READ); - if (n > 0) { - old_index = ctx->post_len; - ctx->post_len += n; - ctx->post_data = realloc(ctx->post_data, ctx->post_len + 1); - memcpy(ctx->post_data + old_index, str, n); - } + if (!ctx->post_data) { + ctx->post_data = apr_brigade_create(f->r->pool, f->c->bucket_alloc); + } + if ((rv = ap_save_brigade(f, &ctx->post_data, &bb, f->r->pool)) != APR_SUCCESS) { + return rv; } + apr_brigade_cleanup(bb); + APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_eos_create(bb->bucket_alloc)); + return APR_SUCCESS; } @@ -412,8 +411,6 @@ static void php_apache_request_ctor(ap_filter_t *f, php_struct *ctx TSRMLS_DC) f->r->no_local_copy = 1; content_type = sapi_get_default_content_type(TSRMLS_C); f->r->content_type = apr_pstrdup(f->r->pool, content_type); - SG(request_info).post_data = ctx->post_data; - SG(request_info).post_data_length = ctx->post_len; efree(content_type); @@ -550,7 +547,7 @@ static int php_output_filter(ap_filter_t *f, apr_bucket_brigade *bb) php_execute_script(&zfd TSRMLS_CC); apr_table_set(ctx->r->notes, "mod_php_memory_usage", - apr_psprintf(ctx->r->pool, "%u", zend_memory_peak_usage(1 TSRMLS_CC))); + apr_psprintf(ctx->r->pool, "%lu", (unsigned long) zend_memory_peak_usage(1 TSRMLS_CC))); php_apache_request_dtor(f TSRMLS_CC); |