fix case when the output filter should add incoming buffers

while waiting on file AIO completion
This commit is contained in:
Igor Sysoev 2009-09-13 06:28:17 +00:00
parent 570608ff4a
commit 84b20ca18b
3 changed files with 18 additions and 11 deletions

View File

@ -89,6 +89,11 @@ struct ngx_output_chain_ctx_s {
#endif #endif
unsigned need_in_memory:1; unsigned need_in_memory:1;
unsigned need_in_temp:1; unsigned need_in_temp:1;
#if (NGX_HAVE_FILE_AIO)
unsigned aio:1;
ngx_output_chain_aio_pt aio_handler;
#endif
off_t alignment; off_t alignment;
@ -99,10 +104,6 @@ struct ngx_output_chain_ctx_s {
ngx_output_chain_filter_pt output_filter; ngx_output_chain_filter_pt output_filter;
void *filter_ctx; void *filter_ctx;
#if (NGX_HAVE_FILE_AIO)
ngx_output_chain_aio_pt aio;
#endif
}; };

View File

@ -74,6 +74,12 @@ ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in)
} }
} }
#if (NGX_HAVE_FILE_AIO)
if (ctx->aio) {
return NGX_AGAIN;
}
#endif
out = NULL; out = NULL;
last_out = &out; last_out = &out;
last = NGX_NONE; last = NGX_NONE;
@ -519,11 +525,11 @@ ngx_output_chain_copy_buf(ngx_output_chain_ctx_t *ctx)
#if (NGX_HAVE_FILE_AIO) #if (NGX_HAVE_FILE_AIO)
if (ctx->aio) { if (ctx->aio_handler) {
n = ngx_file_aio_read(src->file, dst->pos, (size_t) size, n = ngx_file_aio_read(src->file, dst->pos, (size_t) size,
src->file_pos, ctx->pool); src->file_pos, ctx->pool);
if (n == NGX_AGAIN) { if (n == NGX_AGAIN) {
ctx->aio(ctx, src->file); ctx->aio_handler(ctx, src->file);
return NGX_AGAIN; return NGX_AGAIN;
} }

View File

@ -87,10 +87,6 @@ ngx_http_copy_filter(ngx_http_request_t *r, ngx_chain_t *in)
c = r->connection; c = r->connection;
if (r->aio) {
return NGX_AGAIN;
}
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
"http copy filter: \"%V?%V\"", &r->uri, &r->args); "http copy filter: \"%V?%V\"", &r->uri, &r->args);
@ -123,7 +119,7 @@ ngx_http_copy_filter(ngx_http_request_t *r, ngx_chain_t *in)
#if (NGX_HAVE_FILE_AIO) #if (NGX_HAVE_FILE_AIO)
if (clcf->aio) { if (clcf->aio) {
ctx->aio = ngx_http_copy_aio_handler; ctx->aio_handler = ngx_http_copy_aio_handler;
#if (NGX_HAVE_AIO_SENDFILE) #if (NGX_HAVE_AIO_SENDFILE)
c->aio_sendfile = (clcf->aio == NGX_HTTP_AIO_SENDFILE); c->aio_sendfile = (clcf->aio == NGX_HTTP_AIO_SENDFILE);
#endif #endif
@ -133,6 +129,10 @@ ngx_http_copy_filter(ngx_http_request_t *r, ngx_chain_t *in)
r->request_output = 1; r->request_output = 1;
} }
#if (NGX_HAVE_FILE_AIO)
ctx->aio = r->aio;
#endif
for ( ;; ) { for ( ;; ) {
rc = ngx_output_chain(ctx, in); rc = ngx_output_chain(ctx, in);