[nginx] svn commit: r4352 - in branches/stable-1.0: . src/os/unix

mdounin at mdounin.ru mdounin at mdounin.ru
Tue Dec 13 18:59:18 UTC 2011


Author: mdounin
Date: 2011-12-13 18:59:18 +0000 (Tue, 13 Dec 2011)
New Revision: 4352

Log:
Merge of r4221, r4222:

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.


Modified:
   branches/stable-1.0/
   branches/stable-1.0/src/os/unix/ngx_files.c


Property changes on: branches/stable-1.0
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4220,4229-4230,4232,4235-4237,4265,4268,4280,4283,4321,4342-4343
   + /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4222,4229-4230,4232,4235-4237,4265,4268,4280,4283,4321,4342-4343

Modified: branches/stable-1.0/src/os/unix/ngx_files.c
===================================================================
--- branches/stable-1.0/src/os/unix/ngx_files.c	2011-12-13 18:46:07 UTC (rev 4351)
+++ branches/stable-1.0/src/os/unix/ngx_files.c	2011-12-13 18:59:18 UTC (rev 4352)
@@ -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;
@@ -202,8 +204,15 @@
 
         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) {
@@ -233,10 +242,11 @@
 
         file->sys_offset += n;
         file->offset += n;
+        total += n;
 
     } while (cl);
 
-    return n;
+    return total;
 }
 
 



More information about the nginx-devel mailing list