aboutsummaryrefslogtreecommitdiff
path: root/src/core/ngx_output_chain.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/ngx_output_chain.c')
-rw-r--r--src/core/ngx_output_chain.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/core/ngx_output_chain.c b/src/core/ngx_output_chain.c
index 99e0a9434..592f14aaf 100644
--- a/src/core/ngx_output_chain.c
+++ b/src/core/ngx_output_chain.c
@@ -16,14 +16,12 @@
/*
* When DIRECTIO is enabled FreeBSD, Solaris, and MacOSX read directly
* to an application memory from a device if parameters are aligned
- * to device sector boundary(512 bytes). They fallback to usual read
+ * to device sector boundary (512 bytes). They fallback to usual read
* operation if the parameters are not aligned.
* Linux allows DIRECTIO only if the parameters are aligned to a filesystem
* sector boundary, otherwise it returns EINVAL. The sector size is
* usually 512 bytes, however, on XFS it may be 4096 bytes.
*/
-#define NGX_DIRECTIO_BLOCK 4096
-
#define NGX_NONE 1
@@ -337,7 +335,7 @@ ngx_output_chain_align_file_buf(ngx_output_chain_ctx_t *ctx, off_t bsize)
ctx->directio = 1;
- size = (size_t) (in->file_pos - (in->file_pos & ~(NGX_DIRECTIO_BLOCK - 1)));
+ size = (size_t) (in->file_pos - (in->file_pos & ~(ctx->alignment - 1)));
if (size == 0) {
@@ -348,7 +346,7 @@ ngx_output_chain_align_file_buf(ngx_output_chain_ctx_t *ctx, off_t bsize)
size = (size_t) bsize;
} else {
- size = NGX_DIRECTIO_BLOCK - size;
+ size = ctx->alignment - size;
if ((off_t) size > bsize) {
size = (size_t) bsize;
@@ -423,7 +421,7 @@ ngx_output_chain_get_buf(ngx_output_chain_ctx_t *ctx, off_t bsize)
* userland buffer direct usage conjunctly with directio
*/
- b->start = ngx_pmemalign(ctx->pool, size, NGX_DIRECTIO_BLOCK);
+ b->start = ngx_pmemalign(ctx->pool, size, ctx->alignment);
if (b->start == NULL) {
return NGX_ERROR;
}