Mercurial > hg > nginx
comparison src/os/unix/ngx_aio_read_chain.c @ 164:84036764e215
nginx-0.0.1-2003-10-29-11:30:44 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 29 Oct 2003 08:30:44 +0000 |
parents | |
children | 389d7ee9fa60 |
comparison
equal
deleted
inserted
replaced
163:fb61ba77beba | 164:84036764e215 |
---|---|
1 | |
2 #include <ngx_config.h> | |
3 #include <ngx_core.h> | |
4 #include <ngx_event.h> | |
5 #include <ngx_aio.h> | |
6 | |
7 | |
8 ssize_t ngx_aio_read_chain(ngx_connection_t *c, ngx_chain_t *cl) | |
9 { | |
10 int n; | |
11 char *buf, *prev; | |
12 size_t size, total; | |
13 ngx_err_t err; | |
14 | |
15 total = 0; | |
16 | |
17 while (cl) { | |
18 | |
19 /* we can post the single aio operation only */ | |
20 | |
21 if (c->read->active) { | |
22 return total ? total : NGX_AGAIN; | |
23 } | |
24 | |
25 buf = cl->hunk->pos; | |
26 prev = buf; | |
27 size = 0; | |
28 | |
29 /* coalesce the neighbouring hunks */ | |
30 | |
31 while (cl && prev == cl->hunk->pos) { | |
32 size += cl->hunk->last - cl->hunk->pos; | |
33 prev = cl->hunk->last; | |
34 cl = cl->next; | |
35 } | |
36 | |
37 n = ngx_aio_read(c, buf, size); | |
38 | |
39 ngx_log_debug(c->log, "aio_read: %d" _ n); | |
40 | |
41 if (n == NGX_AGAIN) { | |
42 return total ? total : NGX_AGAIN; | |
43 } | |
44 | |
45 if (n == NGX_ERROR) { | |
46 return NGX_ERROR; | |
47 } | |
48 | |
49 if (n > 0) { | |
50 total += n; | |
51 } | |
52 | |
53 ngx_log_debug(c->log, "aio_read total: %d" _ total); | |
54 } | |
55 | |
56 return total ? total : NGX_AGAIN; | |
57 } |