Mercurial > hg > nginx
comparison src/os/unix/ngx_aio_write_chain.c @ 93:738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 21 May 2003 13:28:21 +0000 |
parents | 36d2c25cc9bb |
children | b48066122884 |
comparison
equal
deleted
inserted
replaced
92:19cc647ecd91 | 93:738fe44c70d5 |
---|---|
1 | 1 |
2 #include <ngx_config.h> | 2 #include <ngx_config.h> |
3 | |
4 #include <ngx_core.h> | 3 #include <ngx_core.h> |
5 #include <ngx_types.h> | 4 #include <ngx_aio.h> |
6 #include <ngx_alloc.h> | |
7 #include <ngx_array.h> | |
8 #include <ngx_hunk.h> | |
9 #include <ngx_connection.h> | |
10 #include <ngx_sendv.h> | |
11 #include <ngx_sendfile.h> | |
12 | 5 |
13 | 6 |
14 ngx_chain_t *ngx_aio_write_chain(ngx_connection_t *c, ngx_chain_t *in) | 7 ngx_chain_t *ngx_aio_write_chain(ngx_connection_t *c, ngx_chain_t *in) |
15 { | 8 { |
16 int rc; | 9 int rc; |
23 sent = 0; | 16 sent = 0; |
24 ce = in; | 17 ce = in; |
25 | 18 |
26 while (ce) { | 19 while (ce) { |
27 | 20 |
28 ngx_log_debug(c->log, "aio_write ce: %x" _ ce->hunk->pos.mem); | 21 ngx_log_debug(c->log, "aio_write ce: %x" _ ce->hunk->pos); |
29 | 22 |
30 buf = prev = ce->hunk->pos.mem; | 23 buf = prev = ce->hunk->pos; |
31 size = 0; | 24 size = 0; |
32 | 25 |
33 /* coalesce the neighbouring chain entries */ | 26 /* coalesce the neighbouring chain entries */ |
34 while (ce && prev == ce->hunk->pos.mem) { | 27 while (ce && prev == ce->hunk->pos) { |
35 size += ce->hunk->last.mem - ce->hunk->pos.mem; | 28 size += ce->hunk->last - ce->hunk->pos; |
36 prev = ce->hunk->last.mem; | 29 prev = ce->hunk->last; |
37 ce = ce->next; | 30 ce = ce->next; |
38 } | 31 } |
39 | 32 |
40 rc = ngx_event_aio_write(c, buf, size); | 33 rc = ngx_aio_write(c, buf, size); |
41 | 34 |
42 ngx_log_debug(c->log, "aio_write rc: %d" _ rc); | 35 ngx_log_debug(c->log, "aio_write rc: %d" _ rc); |
43 | 36 |
44 if (rc > 0) { | 37 if (rc > 0) { |
45 sent += rc; | 38 sent += rc; |
60 for (ce = in; ce; ce = ce->next) { | 53 for (ce = in; ce; ce = ce->next) { |
61 | 54 |
62 #if (NGX_DEBUG_WRITE_CHAIN) | 55 #if (NGX_DEBUG_WRITE_CHAIN) |
63 ngx_log_debug(c->log, "write chain: %x %qx %qd" _ | 56 ngx_log_debug(c->log, "write chain: %x %qx %qd" _ |
64 ce->hunk->type _ | 57 ce->hunk->type _ |
65 ce->hunk->pos.file _ | 58 ce->hunk->file_pos _ |
66 ce->hunk->last.file - ce->hunk->pos.file); | 59 ce->hunk->file_last - ce->hunk->file_pos); |
67 #endif | 60 #endif |
68 | 61 |
69 if (sent >= ce->hunk->last.file - ce->hunk->pos.file) { | 62 if (sent >= ce->hunk->file_last - ce->hunk->file_pos) { |
70 sent -= ce->hunk->last.file - ce->hunk->pos.file; | 63 sent -= ce->hunk->file_last - ce->hunk->file_pos; |
71 ce->hunk->pos.file = ce->hunk->last.file; | 64 ce->hunk->file_pos = ce->hunk->file_last; |
72 | 65 |
73 #if (NGX_DEBUG_WRITE_CHAIN) | 66 #if (NGX_DEBUG_WRITE_CHAIN) |
74 ngx_log_debug(c->log, "write chain done: %qx %qd" _ | 67 ngx_log_debug(c->log, "write chain done: %qx %qd" _ |
75 ce->hunk->pos.file _ sent); | 68 ce->hunk->file_pos _ sent); |
76 #endif | 69 #endif |
77 continue; | 70 continue; |
78 } | 71 } |
79 | 72 |
80 ce->hunk->pos.file += sent; | 73 ce->hunk->file_pos += sent; |
81 | 74 |
82 #if (NGX_DEBUG_WRITE_CHAIN) | 75 #if (NGX_DEBUG_WRITE_CHAIN) |
83 ngx_log_debug(c->log, "write chain rest: %qx %qd" _ | 76 ngx_log_debug(c->log, "write chain rest: %qx %qd" _ |
84 ce->hunk->pos.file _ | 77 ce->hunk->file_pos _ |
85 ce->hunk->last.file - ce->hunk->pos.file); | 78 ce->hunk->file_last - ce->hunk->file_pos); |
86 #endif | 79 #endif |
87 | 80 |
88 break; | 81 break; |
89 } | 82 } |
90 | 83 |