From: Jérôme Loyet Date: Tue, 15 Nov 2011 22:29:59 +0000 (+0000) Subject: - FR #60199 (enhance FPM error log when the primary script can't be open) X-Git-Tag: php-5.4.0RC2~69 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8bdf576a1f8f2438792a6238ebb80ab62bd23509;p=php - FR #60199 (enhance FPM error log when the primary script can't be open) --- diff --git a/NEWS b/NEWS index 3b8f12216f..c4fd137f4c 100644 --- a/NEWS +++ b/NEWS @@ -32,6 +32,10 @@ PHP NEWS resource). (Laruence) . Fixed bug #55759 (memory leak when using built-in server). (Laruence) +- Improved PHP-FPM SAPI: + . enhance error log when the primary script can't be open. FR #60199. (fat) + + 11 Nov 2011, PHP 5.4.0 RC1 - General improvements: . Changed silent conversion of array to string to produce a notice. (Patrick) diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c index 6ad53df4f1..fd453668ee 100644 --- a/sapi/fpm/fpm/fpm_main.c +++ b/sapi/fpm/fpm/fpm_main.c @@ -1785,6 +1785,7 @@ consult the installation file that came with this distribution, or visit \n\ SG(server_context) = (void *) &request; init_request_info(TSRMLS_C); CG(interactive) = 0; + char *primary_script = NULL; fpm_request_info(); @@ -1810,7 +1811,9 @@ consult the installation file that came with this distribution, or visit \n\ /* If path_translated is NULL, terminate here with a 404 */ if (!SG(request_info).path_translated) { zend_try { + zlog(ZLOG_DEBUG, "Primary script unknown"); SG(sapi_headers).http_response_code = 404; + PUTS("File not found.\n"); } zend_catch { } zend_end_try(); goto fastcgi_request_done; @@ -1822,9 +1825,16 @@ consult the installation file that came with this distribution, or visit \n\ goto fastcgi_request_done; } + /* + * have to duplicate SG(request_info).path_translated to be able to log errrors + * php_fopen_primary_script seems to delete SG(request_info).path_translated on failure + */ + primary_script = estrdup(SG(request_info).path_translated); + /* path_translated exists, we can continue ! */ if (php_fopen_primary_script(&file_handle TSRMLS_CC) == FAILURE) { zend_try { + zlog(ZLOG_ERROR, "Unable to open primary script: %s (%s)", primary_script, strerror(errno)); if (errno == EACCES) { SG(sapi_headers).http_response_code = 403; PUTS("Access denied.\n"); @@ -1846,6 +1856,10 @@ consult the installation file that came with this distribution, or visit \n\ php_execute_script(&file_handle TSRMLS_CC); fastcgi_request_done: + if (primary_script) { + efree(primary_script); + } + if (request_body_fd != -1) { close(request_body_fd); }