changeset 4220:4be8dd8dd547

Fixed unix ngx_write_chain_to_file() to return total bytes written. Previously result of last iteration's writev() was returned. This was unnoticed as return value was only used if chain contained only one or two buffers.
author Maxim Dounin <mdounin@mdounin.ru>
date Thu, 20 Oct 2011 12:40:26 +0000
parents 691133126226
children 3203ddb78279
files src/os/unix/ngx_files.c
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/os/unix/ngx_files.c	Thu Oct 20 07:12:45 2011 +0000
+++ b/src/os/unix/ngx_files.c	Thu Oct 20 12:40:26 2011 +0000
@@ -153,7 +153,7 @@
 {
     u_char        *prev;
     size_t         size;
-    ssize_t        n;
+    ssize_t        total, n;
     ngx_array_t    vec;
     struct iovec  *iov, iovs[NGX_IOVS];
 
@@ -165,6 +165,8 @@
                               offset);
     }
 
+    total = 0;
+
     vec.elts = iovs;
     vec.size = sizeof(struct iovec);
     vec.nalloc = NGX_IOVS;
@@ -233,10 +235,11 @@
 
         file->sys_offset += n;
         file->offset += n;
+        total += n;
 
     } while (cl);
 
-    return n;
+    return total;
 }