diff src/core/ngx_output_chain.c @ 4:4b2dafa26fe2 NGINX_0_1_2

nginx 0.1.2 *) Feature: the --user=USER, --group=GROUP, and --with-ld-opt=OPTIONS options in configure. *) Feature: the server_name directive supports *.domain.tld. *) Bugfix: the portability improvements. *) Bugfix: if configuration file was set in command line, the reconfiguration was impossible; bug appeared in 0.1.1. *) Bugfix: proxy module may get caught in an endless loop when sendfile is not used. *) Bugfix: with sendfile the response was not recoded according to the charset module directives; bug appeared in 0.1.1. *) Bugfix: very seldom bug in the kqueue processing. *) Bugfix: the gzip module compressed the proxied responses that was already compressed.
author Igor Sysoev <http://sysoev.ru>
date Thu, 21 Oct 2004 00:00:00 +0400
parents cc9f381affaa
children 46833bd150cb
line wrap: on
line diff
--- a/src/core/ngx_output_chain.c
+++ b/src/core/ngx_output_chain.c
@@ -24,13 +24,13 @@ ngx_int_t ngx_output_chain(ngx_output_ch
     size_t        size, bsize;
     ngx_chain_t  *cl, *out, **last_out;
 
-    /*
-     * the short path for the case when the ctx->in chain is empty
-     * and the incoming chain is empty too or it has the single buf
-     * that does not require the copy
-     */
+    if (ctx->in == NULL && ctx->busy == NULL) {
 
-    if (ctx->in == NULL) {
+       /*
+        * the short path for the case when the ctx->in and ctx->busy chains
+        * are empty, the incoming chain is empty too or has the single buf
+        * that does not require the copy
+        */
 
         if (in == NULL) {
             return ctx->output_filter(ctx->filter_ctx, in);
@@ -192,6 +192,7 @@ ngx_inline static ngx_int_t
     }
 
     if (!ctx->sendfile) {
+
         if (!ngx_buf_in_memory(buf)) {
             return 1;
         }
@@ -228,12 +229,19 @@ static ngx_int_t ngx_output_chain_copy_b
         src->pos += size;
         dst->last += size;
 
-        if (src->in_file && sendfile) {
-            dst->in_file = 1;
-            dst->file = src->file;
-            dst->file_pos = src->file_pos;
+        if (src->in_file) {
+
+            if (sendfile) {
+                dst->in_file = 1;
+                dst->file = src->file;
+                dst->file_pos = src->file_pos;
+                dst->file_last = src->file_pos + size;
+
+            } else {
+                dst->in_file = 0;
+            }
+
             src->file_pos += size;
-            dst->file_last = src->file_pos;
 
         } else {
             dst->in_file = 0;
@@ -271,14 +279,14 @@ static ngx_int_t ngx_output_chain_copy_b
             dst->in_file = 1;
             dst->file = src->file;
             dst->file_pos = src->file_pos;
-            src->file_pos += size;
-            dst->file_last = src->file_pos;
+            dst->file_last = src->file_pos + n;
 
         } else {
             dst->in_file = 0;
-            src->file_pos += n;
         }
 
+        src->file_pos += n;
+
         if (src->last_buf && src->file_pos == src->file_last) {
             dst->last_buf = 1;
         }