aboutsummaryrefslogtreecommitdiff
path: root/src/os/unix
diff options
context:
space:
mode:
Diffstat (limited to 'src/os/unix')
-rw-r--r--src/os/unix/ngx_darwin_sendfile_chain.c2
-rw-r--r--src/os/unix/ngx_freebsd_sendfile_chain.c20
2 files changed, 15 insertions, 7 deletions
diff --git a/src/os/unix/ngx_darwin_sendfile_chain.c b/src/os/unix/ngx_darwin_sendfile_chain.c
index c802e9f9a..2a76c154d 100644
--- a/src/os/unix/ngx_darwin_sendfile_chain.c
+++ b/src/os/unix/ngx_darwin_sendfile_chain.c
@@ -98,7 +98,7 @@ ngx_darwin_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
send += file_size;
- if (header.count == 0) {
+ if (header.count == 0 && send < limit) {
/*
* create the trailer iovec and coalesce the neighbouring bufs
diff --git a/src/os/unix/ngx_freebsd_sendfile_chain.c b/src/os/unix/ngx_freebsd_sendfile_chain.c
index d0299f54f..4822e72bb 100644
--- a/src/os/unix/ngx_freebsd_sendfile_chain.c
+++ b/src/os/unix/ngx_freebsd_sendfile_chain.c
@@ -114,15 +114,23 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
send += file_size;
- /* create the trailer iovec and coalesce the neighbouring bufs */
+ if (send < limit) {
- cl = ngx_output_chain_to_iovec(&trailer, cl, limit - send, c->log);
+ /*
+ * create the trailer iovec and coalesce the neighbouring bufs
+ */
- if (cl == NGX_CHAIN_ERROR) {
- return NGX_CHAIN_ERROR;
- }
+ cl = ngx_output_chain_to_iovec(&trailer, cl, limit - send,
+ c->log);
+ if (cl == NGX_CHAIN_ERROR) {
+ return NGX_CHAIN_ERROR;
+ }
+
+ send += trailer.size;
- send += trailer.size;
+ } else {
+ trailer.count = 0;
+ }
if (ngx_freebsd_use_tcp_nopush
&& c->tcp_nopush == NGX_TCP_NOPUSH_UNSET)