comparison src/os/unix/ngx_recv_chain.c @ 73:4534060fde92

nginx-0.0.1-2003-04-10-19:08:54 import
author Igor Sysoev <igor@sysoev.ru>
date Thu, 10 Apr 2003 15:08:54 +0000
parents
children 17ab1af8c3dd
comparison
equal deleted inserted replaced
72:66de3f065886 73:4534060fde92
1
2 #include <ngx_config.h>
3 #include <ngx_core.h>
4 #include <ngx_errno.h>
5 #include <ngx_log.h>
6 #include <ngx_connection.h>
7
8
9 ssize_t ngx_recv_chain(ngx_connection_t *c, ngx_chain_t *ce)
10 {
11 int n;
12 struct iovec *iov;
13 ngx_err_t err;
14 ngx_array_t io;
15
16 ngx_init_array(io, c->pool, 10, sizeof(struct iovec), NGX_ERROR);
17
18 while (ce) {
19 ngx_test_null(iov, ngx_push_array(&io), NGX_ERROR);
20 iov->iov_base = ce->hunk->pos;
21 iov->iov_len = ce->hunk->last - ce->hunk->pos;
22 ce = ce->next;
23 }
24
25 n = readv(c->fd, (struct iovec *) io.elts, io.nelts);
26
27 ngx_destroy_array(&io);
28
29 if (n == -1) {
30 c->read->ready = 0;
31
32 if (err == NGX_EAGAIN) {
33 ngx_log_error(NGX_LOG_INFO, c->log, err, "readv() returned EAGAIN");
34 return NGX_AGAIN;
35 }
36
37 ngx_log_error(NGX_LOG_ERR, c->log, err, "readv() failed");
38 return NGX_ERROR;
39 }
40
41 return n;
42 }