aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/ngx_buf.h15
-rw-r--r--src/core/ngx_core.h1
-rw-r--r--src/core/ngx_file.h5
-rw-r--r--src/core/ngx_output_chain.c24
4 files changed, 37 insertions, 8 deletions
diff --git a/src/core/ngx_buf.h b/src/core/ngx_buf.h
index 56e03992d..b455270ad 100644
--- a/src/core/ngx_buf.h
+++ b/src/core/ngx_buf.h
@@ -67,9 +67,16 @@ typedef struct {
} ngx_bufs_t;
+typedef struct ngx_output_chain_ctx_s ngx_output_chain_ctx_t;
+
typedef ngx_int_t (*ngx_output_chain_filter_pt)(void *ctx, ngx_chain_t *in);
-typedef struct {
+#if (NGX_HAVE_FILE_AIO)
+typedef void (*ngx_output_chain_aio_pt)(ngx_output_chain_ctx_t *ctx,
+ ngx_file_t *file);
+#endif
+
+struct ngx_output_chain_ctx_s {
ngx_buf_t *buf;
ngx_chain_t *in;
ngx_chain_t *free;
@@ -90,7 +97,11 @@ typedef struct {
ngx_output_chain_filter_pt output_filter;
void *filter_ctx;
-} ngx_output_chain_ctx_t;
+
+#if (NGX_HAVE_FILE_AIO)
+ ngx_output_chain_aio_pt aio;
+#endif
+};
typedef struct {
diff --git a/src/core/ngx_core.h b/src/core/ngx_core.h
index d5f18b84c..58d0b8030 100644
--- a/src/core/ngx_core.h
+++ b/src/core/ngx_core.h
@@ -19,6 +19,7 @@ typedef struct ngx_open_file_s ngx_open_file_t;
typedef struct ngx_command_s ngx_command_t;
typedef struct ngx_file_s ngx_file_t;
typedef struct ngx_event_s ngx_event_t;
+typedef struct ngx_event_aio_s ngx_event_aio_t;
typedef struct ngx_connection_s ngx_connection_t;
typedef void (*ngx_event_handler_pt)(ngx_event_t *ev);
diff --git a/src/core/ngx_file.h b/src/core/ngx_file.h
index 56315433b..8b502539a 100644
--- a/src/core/ngx_file.h
+++ b/src/core/ngx_file.h
@@ -22,10 +22,15 @@ struct ngx_file_s {
ngx_log_t *log;
+#if (NGX_HAVE_FILE_AIO)
+ ngx_event_aio_t *aio;
+#endif
+
unsigned valid_info:1;
unsigned directio:1;
};
+
#define NGX_MAX_PATH_LEVEL 3
diff --git a/src/core/ngx_output_chain.c b/src/core/ngx_output_chain.c
index 6d6d241c1..99e0a9434 100644
--- a/src/core/ngx_output_chain.c
+++ b/src/core/ngx_output_chain.c
@@ -519,8 +519,26 @@ ngx_output_chain_copy_buf(ngx_output_chain_ctx_t *ctx)
#endif
+#if (NGX_HAVE_FILE_AIO)
+
+ if (ctx->aio) {
+ n = ngx_file_aio_read(src->file, dst->pos, (size_t) size,
+ src->file_pos, ctx->pool);
+ if (n == NGX_AGAIN) {
+ ctx->aio(ctx, src->file);
+ return NGX_AGAIN;
+ }
+
+ } else {
+ n = ngx_read_file(src->file, dst->pos, (size_t) size,
+ src->file_pos);
+ }
+#else
+
n = ngx_read_file(src->file, dst->pos, (size_t) size, src->file_pos);
+#endif
+
#if (NGX_HAVE_ALIGNED_DIRECTIO)
if (ctx->unaligned) {
@@ -545,12 +563,6 @@ ngx_output_chain_copy_buf(ngx_output_chain_ctx_t *ctx)
return (ngx_int_t) n;
}
-#if (NGX_FILE_AIO_READ)
- if (n == NGX_AGAIN) {
- return (ngx_int_t) n;
- }
-#endif
-
if (n != size) {
ngx_log_error(NGX_LOG_ALERT, ctx->pool->log, 0,
ngx_read_file_n " read only %z of %O from \"%s\"",