Mercurial > hg > nginx-vendor-current
annotate src/os/unix/ngx_writev_chain.c @ 58:b55cbf18157e NGINX_0_1_29
nginx 0.1.29
*) Feature: the ngx_http_ssi_module supports "include virtual" command.
*) Feature: the ngx_http_ssi_module supports the condition command like
'if expr="$NAME"' and "else" and "endif" commands. Only one nested
level is supported.
*) Feature: the ngx_http_ssi_module supports the DATE_LOCAL and
DATE_GMT variables and "config timefmt" command.
*) Feature: the "ssi_ignore_recycled_buffers" directive.
*) Bugfix: the "echo" command did not show the default value for the
empty QUERY_STRING variable.
*) Change: the ngx_http_proxy_module was rewritten.
*) Feature: the "proxy_redirect", "proxy_pass_request_headers",
"proxy_pass_request_body", and "proxy_method" directives.
*) Feature: the "proxy_set_header" directive. The "proxy_x_var" was
canceled and must be replaced with the proxy_set_header directive.
*) Change: the "proxy_preserve_host" is canceled and must be replaced
with the "proxy_set_header Host $host" and the "proxy_redirect off"
directives, the "proxy_set_header Host $host:$proxy_port" directive
and the appropriate proxy_redirect directives.
*) Change: the "proxy_set_x_real_ip" is canceled and must be replaced
with the "proxy_set_header X-Real-IP $remote_addr" directive.
*) Change: the "proxy_add_x_forwarded_for" is canceled and must be
replaced with
the "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for"
directive.
*) Change: the "proxy_set_x_url" is canceled and must be replaced with
the "proxy_set_header X-URL http://$host:$server_port$request_uri"
directive.
*) Feature: the "fastcgi_param" directive.
*) Change: the "fastcgi_root", "fastcgi_set_var" and "fastcgi_params"
directive are canceled and must be replaced with the fastcgi_param
directives.
*) Feature: the "index" directive can use the variables.
*) Feature: the "index" directive can be used at http and server levels.
*) Change: the last index only in the "index" directive can be absolute.
*) Feature: the "rewrite" directive can use the variables.
*) Feature: the "internal" directive.
*) Feature: the CONTENT_LENGTH, CONTENT_TYPE, REMOTE_PORT, SERVER_ADDR,
SERVER_PORT, SERVER_PROTOCOL, DOCUMENT_ROOT, SERVER_NAME,
REQUEST_METHOD, REQUEST_URI, and REMOTE_USER variables.
*) Change: nginx now passes the invalid lines in a client request
headers or a backend response header.
*) Bugfix: if the backend did not transfer response for a long time and
the "send_timeout" was less than "proxy_read_timeout", then nginx
returned the 408 response.
*) Bugfix: the segmentation fault was occurred if the backend sent an
invalid line in response header; bug appeared in 0.1.26.
*) Bugfix: the segmentation fault may occurred in FastCGI fault
tolerance configuration.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" and "Cache-Control" headers.
*) Bugfix: nginx did not take into account trailing dot in "Host"
header line.
*) Bugfix: the ngx_http_auth_module did not work under Linux.
*) Bugfix: the rewrite directive worked incorrectly, if the arguments
were in a request.
*) Bugfix: nginx could not be built on MacOS X.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Thu, 12 May 2005 00:00:00 +0400 |
parents | 72eb30262aac |
children | 962c43960644 |
rev | line source |
---|---|
0 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4 */ | |
5 | |
6 | |
7 #include <ngx_config.h> | |
8 #include <ngx_core.h> | |
9 #include <ngx_event.h> | |
10 | |
11 | |
10 | 12 #define NGX_IOVS 16 |
0 | 13 |
14 | |
50 | 15 ngx_chain_t * |
16 ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit) | |
0 | 17 { |
18 u_char *prev; | |
10 | 19 ssize_t n, size, sent; |
22 | 20 off_t send, prev_send; |
0 | 21 ngx_uint_t eintr, complete; |
22 ngx_err_t err; | |
23 ngx_array_t vec; | |
24 ngx_chain_t *cl; | |
25 ngx_event_t *wev; | |
26 struct iovec *iov, iovs[NGX_IOVS]; | |
27 | |
28 wev = c->write; | |
29 | |
30 if (!wev->ready) { | |
31 return in; | |
32 } | |
33 | |
18 | 34 #if (NGX_HAVE_KQUEUE) |
0 | 35 |
4 | 36 if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT) && wev->pending_eof) { |
0 | 37 ngx_log_error(NGX_LOG_INFO, c->log, wev->kq_errno, |
38 "kevent() reported about an closed connection"); | |
39 | |
40 wev->error = 1; | |
41 return NGX_CHAIN_ERROR; | |
42 } | |
43 | |
44 #endif | |
45 | |
22 | 46 /* the maximum limit size is the maximum size_t value - the page size */ |
47 | |
26 | 48 if (limit == 0 || limit > NGX_MAX_SIZE_T_VALUE - ngx_pagesize) { |
49 limit = NGX_MAX_SIZE_T_VALUE - ngx_pagesize; | |
22 | 50 } |
51 | |
0 | 52 send = 0; |
53 complete = 0; | |
54 | |
55 vec.elts = iovs; | |
56 vec.size = sizeof(struct iovec); | |
57 vec.nalloc = NGX_IOVS; | |
58 vec.pool = c->pool; | |
59 | |
60 for ( ;; ) { | |
61 prev = NULL; | |
62 iov = NULL; | |
63 eintr = 0; | |
22 | 64 prev_send = send; |
0 | 65 |
66 vec.nelts = 0; | |
67 | |
68 /* create the iovec and coalesce the neighbouring bufs */ | |
69 | |
70 for (cl = in; cl && vec.nelts < IOV_MAX && send < limit; cl = cl->next) | |
71 { | |
72 if (ngx_buf_special(cl->buf)) { | |
73 continue; | |
74 } | |
75 | |
10 | 76 #if 1 |
77 if (!ngx_buf_in_memory(cl->buf)) { | |
78 ngx_debug_point(); | |
79 } | |
80 #endif | |
81 | |
0 | 82 size = cl->buf->last - cl->buf->pos; |
83 | |
84 if (send + size > limit) { | |
85 size = limit - send; | |
86 } | |
87 | |
88 if (prev == cl->buf->pos) { | |
89 iov->iov_len += size; | |
90 | |
91 } else { | |
50 | 92 iov = ngx_array_push(&vec); |
93 if (iov == NULL) { | |
0 | 94 return NGX_CHAIN_ERROR; |
95 } | |
96 | |
97 iov->iov_base = (void *) cl->buf->pos; | |
98 iov->iov_len = size; | |
99 } | |
100 | |
101 prev = cl->buf->pos + size; | |
102 send += size; | |
103 } | |
104 | |
105 n = writev(c->fd, vec.elts, vec.nelts); | |
106 | |
107 if (n == -1) { | |
108 err = ngx_errno; | |
109 | |
110 if (err == NGX_EAGAIN || err == NGX_EINTR) { | |
111 if (err == NGX_EINTR) { | |
112 eintr = 1; | |
113 } | |
114 | |
115 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err, | |
116 "writev() not ready"); | |
117 | |
118 } else { | |
119 wev->error = 1; | |
120 ngx_connection_error(c, err, "writev() failed"); | |
121 return NGX_CHAIN_ERROR; | |
122 } | |
123 } | |
124 | |
125 sent = n > 0 ? n : 0; | |
126 | |
10 | 127 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "writev: %z", sent); |
0 | 128 |
22 | 129 if (send - prev_send == sent) { |
0 | 130 complete = 1; |
131 } | |
132 | |
133 c->sent += sent; | |
134 | |
10 | 135 for (cl = in; cl; cl = cl->next) { |
136 | |
0 | 137 if (ngx_buf_special(cl->buf)) { |
138 continue; | |
139 } | |
140 | |
141 if (sent == 0) { | |
142 break; | |
143 } | |
144 | |
145 size = cl->buf->last - cl->buf->pos; | |
146 | |
147 if (sent >= size) { | |
148 sent -= size; | |
149 cl->buf->pos = cl->buf->last; | |
150 | |
151 continue; | |
152 } | |
153 | |
154 cl->buf->pos += sent; | |
155 | |
156 break; | |
157 } | |
158 | |
159 if (eintr) { | |
160 continue; | |
161 } | |
162 | |
163 if (!complete) { | |
164 wev->ready = 0; | |
165 return cl; | |
166 } | |
167 | |
168 if (send >= limit || cl == NULL) { | |
169 return cl; | |
170 } | |
171 | |
172 in = cl; | |
173 } | |
174 } |