summaryrefslogtreecommitdiff
path: root/sapi
diff options
context:
space:
mode:
authorAndrey Hristov <andrey@php.net>2014-04-10 16:49:13 +0300
committerAndrey Hristov <andrey@php.net>2014-04-10 16:49:13 +0300
commit090c3e87c0449e6eadf83815bb57c8a6eff4b56e (patch)
tree946fdc55ed17d2dc07a99b388565cc96197026dd /sapi
parent63791d055ad64762c3f63e08ca7ad8ba1f44e0ab (diff)
parent3204ad5858a5abc50b11b8527d22c82eb07a80cc (diff)
downloadphp-git-090c3e87c0449e6eadf83815bb57c8a6eff4b56e.tar.gz
Merge branch 'PHP-5.6' of git.php.net:php-src into PHP-5.6
Conflicts: ext/mysqli/tests/mysqli_begin_transaction.phpt
Diffstat (limited to 'sapi')
-rw-r--r--sapi/apache2filter/php_apache.h8
-rw-r--r--sapi/apache2filter/sapi_apache2.c59
-rw-r--r--sapi/cli/tests/upload_2G.phpt2
-rw-r--r--sapi/embed/config.w322
-rw-r--r--sapi/phpdbg/phpdbg.c1
5 files changed, 34 insertions, 38 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 da920f818c..d5bf0d8646 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)
{
@@ -360,10 +363,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();
@@ -382,15 +381,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;
}
@@ -413,8 +412,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);
@@ -551,7 +548,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);
diff --git a/sapi/cli/tests/upload_2G.phpt b/sapi/cli/tests/upload_2G.phpt
index 707eddbad3..313dcd5ac1 100644
--- a/sapi/cli/tests/upload_2G.phpt
+++ b/sapi/cli/tests/upload_2G.phpt
@@ -19,7 +19,7 @@ if ($f = fopen("/proc/meminfo","r")) {
}
if (empty($enough_free_ram)) {
- die("need +3G free RAM");
+ die("skip need +3G free RAM");
}
?>
--FILE--
diff --git a/sapi/embed/config.w32 b/sapi/embed/config.w32
index f3cc60d600..64e44bdd94 100644
--- a/sapi/embed/config.w32
+++ b/sapi/embed/config.w32
@@ -3,6 +3,8 @@
ARG_ENABLE('embed', 'Embedded SAPI library', 'no');
+var PHP_EMBED_PGO = false;
+
if (PHP_EMBED != "no") {
SAPI('embed', 'php_embed.c', 'php' + PHP_VERSION + 'embed.lib');
PHP_INSTALL_HEADERS("sapi/embed", "php_embed.h");
diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c
index 6cb1645e65..51a328d0b5 100644
--- a/sapi/phpdbg/phpdbg.c
+++ b/sapi/phpdbg/phpdbg.c
@@ -35,6 +35,7 @@
# include <sys/select.h>
# include <sys/time.h>
# include <sys/types.h>
+# include <netinet/in.h>
# include <unistd.h>
# include <arpa/inet.h>
#endif /* }}} */