[PATCH] Fixed another return in unix ngx_write_chain_to_file()

Maxim Dounin mdounin at mdounin.ru
Thu Oct 20 17:41:35 UTC 2011


# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1319132491 -14400
# Node ID 79c66120c46633f9f68d2ebb37c1a15f03f2673a
# Parent  940ce296e112c04f5be28c70e42bed06f49a8793
Fixed another return in unix ngx_write_chain_to_file().

Previous patch missed special case for one iovec, it needs total bytes
written to be returned as well.

diff --git a/src/os/unix/ngx_files.c b/src/os/unix/ngx_files.c
--- a/src/os/unix/ngx_files.c
+++ b/src/os/unix/ngx_files.c
@@ -204,8 +204,15 @@ ngx_write_chain_to_file(ngx_file_t *file
 
         if (vec.nelts == 1) {
             iov = vec.elts;
-            return ngx_write_file(file, (u_char *) iov[0].iov_base,
-                                  iov[0].iov_len, offset);
+
+            n = ngx_write_file(file, (u_char *) iov[0].iov_base,
+                               iov[0].iov_len, offset);
+
+            if (n == NGX_ERROR) {
+                return n;
+            }
+
+            return total + n;
         }
 
         if (file->sys_offset != offset) {



More information about the nginx-devel mailing list