[nginx] Merged conditions in the ngx_*_sendfile_chain() functions.

Valentin Bartenev vbart at nginx.com
Wed Nov 19 18:19:09 UTC 2014


details:   http://hg.nginx.org/nginx/rev/e044893b4587
branches:  
changeset: 5916:e044893b4587
user:      Valentin Bartenev <vbart at nginx.com>
date:      Wed Aug 13 15:11:45 2014 +0400
description:
Merged conditions in the ngx_*_sendfile_chain() functions.

No functional changes.

diffstat:

 src/os/unix/ngx_darwin_sendfile_chain.c  |  23 ++++++++++-------------
 src/os/unix/ngx_freebsd_sendfile_chain.c |   9 ---------
 src/os/unix/ngx_linux_sendfile_chain.c   |   5 -----
 3 files changed, 10 insertions(+), 27 deletions(-)

diffs (101 lines):

diff -r ac3f78219f85 -r e044893b4587 src/os/unix/ngx_darwin_sendfile_chain.c
--- a/src/os/unix/ngx_darwin_sendfile_chain.c	Wed Aug 13 15:11:45 2014 +0400
+++ b/src/os/unix/ngx_darwin_sendfile_chain.c	Wed Aug 13 15:11:45 2014 +0400
@@ -75,8 +75,6 @@ ngx_darwin_sendfile_chain(ngx_connection
     trailer.nalloc = NGX_IOVS_PREALLOCATE;
 
     for ( ;; ) {
-        file = NULL;
-        file_size = 0;
         eintr = 0;
         prev_send = send;
 
@@ -98,23 +96,22 @@ ngx_darwin_sendfile_chain(ngx_connection
             file_size = ngx_chain_coalesce_file(&cl, limit - send);
 
             send += file_size;
-        }
 
-        if (file && header.count == 0) {
+            if (header.count == 0) {
 
-            /* create the trailer iovec and coalesce the neighbouring bufs */
+                /*
+                 * create the trailer iovec and coalesce the neighbouring bufs
+                 */
 
-            cl = ngx_output_chain_to_iovec(&trailer, cl, limit - send, c->log);
+                cl = ngx_output_chain_to_iovec(&trailer, cl, limit - send, c->log);
 
-            if (cl == NGX_CHAIN_ERROR) {
-                return NGX_CHAIN_ERROR;
+                if (cl == NGX_CHAIN_ERROR) {
+                    return NGX_CHAIN_ERROR;
+                }
+
+                send += trailer.size;
             }
 
-            send += trailer.size;
-        }
-
-        if (file) {
-
             /*
              * sendfile() returns EINVAL if sf_hdtr's count is 0,
              * but corresponding pointer is not NULL
diff -r ac3f78219f85 -r e044893b4587 src/os/unix/ngx_freebsd_sendfile_chain.c
--- a/src/os/unix/ngx_freebsd_sendfile_chain.c	Wed Aug 13 15:11:45 2014 +0400
+++ b/src/os/unix/ngx_freebsd_sendfile_chain.c	Wed Aug 13 15:11:45 2014 +0400
@@ -79,8 +79,6 @@ ngx_freebsd_sendfile_chain(ngx_connectio
     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_connectio
             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_connectio
             }
 
             send += trailer.size;
-        }
-
-        if (file) {
 
             if (ngx_freebsd_use_tcp_nopush
                 && c->tcp_nopush == NGX_TCP_NOPUSH_UNSET)
diff -r ac3f78219f85 -r e044893b4587 src/os/unix/ngx_linux_sendfile_chain.c
--- a/src/os/unix/ngx_linux_sendfile_chain.c	Wed Aug 13 15:11:45 2014 +0400
+++ b/src/os/unix/ngx_linux_sendfile_chain.c	Wed Aug 13 15:11:45 2014 +0400
@@ -66,8 +66,6 @@ ngx_linux_sendfile_chain(ngx_connection_
     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_
             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();



More information about the nginx-devel mailing list