diff options
author | Maxim Dounin <mdounin@mdounin.ru> | 2011-10-20 12:40:26 +0000 |
---|---|---|
committer | Maxim Dounin <mdounin@mdounin.ru> | 2011-10-20 12:40:26 +0000 |
commit | aecb2eda1368aa7e3b58738f2577474d98bf58ca (patch) | |
tree | d7e6e07f41652b1ca507f59378617dbad4ee2db8 /src/os/unix/ngx_files.c | |
parent | 5f810705232f477361de76521287614562c34592 (diff) | |
download | nginx-aecb2eda1368aa7e3b58738f2577474d98bf58ca.tar.gz nginx-aecb2eda1368aa7e3b58738f2577474d98bf58ca.zip |
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.
Diffstat (limited to 'src/os/unix/ngx_files.c')
-rw-r--r-- | src/os/unix/ngx_files.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/os/unix/ngx_files.c b/src/os/unix/ngx_files.c index 89ab8d6bc..4bfde44f4 100644 --- a/src/os/unix/ngx_files.c +++ b/src/os/unix/ngx_files.c @@ -153,7 +153,7 @@ ngx_write_chain_to_file(ngx_file_t *file, ngx_chain_t *cl, off_t offset, { 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 @@ ngx_write_chain_to_file(ngx_file_t *file, ngx_chain_t *cl, off_t offset, offset); } + total = 0; + vec.elts = iovs; vec.size = sizeof(struct iovec); vec.nalloc = NGX_IOVS; @@ -233,10 +235,11 @@ ngx_write_chain_to_file(ngx_file_t *file, ngx_chain_t *cl, off_t offset, file->sys_offset += n; file->offset += n; + total += n; } while (cl); - return n; + return total; } |