diff src/event/ngx_event_pipe.c @ 284:3dbecd747fbb NGINX_0_5_12

nginx 0.5.12 *) Bugfix: nginx could not be built on platforms different from i386, amd64, sparc и ppc; bug appeared in 0.5.8. *) Bugfix: a segmentation fault might occur in worker process if the temporarily files were used while working with FastCGI server; bug appeared in 0.5.8. *) Bugfix: a segmentation fault might occur in worker process if the $fastcgi_script_name variable was logged. *) Bugfix: ngx_http_perl_module could not be built on Solaris.
author Igor Sysoev <http://sysoev.ru>
date Mon, 12 Feb 2007 00:00:00 +0300
parents c5c2b2883984
children 10cc350ed8a1
line wrap: on
line diff
--- a/src/event/ngx_event_pipe.c
+++ b/src/event/ngx_event_pipe.c
@@ -419,6 +419,7 @@ ngx_event_pipe_read_upstream(ngx_event_p
 static ngx_int_t
 ngx_event_pipe_write_to_downstream(ngx_event_pipe_t *p)
 {
+    u_char            *prev;
     size_t             bsize;
     ngx_uint_t         flush, prev_last_shadow;
     ngx_chain_t       *out, **ll, *cl;
@@ -497,11 +498,18 @@ ngx_event_pipe_write_to_downstream(ngx_e
 
         /* bsize is the size of the busy recycled bufs */
 
+        prev = NULL;
         bsize = 0;
 
         for (cl = p->busy; cl; cl = cl->next) {
+
             if (cl->buf->recycled) {
+                if (prev == cl->buf->start) {
+                    continue;
+                }
+
                 bsize += cl->buf->end - cl->buf->start;
+                prev = cl->buf->start;
             }
         }
 
@@ -509,8 +517,14 @@ ngx_event_pipe_write_to_downstream(ngx_e
                        "pipe write busy: %uz", bsize);
 
         out = NULL;
+
+        if (bsize >= (size_t) p->busy_size) {
+            flush = 1;
+            goto flush;
+        }
+
+        flush = 0;
         ll = NULL;
-        flush = 0;
         prev_last_shadow = 1;
 
         for ( ;; ) {
@@ -579,6 +593,8 @@ ngx_event_pipe_write_to_downstream(ngx_e
             ll = &cl->next;
         }
 
+    flush:
+
         ngx_log_debug2(NGX_LOG_DEBUG_EVENT, p->log, 0,
                        "pipe write: out:%p, f:%d", out, flush);