summaryrefslogtreecommitdiffhomepage
path: root/src/os/unix/ngx_aio_read_chain.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/os/unix/ngx_aio_read_chain.c')
-rw-r--r--src/os/unix/ngx_aio_read_chain.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/os/unix/ngx_aio_read_chain.c b/src/os/unix/ngx_aio_read_chain.c
index 31f7c8573..9af48dd98 100644
--- a/src/os/unix/ngx_aio_read_chain.c
+++ b/src/os/unix/ngx_aio_read_chain.c
@@ -12,25 +12,30 @@ ssize_t ngx_aio_read_chain(ngx_connection_t *c, ngx_chain_t *cl)
size_t size, total;
ngx_err_t err;
+ if (c->read->aio_eof) {
+ c->read->ready = 0;
+ return 0;
+ }
+
total = 0;
while (cl) {
/* we can post the single aio operation only */
- if (c->read->active) {
+ if (!c->read->ready) {
return total ? total : NGX_AGAIN;
}
- buf = cl->hunk->pos;
- prev = buf;
+ buf = cl->hunk->last;
+ prev = cl->hunk->last;
size = 0;
/* coalesce the neighbouring hunks */
- while (cl && prev == cl->hunk->pos) {
- size += cl->hunk->last - cl->hunk->pos;
- prev = cl->hunk->last;
+ while (cl && prev == cl->hunk->last) {
+ size += cl->hunk->end - cl->hunk->last;
+ prev = cl->hunk->end;
cl = cl->next;
}
@@ -46,6 +51,15 @@ ssize_t ngx_aio_read_chain(ngx_connection_t *c, ngx_chain_t *cl)
return NGX_ERROR;
}
+ if (n == 0) {
+ c->read->aio_eof = 1;
+ if (total) {
+ c->read->eof = 0;
+ c->read->ready = 1;
+ }
+ return total;
+ }
+
if (n > 0) {
total += n;
}