diff src/os/unix/ngx_aio_read_chain.c @ 166:389d7ee9fa60

nginx-0.0.1-2003-10-30-11:51:06 import
author Igor Sysoev <igor@sysoev.ru>
date Thu, 30 Oct 2003 08:51:06 +0000
parents 84036764e215
children 70e1c7d2b83d
line wrap: on
line diff
--- 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_connectio
     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_connectio
             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;
         }