annotate src/os/unix/ngx_recv_chain.c @ 75:869b10be682f

nginx-0.0.1-2003-04-14-21:04:58 import
author Igor Sysoev <igor@sysoev.ru>
date Mon, 14 Apr 2003 17:04:58 +0000
parents 17ab1af8c3dd
children a7e45c45a95c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
73
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
2 #include <ngx_config.h>
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
3 #include <ngx_core.h>
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
4 #include <ngx_errno.h>
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
5 #include <ngx_log.h>
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
6 #include <ngx_connection.h>
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
7
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
8
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
9 ssize_t ngx_recv_chain(ngx_connection_t *c, ngx_chain_t *ce)
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
10 {
74
17ab1af8c3dd nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents: 73
diff changeset
11 ssize_t n;
17ab1af8c3dd nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents: 73
diff changeset
12 struct iovec *iov;
17ab1af8c3dd nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents: 73
diff changeset
13 ngx_err_t err;
17ab1af8c3dd nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents: 73
diff changeset
14 ngx_array_t io;
73
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
15
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
16 ngx_init_array(io, c->pool, 10, sizeof(struct iovec), NGX_ERROR);
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
17
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
18 while (ce) {
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
19 ngx_test_null(iov, ngx_push_array(&io), NGX_ERROR);
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
20 iov->iov_base = ce->hunk->pos;
75
869b10be682f nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents: 74
diff changeset
21 iov->iov_len = ce->hunk->end - ce->hunk->last;
73
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
22 ce = ce->next;
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
23 }
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
24
75
869b10be682f nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents: 74
diff changeset
25 ngx_log_debug(c->log, "recv: %d:%d" _ io.nelts _ iov->iov_len);
869b10be682f nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents: 74
diff changeset
26
73
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
27 n = readv(c->fd, (struct iovec *) io.elts, io.nelts);
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
28
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
29 ngx_destroy_array(&io);
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
30
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
31 if (n == -1) {
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
32 c->read->ready = 0;
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
33
75
869b10be682f nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents: 74
diff changeset
34 err = ngx_errno;
73
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
35 if (err == NGX_EAGAIN) {
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
36 ngx_log_error(NGX_LOG_INFO, c->log, err, "readv() returned EAGAIN");
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
37 return NGX_AGAIN;
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
38 }
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
39
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
40 ngx_log_error(NGX_LOG_ERR, c->log, err, "readv() failed");
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
41 return NGX_ERROR;
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
42 }
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
43
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
44 return n;
4534060fde92 nginx-0.0.1-2003-04-10-19:08:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
45 }