diff src/event/ngx_event_pipe.c @ 28:7ca9bdc82b3f NGINX_0_1_14

nginx 0.1.14 *) Feature: the autoconfiguration directives: --http-client-body-temp-path=PATH, --http-proxy-temp-path=PATH, and --http-fastcgi-temp-path=PATH *) Change: the directory name for the temporary files with the client request body is specified by directive client_body_temp_path, by default it is <prefix>/client_body_temp. *) Feature: the ngx_http_fastcgi_module and the directives: fastcgi_pass, fastcgi_root, fastcgi_index, fastcgi_params, fastcgi_connect_timeout, fastcgi_send_timeout, fastcgi_read_timeout, fastcgi_send_lowat, fastcgi_header_buffer_size, fastcgi_buffers, fastcgi_busy_buffers_size, fastcgi_temp_path, fastcgi_max_temp_file_size, fastcgi_temp_file_write_size, fastcgi_next_upstream, and fastcgi_x_powered_by. *) Bugfix: the "[alert] zero size buf" error; bug appeared in 0.1.3. *) Change: the URI must be specified after the host name in the proxy_pass directive. *) Change: the %3F symbol in the URI was considered as the argument string start. *) Feature: the unix domain sockets support in the ngx_http_proxy_module. *) Feature: the ssl_engine and ssl_ciphers directives. Thanks to Sergey Skvortsov for SSL-accelerator.
author Igor Sysoev <http://sysoev.ru>
date Tue, 18 Jan 2005 00:00:00 +0300
parents 8b6db3bda591
children da8c190bdaba
line wrap: on
line diff
--- a/src/event/ngx_event_pipe.c
+++ b/src/event/ngx_event_pipe.c
@@ -379,7 +379,7 @@ ngx_int_t ngx_event_pipe_read_upstream(n
 
 ngx_int_t ngx_event_pipe_write_to_downstream(ngx_event_pipe_t *p)
 {
-    off_t         bsize;
+    size_t        bsize;
     ngx_uint_t    flush;
     ngx_buf_t    *b;
     ngx_chain_t  *out, **ll, *cl, *tl;
@@ -433,16 +433,18 @@ ngx_int_t ngx_event_pipe_write_to_downst
             break;
         }
 
-        /* bsize is the size of the busy bufs */
+        /* bsize is the size of the busy recycled bufs */
 
         bsize = 0;
 
         for (cl = p->busy; cl; cl = cl->next) {
-            bsize += cl->buf->end - cl->buf->start;
+            if (cl->buf->recycled) {
+                bsize += cl->buf->end - cl->buf->start;
+            }
         }
 
         ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0,
-                       "pipe write busy: %O", bsize);
+                       "pipe write busy: %uz", bsize);
 
         out = NULL;
         ll = NULL;
@@ -452,19 +454,23 @@ ngx_int_t ngx_event_pipe_write_to_downst
             if (p->out) {
                 cl = p->out;
 
-                if (bsize + ngx_buf_size(cl->buf) > p->busy_size) {
+                if (cl->buf->recycled
+                    && bsize + cl->buf->last - cl->buf->pos > p->busy_size)
+                {
                     flush = 1;
                     break;
                 }
 
                 p->out = p->out->next;
-                ngx_event_pipe_free_shadow_raw_buf(&p->free_raw_bufs,
-                                                   cl->buf);
+
+                ngx_event_pipe_free_shadow_raw_buf(&p->free_raw_bufs, cl->buf);
 
             } else if (!p->cachable && p->in) {
                 cl = p->in;
 
-                if (bsize + ngx_buf_size(cl->buf) > p->busy_size) {
+                if (cl->buf->recycled
+                    && bsize + cl->buf->last - cl->buf->pos > p->busy_size)
+                {
                     flush = 1;
                     break;
                 }
@@ -475,7 +481,10 @@ ngx_int_t ngx_event_pipe_write_to_downst
                 break;
             }
 
-            bsize += ngx_buf_size(cl->buf);
+            if (cl->buf->recycled) {
+                bsize += cl->buf->last - cl->buf->pos;
+            }
+
             cl->next = NULL;
             ngx_chain_add_link(out, ll, cl);
         }
@@ -618,8 +627,6 @@ static ngx_int_t ngx_event_pipe_write_ch
 
         b->in_file = 1;
         b->temp_file = 1;
-        b->temporary = 0;
-        b->recycled = 0;
 
         ngx_chain_add_link(p->out, p->last_out, cl);
 
@@ -668,7 +675,7 @@ ngx_int_t ngx_event_pipe_copy_input_filt
 
     ngx_alloc_link_and_set_buf(cl, b, p->pool, NGX_ERROR);
 
-    ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, "buf #%d", b->num);
+    ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, "input buf #%d", b->num);
 
     ngx_chain_add_link(p->in, p->last_in, cl);
 
@@ -781,7 +788,14 @@ static ngx_int_t ngx_event_pipe_drain_ch
                 b = cl->buf->shadow;
                 b->pos = b->last = b->start;
                 b->shadow = NULL;
-                ngx_alloc_link_and_set_buf(tl, b, p->pool, NGX_ABORT);
+
+                if (!(tl = ngx_alloc_chain_link(p->pool))) {
+                    return NGX_ABORT;
+                }
+
+                tl->buf = b;
+                tl->next = NULL;
+
                 ngx_event_pipe_add_free_buf(&p->free_raw_bufs, tl);
 
                 cl->buf->last_shadow = 0;