aboutsummaryrefslogtreecommitdiff
path: root/src/os/unix/ngx_linux_sendfile_chain.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2006-09-07 18:56:45 +0000
committerIgor Sysoev <igor@sysoev.ru>2006-09-07 18:56:45 +0000
commitc839ef81b22bcddca9dd914dbaeafb1934055521 (patch)
tree605f4ee03b1ad1703c97162eea24389ed27bade6 /src/os/unix/ngx_linux_sendfile_chain.c
parente2f30beb932259ae3ed556f90604c33604dee710 (diff)
downloadnginx-c839ef81b22bcddca9dd914dbaeafb1934055521.tar.gz
nginx-c839ef81b22bcddca9dd914dbaeafb1934055521.zip
workaround of 2G+ file bug in 64-bit Linux sendfile()
Diffstat (limited to 'src/os/unix/ngx_linux_sendfile_chain.c')
-rw-r--r--src/os/unix/ngx_linux_sendfile_chain.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/os/unix/ngx_linux_sendfile_chain.c b/src/os/unix/ngx_linux_sendfile_chain.c
index fb9957728..1d602c886 100644
--- a/src/os/unix/ngx_linux_sendfile_chain.c
+++ b/src/os/unix/ngx_linux_sendfile_chain.c
@@ -16,9 +16,15 @@
* parameter is int32_t, and use sendfile() for the file parts below 2G only,
* see src/os/unix/ngx_linux_config.h
*
- * Linux 2.4.21 has a new sendfile64() syscall #239.
+ * Linux 2.4.21 has the new sendfile64() syscall #239.
+ *
+ * On Linux up to 2.6.16 sendfile() does not allow to pass the count parameter
+ * more than 2G-1 bytes even on 64-bit platforms: it returns EINVAL,
+ * so we limit it to 2G-1 bytes.
*/
+#define NGX_SENDFILE_LIMIT 2147483647L
+
#if (IOV_MAX > 64)
#define NGX_HEADERS 64
@@ -54,10 +60,10 @@ ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
}
- /* the maximum limit size is the maximum size_t value - the page size */
+ /* the maximum limit size is 2G-1 - the page size */
- if (limit == 0 || limit > NGX_MAX_SIZE_T_VALUE - ngx_pagesize) {
- limit = NGX_MAX_SIZE_T_VALUE - ngx_pagesize;
+ if (limit == 0 || limit > NGX_SENDFILE_LIMIT - ngx_pagesize) {
+ limit = NGX_SENDFILE_LIMIT - ngx_pagesize;
}