large SSI inclusions are truncated

Igor Sysoev is at rambler-co.ru
Sat Jun 16 13:38:41 MSD 2007


On Fri, Jun 08, 2007 at 10:37:14AM -0700, Evan Miller wrote:

> Igor Sysoev wrote:
> >On Fri, Jun 08, 2007 at 08:14:36AM +0000, Evan Miller wrote:
> >
> >>I find that files included in an SSI are truncated when:
> >>
> >>* the inclusion is retrieved from an upstream subrequest
> >>* the response to the subrequest is buffered to a file
> >>* the response to the subrequest is over about 100KB
> >>
> >>I am using nginx 0.5.24. It works fine when I set 
> >>"proxy_max_temp_file_size 0;".
> >>
> >>I can post a debug log if no one can reproduce the problem.
> >
> >Please, send me debug log.
> >
> >
> 
> Here's the debug log:
> 
> http://www.riceonfire.org/emiller/error.log
> 
> This seems to happen most often (only?) after a SIGHUP.
> 
> evanm at tim:~ nginx -V
> nginx version: nginx/0.5.24
> built by gcc 4.1.2 (Ubuntu 4.1.2-0ubuntu4)
> configure arguments: --with-debug
> 
> Here's what I did:
> 
> evanm at tim:~ sudo rm /usr/local/nginx/logs/error.log
> evanm at tim:~ sudo pkill -HUP nginx
> evanm at tim:~ wget http://localhost/static/test.html
> 
> Here's the contents of test.html:
> 
> <!--# include virtual="/guide2.html" -->
> 
> 
> The upstream is an Apache serving a static file.

The attached patch should fix the problem.


-- 
Igor Sysoev
http://sysoev.ru/en/
-------------- next part --------------
Index: src/http/ngx_http_copy_filter_module.c
===================================================================
--- src/http/ngx_http_copy_filter_module.c	(revision 578)
+++ src/http/ngx_http_copy_filter_module.c	(working copy)
@@ -117,6 +117,10 @@
             r->buffered |= NGX_HTTP_COPY_BUFFERED;
         }
 
+        if (r != r->main) {
+            r->out = ctx->in;
+        }
+
 #if (NGX_DEBUG)
         ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
                        "copy filter: %i \"%V?%V\"", rc, &r->uri, &r->args);
Index: src/http/ngx_http_upstream.c
===================================================================
--- src/http/ngx_http_upstream.c	(revision 578)
+++ src/http/ngx_http_upstream.c	(working copy)
@@ -2157,8 +2157,17 @@
 
     r->connection->log->action = "sending to client";
 
-    if (rc == 0 && r == r->main && !r->post_action) {
-        rc = ngx_http_send_special(r, NGX_HTTP_LAST);
+    if (rc == 0) {
+        if (r == r->main) {
+            if (rc == 0 && !r->post_action) {
+                rc = ngx_http_send_special(r, NGX_HTTP_LAST);
+            }
+
+        } else {
+            if (r->out) {
+                rc = NGX_AGAIN;
+            }
+        }
     }
 
     ngx_http_finalize_request(r, rc);


More information about the nginx mailing list