From 00fcc6a987f1d45a9eac91242de7e3527451242e Mon Sep 17 00:00:00 2001 From: Maxim Dounin Date: Thu, 3 Mar 2016 21:14:19 +0300 Subject: Copy filter: fixed sendfile aio handlers to set ctx->aio. Sendfile handlers (aio preload and thread handler) are called within ctx->output_filter() in ngx_output_chain(), and hence ctx->aio cannot be set directly in ngx_output_chain(). Meanwhile, it must be set to make sure loop within ngx_output_chain() will be properly terminated. There are no known cases that trigger the problem, though in theory something like aio + sub filter (something that needs body in memory, and can also free some memory buffers) + sendfile can result in "task already active" and "second aio post" alerts. The fix is to set ctx->aio in ngx_http_copy_aio_sendfile_preload() and ngx_http_copy_thread_handler(). For consistency, ctx->aio is no longer set explicitly in ngx_output_chain_copy_buf(), as it's now done in ngx_http_copy_thread_handler(). --- src/core/ngx_output_chain.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/core') diff --git a/src/core/ngx_output_chain.c b/src/core/ngx_output_chain.c index 252359af6..b8361dcd6 100644 --- a/src/core/ngx_output_chain.c +++ b/src/core/ngx_output_chain.c @@ -581,7 +581,6 @@ ngx_output_chain_copy_buf(ngx_output_chain_ctx_t *ctx) n = ngx_thread_read(&ctx->thread_task, src->file, dst->pos, (size_t) size, src->file_pos, ctx->pool); if (n == NGX_AGAIN) { - ctx->aio = 1; return NGX_AGAIN; } -- cgit