Mercurial > hg > nginx
comparison 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 |
comparison
equal
deleted
inserted
replaced
165:894a01c6aea3 | 166:389d7ee9fa60 |
---|---|
10 int n; | 10 int n; |
11 char *buf, *prev; | 11 char *buf, *prev; |
12 size_t size, total; | 12 size_t size, total; |
13 ngx_err_t err; | 13 ngx_err_t err; |
14 | 14 |
15 if (c->read->aio_eof) { | |
16 c->read->ready = 0; | |
17 return 0; | |
18 } | |
19 | |
15 total = 0; | 20 total = 0; |
16 | 21 |
17 while (cl) { | 22 while (cl) { |
18 | 23 |
19 /* we can post the single aio operation only */ | 24 /* we can post the single aio operation only */ |
20 | 25 |
21 if (c->read->active) { | 26 if (!c->read->ready) { |
22 return total ? total : NGX_AGAIN; | 27 return total ? total : NGX_AGAIN; |
23 } | 28 } |
24 | 29 |
25 buf = cl->hunk->pos; | 30 buf = cl->hunk->last; |
26 prev = buf; | 31 prev = cl->hunk->last; |
27 size = 0; | 32 size = 0; |
28 | 33 |
29 /* coalesce the neighbouring hunks */ | 34 /* coalesce the neighbouring hunks */ |
30 | 35 |
31 while (cl && prev == cl->hunk->pos) { | 36 while (cl && prev == cl->hunk->last) { |
32 size += cl->hunk->last - cl->hunk->pos; | 37 size += cl->hunk->end - cl->hunk->last; |
33 prev = cl->hunk->last; | 38 prev = cl->hunk->end; |
34 cl = cl->next; | 39 cl = cl->next; |
35 } | 40 } |
36 | 41 |
37 n = ngx_aio_read(c, buf, size); | 42 n = ngx_aio_read(c, buf, size); |
38 | 43 |
44 | 49 |
45 if (n == NGX_ERROR) { | 50 if (n == NGX_ERROR) { |
46 return NGX_ERROR; | 51 return NGX_ERROR; |
47 } | 52 } |
48 | 53 |
54 if (n == 0) { | |
55 c->read->aio_eof = 1; | |
56 if (total) { | |
57 c->read->eof = 0; | |
58 c->read->ready = 1; | |
59 } | |
60 return total; | |
61 } | |
62 | |
49 if (n > 0) { | 63 if (n > 0) { |
50 total += n; | 64 total += n; |
51 } | 65 } |
52 | 66 |
53 ngx_log_debug(c->log, "aio_read total: %d" _ total); | 67 ngx_log_debug(c->log, "aio_read total: %d" _ total); |