]> git.kaiwu.me - nginx.git/commitdiff
Merged conditions in the ngx_*_sendfile_chain() functions.
authorValentin Bartenev <vbart@nginx.com>
Wed, 13 Aug 2014 11:11:45 +0000 (15:11 +0400)
committerValentin Bartenev <vbart@nginx.com>
Wed, 13 Aug 2014 11:11:45 +0000 (15:11 +0400)
No functional changes.

src/os/unix/ngx_darwin_sendfile_chain.c
src/os/unix/ngx_freebsd_sendfile_chain.c
src/os/unix/ngx_linux_sendfile_chain.c

index a85269dcd44cca4705d0503e1dc75fc5d594cfcf..3caad0790fbb8de407a903eb5e83eee079c3b2af 100644 (file)
@@ -75,8 +75,6 @@ ngx_darwin_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
     trailer.nalloc = NGX_IOVS_PREALLOCATE;
 
     for ( ;; ) {
-        file = NULL;
-        file_size = 0;
         eintr = 0;
         prev_send = send;
 
@@ -98,22 +96,21 @@ ngx_darwin_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
             file_size = ngx_chain_coalesce_file(&cl, limit - send);
 
             send += file_size;
-        }
-
-        if (file && header.count == 0) {
 
-            /* create the trailer iovec and coalesce the neighbouring bufs */
+            if (header.count == 0) {
 
-            cl = ngx_output_chain_to_iovec(&trailer, cl, limit - send, c->log);
+                /*
+                 * create the trailer iovec and coalesce the neighbouring bufs
+                 */
 
-            if (cl == NGX_CHAIN_ERROR) {
-                return NGX_CHAIN_ERROR;
-            }
+                cl = ngx_output_chain_to_iovec(&trailer, cl, limit - send, c->log);
 
-            send += trailer.size;
-        }
+                if (cl == NGX_CHAIN_ERROR) {
+                    return NGX_CHAIN_ERROR;
+                }
 
-        if (file) {
+                send += trailer.size;
+            }
 
             /*
              * sendfile() returns EINVAL if sf_hdtr's count is 0,
index 96d783e277e06c3f83b65a3ef4ead5eaa4ed7fa3..76f6ef235460928f2e4db8ea30bb7c9b4fefb390 100644 (file)
@@ -79,8 +79,6 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
     trailer.nalloc = NGX_IOVS_PREALLOCATE;
 
     for ( ;; ) {
-        file = NULL;
-        file_size = 0;
         eintr = 0;
         prev_send = send;
 
@@ -102,10 +100,6 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
             file_size = (size_t) ngx_chain_coalesce_file(&cl, limit - send);
 
             send += file_size;
-        }
-
-
-        if (file) {
 
             /* create the trailer iovec and coalesce the neighbouring bufs */
 
@@ -116,9 +110,6 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
             }
 
             send += trailer.size;
-        }
-
-        if (file) {
 
             if (ngx_freebsd_use_tcp_nopush
                 && c->tcp_nopush == NGX_TCP_NOPUSH_UNSET)
index 417c19b02ef789d46e93cb17d188791afa494ac9..c83677f0f8a62c7afeef1e22800d4f3479cc66a8 100644 (file)
@@ -66,8 +66,6 @@ ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
     header.nalloc = NGX_IOVS_PREALLOCATE;
 
     for ( ;; ) {
-        file = NULL;
-        file_size = 0;
         eintr = 0;
         prev_send = send;
 
@@ -156,9 +154,6 @@ ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
             file_size = (size_t) ngx_chain_coalesce_file(&cl, limit - send);
 
             send += file_size;
-        }
-
-        if (file) {
 #if 1
             if (file_size == 0) {
                 ngx_debug_point();