Mercurial > hg > nginx-quic
annotate docs/xsls/changes.xsls @ 6893:a3e6d660b179 stable-1.10
Fixed trailer construction with limit on FreeBSD and macOS.
The ngx_chain_coalesce_file() function may produce more bytes to send then
requested in the limit passed, as it aligns the last file position
to send to memory page boundary. As a result, (limit - send) may become
negative. This resulted in big positive number when converted to size_t
while calling ngx_output_chain_to_iovec().
Another part of the problem is in ngx_chain_coalesce_file(): it changes cl
to the next chain link even if the current buffer is only partially sent
due to limit.
Therefore, if a file buffer was not expected to be fully sent due to limit,
and was followed by a memory buffer, nginx called sendfile() with a part
of the file buffer, and the memory buffer in trailer. If there were enough
room in the socket buffer, this resulted in a part of the file buffer being
skipped, and corresponding part of the memory buffer sent instead.
The bug was introduced in 8e903522c17a (1.7.8). Configurations affected
are ones using limits, that is, limit_rate and/or sendfile_max_chunk, and
memory buffers after file ones (may happen when using subrequests or
with proxying with disk buffering).
Fix is to explicitly check if (send < limit) before constructing trailer
with ngx_output_chain_to_iovec(). Additionally, ngx_chain_coalesce_file()
was modified to preserve unfinished file buffers in cl.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Fri, 20 Jan 2017 21:12:48 +0300 |
parents | 76bc29f06168 |
children | 529f10f7757c |
rev | line source |
---|---|
450 | 1 X:stylesheet { |
2 | |
4028
76bc29f06168
CHANGES conversion from KOI8-R to UTF-8.
Igor Sysoev <igor@sysoev.ru>
parents:
4025
diff
changeset
|
3 X:output method="text"; |
450 | 4 |
5 X:param lang="'en'"; | |
6 X:param configuration="'../xml/change_log_conf.xml'"; | |
7 | |
8 X:var conf = "document($configuration)/configuration"; | |
9 X:var start = "$conf/start"; | |
10 X:var indent = "$conf/indent"; | |
11 X:var max = "$conf/length"; | |
12 X:var br = {<br>} | |
13 | |
14 | |
15 X:template = "/" { !! "change_log"; } | |
16 X:template = "change_log" { !! "changes"; } | |
17 | |
18 | |
19 X:template = "changes" { | |
20 X:text { } | |
21 | |
22 !{substring(concat($conf/changes[@lang=$lang]/title, | |
23 //change_log/@title, | |
24 ' ', @ver, | |
25 ' '), | |
26 1, $conf/changes[@lang=$lang]/length)} | |
27 | |
28 X:if "$lang='ru'" { !{@date} } | |
29 | |
30 X:if "$lang='en'" { | |
31 !{substring(@date, 1, 2)} | |
32 !{$conf/changes[@lang=$lang]/month[number(substring(current()/@date, | |
33 4, 2))]} | |
34 !{substring(@date, 7, 4)} | |
35 } | |
36 | |
37 X:text { } | |
38 | |
39 !! "change"; | |
40 | |
41 X:text { } | |
42 } | |
43 | |
44 | |
45 X:template = "change" { | |
46 X:var prefix = "$conf/changes[@lang=$lang]/*[local-name(.)=current()/@type]" | |
47 | |
48 X:var postfix = { X:if "$prefix" { X:text {: } } } | |
49 | |
50 !! "para[@lang=$lang]" (prefix = "concat($start, $prefix, $postfix)"); | |
51 } | |
52 | |
53 | |
54 X:template para(prefix) = "para" { | |
55 X:var text = { !!; } | |
56 | |
57 X:text { } | |
58 | |
59 !wrap(text = "normalize-space($text)", | |
60 prefix = { X:if "position() = 1" { !{$prefix} } else { !{$indent} } }) | |
61 } | |
62 | |
63 | |
64 X:template wrap(text, prefix) { | |
65 X:if "$text" { | |
66 X:var offset = { | |
4022
10b3b7908efb
- support <br/> in the middle of input
Ruslan Ermilov <ru@nginx.com>
parents:
450
diff
changeset
|
67 X:choose { |
10b3b7908efb
- support <br/> in the middle of input
Ruslan Ermilov <ru@nginx.com>
parents:
450
diff
changeset
|
68 X:when "starts-with($text, concat($br, ' '))" { |
10b3b7908efb
- support <br/> in the middle of input
Ruslan Ermilov <ru@nginx.com>
parents:
450
diff
changeset
|
69 !{string-length($br) + 2} |
10b3b7908efb
- support <br/> in the middle of input
Ruslan Ermilov <ru@nginx.com>
parents:
450
diff
changeset
|
70 } |
10b3b7908efb
- support <br/> in the middle of input
Ruslan Ermilov <ru@nginx.com>
parents:
450
diff
changeset
|
71 X:when "starts-with($text, $br)" { |
10b3b7908efb
- support <br/> in the middle of input
Ruslan Ermilov <ru@nginx.com>
parents:
450
diff
changeset
|
72 !{string-length($br) + 1} |
10b3b7908efb
- support <br/> in the middle of input
Ruslan Ermilov <ru@nginx.com>
parents:
450
diff
changeset
|
73 } |
10b3b7908efb
- support <br/> in the middle of input
Ruslan Ermilov <ru@nginx.com>
parents:
450
diff
changeset
|
74 X:otherwise { |
10b3b7908efb
- support <br/> in the middle of input
Ruslan Ermilov <ru@nginx.com>
parents:
450
diff
changeset
|
75 1 |
10b3b7908efb
- support <br/> in the middle of input
Ruslan Ermilov <ru@nginx.com>
parents:
450
diff
changeset
|
76 } |
450 | 77 } |
78 } | |
79 | |
80 X:var length = { | |
81 !length(text = "substring($text, $offset)", | |
82 prefix = "string-length($prefix)", | |
83 length = "$max") | |
84 } | |
85 | |
86 !{$prefix} | |
87 | |
4025
7b85e695600a
Traling spaces removal in text CHANGES files.
Igor Sysoev <igor@sysoev.ru>
parents:
4022
diff
changeset
|
88 !{normalize-space(translate(substring($text, $offset, $length), |
7b85e695600a
Traling spaces removal in text CHANGES files.
Igor Sysoev <igor@sysoev.ru>
parents:
4022
diff
changeset
|
89 ' ', ' '))} |
450 | 90 |
91 X:text { } | |
92 | |
93 !wrap(text = "substring($text, $length + $offset)", prefix = "$indent") | |
94 } | |
95 } | |
96 | |
97 | |
98 X:template length(text, prefix, length) { | |
4022
10b3b7908efb
- support <br/> in the middle of input
Ruslan Ermilov <ru@nginx.com>
parents:
450
diff
changeset
|
99 X:var break = "substring-before(substring($text, 1, |
10b3b7908efb
- support <br/> in the middle of input
Ruslan Ermilov <ru@nginx.com>
parents:
450
diff
changeset
|
100 $length - $prefix + string-length($br)), |
450 | 101 $br)" |
102 | |
103 X:choose { | |
104 X:when "$break" { !{string-length($break)} } | |
105 | |
4022
10b3b7908efb
- support <br/> in the middle of input
Ruslan Ermilov <ru@nginx.com>
parents:
450
diff
changeset
|
106 X:when "$length = 0" { !{$max - $prefix} } |
450 | 107 |
4022
10b3b7908efb
- support <br/> in the middle of input
Ruslan Ermilov <ru@nginx.com>
parents:
450
diff
changeset
|
108 X:when "string-length($text) + $prefix <= $length" { |
450 | 109 !{$length - $prefix} |
110 } | |
111 | |
4022
10b3b7908efb
- support <br/> in the middle of input
Ruslan Ermilov <ru@nginx.com>
parents:
450
diff
changeset
|
112 X:when "substring($text, $length - $prefix + 1, 1) = ' '" { |
10b3b7908efb
- support <br/> in the middle of input
Ruslan Ermilov <ru@nginx.com>
parents:
450
diff
changeset
|
113 !{$length - $prefix + 1} |
10b3b7908efb
- support <br/> in the middle of input
Ruslan Ermilov <ru@nginx.com>
parents:
450
diff
changeset
|
114 } |
10b3b7908efb
- support <br/> in the middle of input
Ruslan Ermilov <ru@nginx.com>
parents:
450
diff
changeset
|
115 |
450 | 116 X:otherwise { |
117 !length(text = "$text", prefix = "$prefix", length = "$length - 1") | |
118 } | |
119 } | |
120 } | |
121 | |
122 | |
123 X:template = "at" {@} | |
124 X:template = "br" { !{$br} } | |
125 X:template = "nobr" { !{translate(., ' ', ' ')} } | |
126 | |
127 | |
128 } |