]> git.kaiwu.me - nginx.git/commitdiff
nginx-0.0.9-2004-07-28-20:16:50 import
authorIgor Sysoev <igor@sysoev.ru>
Wed, 28 Jul 2004 16:16:50 +0000 (16:16 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Wed, 28 Jul 2004 16:16:50 +0000 (16:16 +0000)
src/core/ngx_output_chain.c
src/event/modules/ngx_rtsig_module.c
src/http/ngx_http_write_filter.c
src/os/unix/ngx_freebsd_sendfile_chain.c
src/os/unix/ngx_linux_sendfile_chain.c

index 02d780f3730e97b8f469ab533473d8e7c835d0d0..549c9ad167afefd27c91326d2fdab2b8bb69ab95 100644 (file)
@@ -73,6 +73,13 @@ ngx_int_t ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in)
                 continue;
             }
 
+            bsize = ngx_buf_size(ctx->in->buf);
+
+            if (bsize == 0) {
+                ctx->in = ctx->in->next;
+                continue;
+            }
+
             if (ctx->buf == NULL) {
 
                 /* get the free buf */
@@ -91,8 +98,6 @@ ngx_int_t ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in)
 
                     if (ctx->in->buf->last_buf) {
 
-                        bsize = ngx_buf_size(ctx->in->buf);
-
                         if (bsize < ctx->bufs.size) {
 
                            /*
index 3be8e6a8f1d273672e5ae3cd2d192f164a625052..6a83e9c1b7a64f17f9a5199339f85e95186a910e 100644 (file)
@@ -626,20 +626,20 @@ static ngx_int_t ngx_rtsig_process_overflow(ngx_cycle_t *cycle)
                               cycle->log, 0,
                               "poll() failed while the overflow recover");
 
-                if (err != NGX_EINTR) {
-                    break;
+                if (err == NGX_EINTR) {
+                    continue;
                 }
             }
+
+            break;
         }
 
         if (ready <= 0) {
             continue;
         }
 
-        if (n) {
-            if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) {
-                return NGX_ERROR;
-            }
+        if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) {
+            return NGX_ERROR;
         }
 
         for (i = 0; i < n; i++) {
@@ -686,9 +686,7 @@ static ngx_int_t ngx_rtsig_process_overflow(ngx_cycle_t *cycle)
             }
         }
 
-        if (n) {
-            ngx_mutex_unlock(ngx_posted_events_mutex);
-        }
+        ngx_mutex_unlock(ngx_posted_events_mutex);
 
         if (tested >= rtscf->overflow_test) {
 
@@ -723,7 +721,7 @@ static ngx_int_t ngx_rtsig_process_overflow(ngx_cycle_t *cycle)
                 }
 
                 /*
-                 * drain rt signal queue if the /proc/sys/kernel/rtsig-nr
+                 * drain the rt signal queue if the /proc/sys/kernel/rtsig-nr
                  * is bigger than
                  *    /proc/sys/kernel/rtsig-max / rtsig_overflow_threshold
                  */
@@ -741,7 +739,7 @@ static ngx_int_t ngx_rtsig_process_overflow(ngx_cycle_t *cycle)
 
                 /*
                  * Linux has not KERN_RTSIGMAX since 2.6.6-mm2
-                 * so drain rt signal queue unconditionally
+                 * so drain the rt signal queue unconditionally
                  */
 
                 while (ngx_rtsig_process_events(cycle) == NGX_OK) { /* void */ }
index 2c0989d0a4ef7e9f079290cf43af60c4e1c392d7..c6cc6519a09489e9a2554069aa9bde1907a57087 100644 (file)
@@ -40,7 +40,7 @@ ngx_module_t  ngx_http_write_filter_module = {
 ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
 {
     int                           last;
-    off_t                         size, flush, sent;
+    off_t                         size, flush, sent, bsize;
     ngx_chain_t                  *cl, *ln, **ll, *chain;
     ngx_connection_t             *c;
     ngx_http_core_loc_conf_t     *clcf;
@@ -82,7 +82,13 @@ ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
         *ll = cl;
         ll = &cl->next;
 
-        size += ngx_buf_size(cl->buf);
+        bsize = ngx_buf_size(cl->buf);
+
+        if (bsize == 0 && cl->buf->in_file) {
+            cl->buf->in_file = 0;
+        }
+
+        size += bsize;
 
         if (cl->buf->flush || cl->buf->recycled) {
             flush = size;
index f79b79bc2580b672fa4c073a2c951903ae0e25f9..5227a21bdcd54d232d5406132a628c52b40996db 100644 (file)
@@ -120,7 +120,6 @@ ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
 
         if (cl && cl->buf->in_file && send < limit) {
             file = cl->buf;
-            fsize = 0;
 
             /* coalesce the neighbouring file bufs */
 
index 690631f311350b26c367e0600762de95d24704af..48c09dffadfb9fbee42f0d5632a45bcc6c97c6d7 100644 (file)
@@ -127,7 +127,6 @@ ngx_chain_t *ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
 
         if (header.nelts == 0 && cl && cl->buf->in_file && send < limit) {
             file = cl->buf;
-            fsize = 0;
 
             /* coalesce the neighbouring file bufs */