Mercurial > hg > nginx-vendor-current
annotate src/os/unix/ngx_aio_write_chain.c @ 634:23ef0645ea57 NGINX_1_1_1
nginx 1.1.1
*) Change: now cache loader processes either as many files as specified
by "loader_files" parameter or works no more than time specified by
"loader_threshold" parameter during each iteration.
*) Change: now SIGWINCH signal works only in deamon mode.
*) Feature: now shared zones and caches use POSIX semaphores on
Solaris.
Thanks to Den Ivanov.
*) Feature: accept filters are now supported on NetBSD.
*) Bugfix: nginx could not be build on Linux 3.0.
*) Bugfix: nginx did not use gzipping in some cases; the bug had
appeared in 1.1.0.
*) Bugfix: request body might be incorrectly processed if client used
pipelining.
*) Bugfix: in the "request_body_in_single_buf" directive.
*) Bugfix: in "proxy_set_body" and "proxy_pass_request_body" directives
if SSL connection to backend was used.
*) Bugfix: nginx hogged CPU if all servers in an upstream were marked
as "down".
*) Bugfix: a segmentation fault might occur during reconfiguration if
ssl_session_cache was defined but not used in a previous
configuration.
*) Bugfix: a segmentation fault might occur in a worker process if many
backup servers were used in an upstream.
*) Bugfix: a segmentation fault might occur in a worker process if
"fastcgi/scgi/uwsgi_param" directives were used with values starting
with "HTTP_"; the bug had appeared in 0.8.40.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 22 Aug 2011 00:00:00 +0400 |
parents | 86dad910eeb6 |
children | d0f7a625f27c |
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 | |
126 | 12 ngx_chain_t * |
13 ngx_aio_write_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit) | |
0 | 14 { |
15 u_char *buf, *prev; | |
16 off_t send, sent; | |
17 size_t len; | |
10 | 18 ssize_t n, size; |
0 | 19 ngx_chain_t *cl; |
20 | |
22 | 21 /* the maximum limit size is the maximum size_t value - the page size */ |
22 | |
324 | 23 if (limit == 0 || limit > (off_t) (NGX_MAX_SIZE_T_VALUE - ngx_pagesize)) { |
26 | 24 limit = NGX_MAX_SIZE_T_VALUE - ngx_pagesize; |
22 | 25 } |
26 | |
0 | 27 send = 0; |
28 sent = 0; | |
29 cl = in; | |
30 | |
31 while (cl) { | |
32 | |
33 if (cl->buf->pos == cl->buf->last) { | |
34 cl = cl->next; | |
35 continue; | |
36 } | |
37 | |
38 /* we can post the single aio operation only */ | |
39 | |
40 if (!c->write->ready) { | |
41 return cl; | |
42 } | |
43 | |
44 buf = cl->buf->pos; | |
45 prev = buf; | |
46 len = 0; | |
47 | |
48 /* coalesce the neighbouring bufs */ | |
49 | |
50 while (cl && prev == cl->buf->pos && send < limit) { | |
51 if (ngx_buf_special(cl->buf)) { | |
52 continue; | |
53 } | |
54 | |
55 size = cl->buf->last - cl->buf->pos; | |
56 | |
57 if (send + size > limit) { | |
58 size = limit - send; | |
59 } | |
60 | |
61 len += size; | |
62 prev = cl->buf->pos + size; | |
63 send += size; | |
64 cl = cl->next; | |
65 } | |
66 | |
67 n = ngx_aio_write(c, buf, len); | |
68 | |
10 | 69 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "aio_write: %z", n); |
0 | 70 |
71 if (n == NGX_ERROR) { | |
72 return NGX_CHAIN_ERROR; | |
73 } | |
74 | |
75 if (n > 0) { | |
76 sent += n; | |
77 c->sent += n; | |
78 } | |
79 | |
80 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, | |
10 | 81 "aio_write sent: %O", c->sent); |
0 | 82 |
83 for (cl = in; cl; cl = cl->next) { | |
84 | |
85 if (sent >= cl->buf->last - cl->buf->pos) { | |
86 sent -= cl->buf->last - cl->buf->pos; | |
87 cl->buf->pos = cl->buf->last; | |
88 | |
89 continue; | |
90 } | |
91 | |
92 cl->buf->pos += sent; | |
93 | |
94 break; | |
95 } | |
96 } | |
97 | |
98 return cl; | |
99 } |