Commit:cc58373d4d9b0b3d8b0e2cbf86dfee37da799c77
Author:Xinchen Hui larue...@php.net Sat, 21 Apr 2012 00:01:10
+0800
Parents: bca2d6b985dee0d120b0f14f088c1238f8eeef15
Branches: PHP-5.4
Link:
http://git.php.net/?p=php-src.git;a=commitdiff;h=cc58373d4d9b0b3d8b0e2cbf86dfee37da799c77
Log:
Improved performance while sending error page
this also fixed bug #61785 (Memory leak when access a non-exists file without
router)
Bugs:
https://bugs.php.net/61785
Changed paths:
M NEWS
M sapi/cli/php_cli_server.c
Diff:
diff --git a/NEWS b/NEWS
index b2c6a8d..b336316 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,9 @@ PHP
NEWS
?? ??? 2012, PHP 5.4.1 RC1
- CLI Server:
+ . Improved performance while sending error page, this also fixed
+bug #61785 (Memory leak when access a non-exists file without router).
+(Laruence)
. Fixed bug #61461 (missing checks around malloc() calls). (Ilia)
. Implemented FR #60850 (Built in web server does not set
$_SERVER['SCRIPT_FILENAME'] when using router). (Laruence)
diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c
index 79ccea3..105fd60 100644
--- a/sapi/cli/php_cli_server.c
+++ b/sapi/cli/php_cli_server.c
@@ -98,7 +98,6 @@
#include ext/standard/html.h
#include ext/standard/url.h /* for php_url_decode() */
#include ext/standard/php_string.h /* for php_dirname() */
-#include ext/standard/info.h /* for php_info_print_style() */
#include php_network.h
#include php_http_parser.h
@@ -174,8 +173,6 @@ typedef struct php_cli_server_client {
php_cli_server_request request;
unsigned int content_sender_initialized:1;
php_cli_server_content_sender content_sender;
- php_cli_server_buffer capture_buffer;
- unsigned int capturing:1;
int file_fd;
} php_cli_server_client;
@@ -276,6 +273,27 @@ static void
php_cli_server_log_response(php_cli_server_client *client, int statu
ZEND_DECLARE_MODULE_GLOBALS(cli_server);
+/* {{{ static char php_cli_server_css[]
+ * copied from ext/standard/info.c
+ */
+static char php_cli_server_css[] = style type=\text/css\\n \
+ body
{background-color: #ff; color: #00;}\n \
+ body, td,
th, h1, h2 {font-family: sans-serif;}\n \
+ .center
{text-align: center;}\n \
+ .center
table { margin-left: auto; margin-right: auto; text-align: left;}\n \
+ .center th
{ text-align: center !important; }\n \
+ h1
{font-size: 150%;}\n \
+ h2
{font-size: 125%;}\n \
+ .p
{text-align: left;}\n \
+ .e
{background-color: #ff; font-weight: bold; color: #00;}\n \
+ .h
{background-color: #cc; font-weight: bold; color: #00;}\n \
+ .v
{background-color: #cc; color: #00;}\n \
+ .vr
{background-color: #cc; text-align: right; color: #00;}\n \
+ img {float:
right; border: 0px;}\n \
+ hr {width:
600px; background-color: #cc; border: 0px; height: 1px; color: #00;}\n
\
+ /style\n;
+/* }}} */
+
static void char_ptr_dtor_p(char **p) /* {{{ */
{
pefree(*p, 1);
@@ -425,17 +443,7 @@ static int sapi_cli_server_ub_write(const char *str, uint
str_length TSRMLS_DC)
if (!client) {
return 0;
}
- if (client-capturing) {
- php_cli_server_chunk *chunk =
php_cli_server_chunk_heap_new_self_contained(str_length);
- if (!chunk) {
- zend_bailout();
- }
- memmove(chunk-data.heap.p, str, str_length);
- php_cli_server_buffer_append(client-capture_buffer, chunk);
- return str_length;
- } else {
- return php_cli_server_client_send_through(client, str,
str_length);
- }
+ return php_cli_server_client_send_through(client, str, str_length);
} /* }}} */
static void sapi_cli_server_flush(void *server_context) /* {{{ */
@@ -470,7 +478,7 @@ static int sapi_cli_server_send_headers(sapi_headers_struct
*sapi_headers TSRMLS