diff src/http/ngx_http_output_filter.c @ 94:8220378432a8

nginx-0.0.1-2003-05-22-19:23:47 import
author Igor Sysoev <igor@sysoev.ru>
date Thu, 22 May 2003 15:23:47 +0000
parents 637625a2acdb
children b48066122884
line wrap: on
line diff
--- a/src/http/ngx_http_output_filter.c
+++ b/src/http/ngx_http_output_filter.c
@@ -58,15 +58,6 @@ ngx_module_t  ngx_http_output_filter_mod
 
 #define next_filter  (*ngx_http_top_body_filter)
 
-#if 0
-static int (*next_filter) (ngx_http_request_t *r, ngx_chain_t *ch);
-#endif
-
-
-#if 0
-#define next_filter  ngx_http_output_filter_module_ctx.next_output_body_filter
-#endif
-
 #define need_to_copy(r, hunk)                                             \
             (((r->filter & NGX_HTTP_FILTER_NEED_IN_MEMORY)                \
                && (hunk->type & NGX_HUNK_IN_MEMORY) == 0)                 \
@@ -159,6 +150,8 @@ int ngx_http_output_filter(ngx_http_requ
             return rc;
         }
 
+ngx_log_debug(r->connection->log, "HERE");
+
         /* NGX_OK */
         /* set our hunk free */
         ctx->hunk->pos = ctx->hunk->last = ctx->hunk->start;
@@ -211,6 +204,20 @@ int ngx_http_output_filter(ngx_http_requ
                 return rc;
             }
 #endif
+
+            if (ctx->incoming->hunk->type & NGX_HUNK_IN_MEMORY) {
+                size = ctx->incoming->hunk->last - ctx->incoming->hunk->pos;
+
+            } else {
+                size = ctx->incoming->hunk->file_last
+                                               - ctx->incoming->hunk->file_pos;
+            }
+
+            /* delete the completed hunk from the incoming chain */
+            if (size == 0) {
+                ctx->incoming = ctx->incoming->next;
+            }
+
             ctx->out.hunk = ctx->hunk;
             ctx->out.next = NULL;
 
@@ -226,19 +233,8 @@ int ngx_http_output_filter(ngx_http_requ
             /* repeat until we will have copied the whole first hunk from
                the chain ctx->incoming */
 
-            if (ctx->incoming->hunk->type & NGX_HUNK_IN_MEMORY) {
-                size = ctx->incoming->hunk->last - ctx->incoming->hunk->pos;
-
-            } else {
-                size = ctx->incoming->hunk->file_last
-                                               - ctx->incoming->hunk->file_pos;
-            }
-
         } while (size);
 
-    /* delete the completed hunk from the incoming chain */
-    ctx->incoming = ctx->incoming->next;
-
     /* repeat until we will have processed the whole chain ctx->incoming */
     } while (ctx->incoming);
 
@@ -276,6 +272,12 @@ static int ngx_http_output_filter_copy_h
     } else {
         n = ngx_read_file(src->file, dst->pos, size, src->file_pos);
 
+if (n == 0) {
+ngx_log_debug(src->file->log, "READ: %qd:%qd %X:%X %X:%X" _
+              src->file_pos _ src->file_last _
+              dst->pos _ dst->last _ dst->start _ dst->end);
+}
+
         if (n == NGX_ERROR) {
             return n;
         }