diff src/event/ngx_event_pipe.c @ 2:cc9f381affaa NGINX_0_1_1

nginx 0.1.1 *) Feature: the gzip_types directive. *) Feature: the tcp_nodelay directive. *) Feature: the send_lowat directive is working not only on OSes that support kqueue NOTE_LOWAT, but also on OSes that support SO_SNDLOWAT. *) Feature: the setproctitle() emulation for Linux and Solaris. *) Bugfix: the "Location" header rewrite bug fixed while the proxying. *) Bugfix: the ngx_http_chunked_module module may get caught in an endless loop. *) Bugfix: the /dev/poll module bugs fixed. *) Bugfix: the responses were corrupted when the temporary files were used while the proxying. *) Bugfix: the unescaped requests were passed to the backend. *) Bugfix: while the build configuration on Linux 2.4 the --with-poll_module parameter was required.
author Igor Sysoev <http://sysoev.ru>
date Mon, 11 Oct 2004 00:00:00 +0400
parents f0b350454894
children 80ba094c6b3e
line wrap: on
line diff
--- a/src/event/ngx_event_pipe.c
+++ b/src/event/ngx_event_pipe.c
@@ -64,8 +64,7 @@ ngx_int_t ngx_event_pipe(ngx_event_pipe_
 
     if (p->downstream->fd != -1) {
         wev = p->downstream->write;
-        wev->available = p->send_lowat;
-        if (ngx_handle_write_event(wev, NGX_LOWAT_EVENT) == NGX_ERROR) {
+        if (ngx_handle_write_event(wev, p->send_lowat) == NGX_ERROR) {
             return NGX_ABORT;
         }
 
@@ -302,16 +301,41 @@ ngx_int_t ngx_event_pipe_read_upstream(n
         ngx_log_debug0(NGX_LOG_DEBUG_EVENT, p->log, 0, "pipe buf");
     }
 
-    for (cl = p->in; cl; cl = cl->next) {
+    for (cl = p->busy; cl; cl = cl->next) {
         ngx_log_debug3(NGX_LOG_DEBUG_EVENT, p->log, 0,
-                       "pipe buf in " PTR_FMT ", pos " PTR_FMT ", size: %d",
+                       "pipe buf busy " PTR_FMT ", pos " PTR_FMT ", size: %d",
                        cl->buf->start, cl->buf->pos,
                        cl->buf->last - cl->buf->pos);
     }
 
-    for (cl = p->busy; cl; cl = cl->next) {
+    for (cl = p->out; cl; cl = cl->next) {
+        if (cl->buf->in_file && cl->buf->temporary) {
+            ngx_log_debug5(NGX_LOG_DEBUG_EVENT, p->log, 0,
+                           "pipe buf out shadow "
+                           PTR_FMT ", pos " PTR_FMT ", size: %d "
+                           "file: " OFF_T_FMT ", size: %d",
+                           cl->buf->start, cl->buf->pos,
+                           cl->buf->last - cl->buf->pos,
+                           cl->buf->file_pos,
+                           cl->buf->file_last - cl->buf->file_pos);
+
+        } else if (cl->buf->in_file) {
+            ngx_log_debug2(NGX_LOG_DEBUG_EVENT, p->log, 0,
+                           "pipe buf out file " OFF_T_FMT ", size: %d",
+                           cl->buf->file_pos,
+                           cl->buf->file_last - cl->buf->file_pos);
+        } else {
+            ngx_log_debug3(NGX_LOG_DEBUG_EVENT, p->log, 0,
+                           "pipe buf out " PTR_FMT ", pos " PTR_FMT
+                           ", size: %d",
+                           cl->buf->start, cl->buf->pos,
+                           cl->buf->last - cl->buf->pos);
+        }
+    }
+
+    for (cl = p->in; cl; cl = cl->next) {
         ngx_log_debug3(NGX_LOG_DEBUG_EVENT, p->log, 0,
-                       "pipe buf busy " PTR_FMT ", pos " PTR_FMT ", size: %d",
+                       "pipe buf in " PTR_FMT ", pos " PTR_FMT ", size: %d",
                        cl->buf->start, cl->buf->pos,
                        cl->buf->last - cl->buf->pos);
     }
@@ -337,7 +361,9 @@ ngx_int_t ngx_event_pipe_read_upstream(n
 
         if (p->free_bufs) {
             for (cl = p->free_raw_bufs; cl; cl = cl->next) {
-                ngx_pfree(p->pool, cl->buf->start); 
+                if (cl->buf->shadow == NULL) {
+                    ngx_pfree(p->pool, cl->buf->start); 
+                }
             }
         }
     }
@@ -597,8 +623,11 @@ static ngx_int_t ngx_event_pipe_write_ch
         ngx_chain_add_link(p->out, p->last_out, cl);
 
         if (b->last_shadow) {
-            b->shadow->last = b->shadow->pos = b->shadow->start;
+            b->shadow->pos = b->shadow->start;
+            b->shadow->last = b->shadow->start;
+
             ngx_alloc_link_and_set_buf(tl, b->shadow, p->pool, NGX_ABORT);
+
             *last_free = tl;
             last_free = &tl->next;
         }
@@ -650,28 +679,24 @@ ngx_inline static void ngx_event_pipe_re
 {
     ngx_buf_t  *b, *next;
 
-    if (buf->shadow == NULL) {
+    b = buf->shadow;
+
+    if (b == NULL) {
         return;
     }
 
-    b = buf->shadow;
-
     while (!b->last_shadow) {
         next = b->shadow;
 
-        b->in_file = 0;
-        b->temp_file = 0;
-        b->flush = 0;
-        b->zerocopy_busy = 0;
+        b->temporary = 0;
+        b->recycled = 0;
 
         b->shadow = NULL;
         b = next;
     }
 
-    b->in_file = 0;
-    b->temp_file = 0;
-    b->flush = 0;
-    b->zerocopy_busy = 0;
+    b->temporary = 0;
+    b->recycled = 0;
     b->last_shadow = 0;
 
     b->shadow = NULL;