summaryrefslogtreecommitdiff
path: root/sapi
diff options
context:
space:
mode:
authorJérôme Loyet <fat@php.net>2011-11-15 22:29:59 +0000
committerJérôme Loyet <fat@php.net>2011-11-15 22:29:59 +0000
commit1546456cdd058f6e91f13a3acb23b67f29ead9bb (patch)
treea7556f330686f2ab7632423eec0f1a7ee59cf222 /sapi
parent3d190388382e64e12e7cf501952c98f4e8f71ef8 (diff)
downloadphp-git-1546456cdd058f6e91f13a3acb23b67f29ead9bb.tar.gz
- FR #60199 (enhance FPM error log when the primary script can't be open)
Diffstat (limited to 'sapi')
-rw-r--r--sapi/fpm/fpm/fpm_main.c14
1 files changed, 14 insertions, 0 deletions
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);
}