Welcome! Log In Create A New Profile

Advanced

[PATCH] Fixed unix ngx_write_chain_to_file() to return total bytes written

Maxim Dounin
October 20, 2011 08:38AM
# HG changeset patch
# User Maxim Dounin <mdounin@mdounin.ru>
# Date 1319074243 -14400
# Node ID 13566dde55124ae2d72f875734752cf4c7857b98
# Parent b07d81a20619e790bb0433780c58dc35ec4260ad
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.

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
@@ -153,7 +153,7 @@ ngx_write_chain_to_file(ngx_file_t *file
{
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
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

file->sys_offset += n;
file->offset += n;
+ total += n;

} while (cl);

- return n;
+ return total;
}



_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] Fixed unix ngx_write_chain_to_file() to return total bytes written

Maxim Dounin 1775 October 20, 2011 08:38AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 156
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready