special-responses: fix for hanging sometimes on special responses (#1238)

After calling ngx_http_filter_finalize_request return NGX_DONE
as we are still in pre-access phase. This bug shows up when the
"special" response is generated from, for example, php as opposed
to a static file.

Second part of the fix for
https://github.com/pagespeed/ngx_pagespeed/issues/1146
This commit is contained in:
Otto van der Schaaf
2016-09-07 10:49:53 +02:00
committed by GitHub
parent 2d24ec68f1
commit 76eeec5972
3 changed files with 25 additions and 1 deletions
+2 -1
View File
@@ -288,7 +288,8 @@ ngx_int_t ps_base_fetch_handler(ngx_http_request_t* r) {
if (!status_ok && (ctx->base_fetch->base_fetch_type() != kHtmlTransform if (!status_ok && (ctx->base_fetch->base_fetch_type() != kHtmlTransform
&& ctx->base_fetch->base_fetch_type() != kIproLookup)) { && ctx->base_fetch->base_fetch_type() != kIproLookup)) {
ps_release_base_fetch(ctx); ps_release_base_fetch(ctx);
return ngx_http_filter_finalize_request(r, NULL, status_code); ngx_http_filter_finalize_request(r, NULL, status_code);
return NGX_DONE;
} }
if (ctx->preserve_caching_headers != kDontPreserveHeaders) { if (ctx->preserve_caching_headers != kDontPreserveHeaders) {
+7
View File
@@ -1351,6 +1351,12 @@ URL="http://noflush.example.com/mod_pagespeed_test/slow_flushing_html_response.p
check_flushing "curl -N --raw --silent --proxy $SECONDARY_HOSTNAME $URL" \ check_flushing "curl -N --raw --silent --proxy $SECONDARY_HOSTNAME $URL" \
5.4 1 5.4 1
start_test Special responses from php are handled OK.
URL="http://special-response.example.com/A.foo.css.pagespeed.cf.0.css"
OUT=$(http_proxy=$SECONDARY_HOSTNAME $WGET_DUMP -S --content-on-error $URL 2>&1) || true
check_from "$OUT" fgrep -qi '404'
check_from "$OUT" fgrep -q "PHP with a call to flush"
start_test Shutting down. start_test Shutting down.
# Fire up some heavy load if ab is available to test a stressed shutdown # Fire up some heavy load if ab is available to test a stressed shutdown
@@ -1434,6 +1440,7 @@ OUT=$(cat "$ERROR_LOG" \
| grep -v "\\[warn\\].*Rewrite.*failed.*.pagespeed....0.foo.*" \ | grep -v "\\[warn\\].*Rewrite.*failed.*.pagespeed....0.foo.*" \
| grep -v "\\[warn\\].*A.blue.css.*but cannot access the original.*" \ | grep -v "\\[warn\\].*A.blue.css.*but cannot access the original.*" \
| grep -v "\\[warn\\].*Adding function to sequence.*" \ | grep -v "\\[warn\\].*Adding function to sequence.*" \
| grep -v "\\[warn\\].*special-response.*foo.css.*but cannot access the original.*" \
|| true) || true)
check [ -z "$OUT" ] check [ -z "$OUT" ]
+16
View File
@@ -1616,6 +1616,22 @@ http {
fastcgi_buffering off; fastcgi_buffering off;
} }
} }
server {
pagespeed on;
listen @@SECONDARY_PORT@@;
listen [::]:@@SECONDARY_PORT@@;
server_name special-response.example.com;
pagespeed FileCachePath "@@FILE_CACHE@@";
error_page 404 /mod_pagespeed_test/php_withflush.php;
location ~ \.php$ {
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_pass 127.0.0.1:9000;
}
}
server { server {
pagespeed on; pagespeed on;
listen @@SECONDARY_PORT@@; listen @@SECONDARY_PORT@@;