mirror of
https://github.com/nginx/nginx.git
synced 2024-11-21 16:28:40 +00:00
Support for sendfile(SF_NOCACHE).
The SF_NOCACHE flag, introduced in FreeBSD 11 along with the new non-blocking sendfile() implementation by glebius@, makes it possible to use sendfile() along with the "directio" directive.
This commit is contained in:
parent
2a00e6141f
commit
1f01183b9e
@ -256,10 +256,6 @@ ngx_output_chain_as_is(ngx_output_chain_ctx_t *ctx, ngx_buf_t *buf)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (buf->in_file && buf->file->directio) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
sendfile = ctx->sendfile;
|
sendfile = ctx->sendfile;
|
||||||
|
|
||||||
#if (NGX_SENDFILE_LIMIT)
|
#if (NGX_SENDFILE_LIMIT)
|
||||||
@ -268,6 +264,19 @@ ngx_output_chain_as_is(ngx_output_chain_ctx_t *ctx, ngx_buf_t *buf)
|
|||||||
sendfile = 0;
|
sendfile = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !(NGX_HAVE_SENDFILE_NODISKIO)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* With DIRECTIO, disable sendfile() unless sendfile(SF_NOCACHE)
|
||||||
|
* is available.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (buf->in_file && buf->file->directio) {
|
||||||
|
sendfile = 0;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!sendfile) {
|
if (!sendfile) {
|
||||||
|
@ -2955,7 +2955,13 @@ ngx_ssl_sendfile(ngx_connection_t *c, ngx_buf_t *file, size_t size)
|
|||||||
ngx_set_errno(0);
|
ngx_set_errno(0);
|
||||||
|
|
||||||
#if (NGX_HAVE_SENDFILE_NODISKIO)
|
#if (NGX_HAVE_SENDFILE_NODISKIO)
|
||||||
|
|
||||||
flags = (c->busy_count <= 2) ? SF_NODISKIO : 0;
|
flags = (c->busy_count <= 2) ? SF_NODISKIO : 0;
|
||||||
|
|
||||||
|
if (file->file->directio) {
|
||||||
|
flags |= SF_NOCACHE;
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
flags = 0;
|
flags = 0;
|
||||||
#endif
|
#endif
|
||||||
|
@ -174,7 +174,13 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
|
|||||||
sent = 0;
|
sent = 0;
|
||||||
|
|
||||||
#if (NGX_HAVE_SENDFILE_NODISKIO)
|
#if (NGX_HAVE_SENDFILE_NODISKIO)
|
||||||
|
|
||||||
flags = (c->busy_count <= 2) ? SF_NODISKIO : 0;
|
flags = (c->busy_count <= 2) ? SF_NODISKIO : 0;
|
||||||
|
|
||||||
|
if (file->file->directio) {
|
||||||
|
flags |= SF_NOCACHE;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rc = sendfile(file->file->fd, c->fd, file->file_pos,
|
rc = sendfile(file->file->fd, c->fd, file->file_pos,
|
||||||
|
Loading…
Reference in New Issue
Block a user