Mercurial > hg > nginx-quic
comparison src/os/unix/ngx_readv_chain.c @ 343:6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 28 May 2004 15:49:23 +0000 |
parents | fb4dfb2ac0fc |
children | 744ccb59062d |
comparison
equal
deleted
inserted
replaced
342:0ee0642af5f1 | 343:6bdf858bff8c |
---|---|
8 | 8 |
9 ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain) | 9 ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain) |
10 { | 10 { |
11 u_char *prev; | 11 u_char *prev; |
12 ssize_t n, size; | 12 ssize_t n, size; |
13 struct iovec *iov; | |
14 ngx_err_t err; | 13 ngx_err_t err; |
15 ngx_array_t io; | 14 ngx_array_t io; |
16 ngx_event_t *rev; | 15 ngx_event_t *rev; |
16 struct iovec *iov; | |
17 | 17 |
18 rev = c->read; | 18 rev = c->read; |
19 | 19 |
20 if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) { | 20 if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) { |
21 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, | 21 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
48 iov = NULL; | 48 iov = NULL; |
49 size = 0; | 49 size = 0; |
50 | 50 |
51 ngx_init_array(io, c->pool, 10, sizeof(struct iovec), NGX_ERROR); | 51 ngx_init_array(io, c->pool, 10, sizeof(struct iovec), NGX_ERROR); |
52 | 52 |
53 /* coalesce the neighbouring hunks */ | 53 /* coalesce the neighbouring bufs */ |
54 | 54 |
55 while (chain) { | 55 while (chain) { |
56 if (prev == chain->hunk->last) { | 56 if (prev == chain->buf->last) { |
57 iov->iov_len += chain->hunk->end - chain->hunk->last; | 57 iov->iov_len += chain->buf->end - chain->buf->last; |
58 | 58 |
59 } else { | 59 } else { |
60 ngx_test_null(iov, ngx_push_array(&io), NGX_ERROR); | 60 ngx_test_null(iov, ngx_push_array(&io), NGX_ERROR); |
61 iov->iov_base = (void *) chain->hunk->last; | 61 iov->iov_base = (void *) chain->buf->last; |
62 iov->iov_len = chain->hunk->end - chain->hunk->last; | 62 iov->iov_len = chain->buf->end - chain->buf->last; |
63 } | 63 } |
64 | 64 |
65 size += chain->hunk->end - chain->hunk->last; | 65 size += chain->buf->end - chain->buf->last; |
66 prev = chain->hunk->end; | 66 prev = chain->buf->end; |
67 chain = chain->next; | 67 chain = chain->next; |
68 } | 68 } |
69 | 69 |
70 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, | 70 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
71 "readv: %d, last:%d", io.nelts, iov->iov_len); | 71 "readv: %d, last:%d", io.nelts, iov->iov_len); |
135 | 135 |
136 ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain) | 136 ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain) |
137 { | 137 { |
138 u_char *prev; | 138 u_char *prev; |
139 ssize_t n, size; | 139 ssize_t n, size; |
140 struct iovec *iov; | |
141 ngx_err_t err; | 140 ngx_err_t err; |
142 ngx_array_t io; | 141 ngx_array_t io; |
143 ngx_event_t *rev; | 142 ngx_event_t *rev; |
143 struct iovec *iov; | |
144 | 144 |
145 prev = NULL; | 145 prev = NULL; |
146 iov = NULL; | 146 iov = NULL; |
147 size = 0; | 147 size = 0; |
148 | 148 |
149 ngx_init_array(io, c->pool, 10, sizeof(struct iovec), NGX_ERROR); | 149 ngx_init_array(io, c->pool, 10, sizeof(struct iovec), NGX_ERROR); |
150 | 150 |
151 /* coalesce the neighbouring hunks */ | 151 /* coalesce the neighbouring bufs */ |
152 | 152 |
153 while (chain) { | 153 while (chain) { |
154 if (prev == chain->hunk->last) { | 154 if (prev == chain->buf->last) { |
155 iov->iov_len += chain->hunk->end - chain->hunk->last; | 155 iov->iov_len += chain->buf->end - chain->buf->last; |
156 | 156 |
157 } else { | 157 } else { |
158 ngx_test_null(iov, ngx_push_array(&io), NGX_ERROR); | 158 ngx_test_null(iov, ngx_push_array(&io), NGX_ERROR); |
159 iov->iov_base = chain->hunk->last; | 159 iov->iov_base = chain->buf->last; |
160 iov->iov_len = chain->hunk->end - chain->hunk->last; | 160 iov->iov_len = chain->buf->end - chain->buf->last; |
161 } | 161 } |
162 | 162 |
163 size += chain->hunk->end - chain->hunk->last; | 163 size += chain->buf->end - chain->buf->last; |
164 prev = chain->hunk->end; | 164 prev = chain->buf->end; |
165 chain = chain->next; | 165 chain = chain->next; |
166 } | 166 } |
167 | 167 |
168 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, | 168 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
169 "readv: %d:%d", io.nelts, iov->iov_len); | 169 "readv: %d:%d", io.nelts, iov->iov_len); |