comparison src/os/unix/ngx_readv_chain.c @ 155:46eb23d9471d

nginx-0.0.1-2003-10-22-20:38:26 import
author Igor Sysoev <igor@sysoev.ru>
date Wed, 22 Oct 2003 16:38:26 +0000
parents 2d9e4a8b6d11
children fb61ba77beba
comparison
equal deleted inserted replaced
154:eac26585476e 155:46eb23d9471d
2 #include <ngx_config.h> 2 #include <ngx_config.h>
3 #include <ngx_core.h> 3 #include <ngx_core.h>
4 #include <ngx_event.h> 4 #include <ngx_event.h>
5 5
6 6
7 ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *entry) 7 ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
8 { 8 {
9 ssize_t n; 9 ssize_t n;
10 struct iovec *iov; 10 struct iovec *iov;
11 ngx_err_t err; 11 ngx_err_t err;
12 ngx_array_t io; 12 ngx_array_t io;
17 17
18 ngx_init_array(io, c->pool, 10, sizeof(struct iovec), NGX_ERROR); 18 ngx_init_array(io, c->pool, 10, sizeof(struct iovec), NGX_ERROR);
19 19
20 /* TODO: coalesce the neighbouring chain entries */ 20 /* TODO: coalesce the neighbouring chain entries */
21 21
22 while (entry) { 22 while (chain) {
23 ngx_test_null(iov, ngx_push_array(&io), NGX_ERROR); 23 ngx_test_null(iov, ngx_push_array(&io), NGX_ERROR);
24 iov->iov_base = entry->hunk->last; 24 iov->iov_base = chain->hunk->last;
25 iov->iov_len = entry->hunk->end - entry->hunk->last; 25 iov->iov_len = chain->hunk->end - chain->hunk->last;
26 entry = entry->next; 26 chain = chain->next;
27 } 27 }
28 28
29 ngx_log_debug(c->log, "recv: %d:%d" _ io.nelts _ iov->iov_len); 29 ngx_log_debug(c->log, "recv: %d:%d" _ io.nelts _ iov->iov_len);
30 30
31 n = readv(c->fd, (struct iovec *) io.elts, io.nelts); 31 n = readv(c->fd, (struct iovec *) io.elts, io.nelts);
32
33 ngx_destroy_array(&io);
34 32
35 if (n == -1) { 33 if (n == -1) {
36 c->read->ready = 0; 34 c->read->ready = 0;
37 35
38 err = ngx_errno; 36 err = ngx_errno;