Mercurial > hg > nginx
annotate src/event/quic/ngx_event_quic_frames.h @ 9300:5be23505292b default tip
SSI: fixed incorrect or duplicate stub output.
Following 3518:eb3aaf8bd2a9 (0.8.37), r->request_output is only set
if there are data in the first buffer sent in the subrequest. As a
result, following the change mentioned this flag cannot be used to
prevent duplicate ngx_http_ssi_stub_output() calls, since it is not
set if there was already some output, but the first buffer was empty.
Still, when there are multiple subrequests, even an empty subrequest
response might be delayed by the postpone filter, leading to a second
call of ngx_http_ssi_stub_output() during finalization from
ngx_http_writer() the subreqest buffers are released by the postpone
filter. Since r->request_output is not set after the first call, this
resulted in duplicate stub output.
Additionally, checking only the first buffer might be wrong in some
unusual cases. For example, the first buffer might be empty if
$r->flush() is called before printing any data in the embedded Perl
module.
Depending on the postpone_output value and corresponding sizes, this
issue can result in either duplicate or unexpected stub output, or
"zero size buf in writer" alerts.
Following 8124:f5515e727656 (1.23.4), it became slightly easier to
reproduce the issue, as empty static files and empty cache items now
result in a response with an empty buffer. Before the change, an empty
proxied response can be used to reproduce the issue.
Fix is check all buffers and set r->request_output if any non-empty
buffers are sent. This ensures that all unusual cases of non-empty
responses are covered, and also that r->request_output will be set
after the first stub output, preventing duplicate output.
Reported by Jan Gassen.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 04 Jul 2024 17:41:28 +0300 |
parents | 3c98fa8fef6f |
children |
rev | line source |
---|---|
8749
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
2 /* |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
3 * Copyright (C) Nginx, Inc. |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
4 */ |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
5 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
6 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
7 #ifndef _NGX_EVENT_QUIC_FRAMES_H_INCLUDED_ |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
8 #define _NGX_EVENT_QUIC_FRAMES_H_INCLUDED_ |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
9 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
10 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
11 #include <ngx_config.h> |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
12 #include <ngx_core.h> |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
13 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
14 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
15 typedef ngx_int_t (*ngx_quic_frame_handler_pt)(ngx_connection_t *c, |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
16 ngx_quic_frame_t *frame, void *data); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
17 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
18 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
19 ngx_quic_frame_t *ngx_quic_alloc_frame(ngx_connection_t *c); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
20 void ngx_quic_free_frame(ngx_connection_t *c, ngx_quic_frame_t *frame); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
21 void ngx_quic_free_frames(ngx_connection_t *c, ngx_queue_t *frames); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
22 void ngx_quic_queue_frame(ngx_quic_connection_t *qc, ngx_quic_frame_t *frame); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
23 ngx_int_t ngx_quic_split_frame(ngx_connection_t *c, ngx_quic_frame_t *f, |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
24 size_t len); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
25 |
8948
19e063e955bf
QUIC: renamed buffer-related functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8947
diff
changeset
|
26 ngx_chain_t *ngx_quic_alloc_chain(ngx_connection_t *c); |
19e063e955bf
QUIC: renamed buffer-related functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8947
diff
changeset
|
27 void ngx_quic_free_chain(ngx_connection_t *c, ngx_chain_t *in); |
9011
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8967
diff
changeset
|
28 |
9071
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
9013
diff
changeset
|
29 ngx_chain_t *ngx_quic_copy_buffer(ngx_connection_t *c, u_char *data, |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
9013
diff
changeset
|
30 size_t len); |
9011
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8967
diff
changeset
|
31 ngx_chain_t *ngx_quic_read_buffer(ngx_connection_t *c, ngx_quic_buffer_t *qb, |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8967
diff
changeset
|
32 uint64_t limit); |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8967
diff
changeset
|
33 ngx_chain_t *ngx_quic_write_buffer(ngx_connection_t *c, ngx_quic_buffer_t *qb, |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8967
diff
changeset
|
34 ngx_chain_t *in, uint64_t limit, uint64_t offset); |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8967
diff
changeset
|
35 void ngx_quic_skip_buffer(ngx_connection_t *c, ngx_quic_buffer_t *qb, |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8967
diff
changeset
|
36 uint64_t offset); |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8967
diff
changeset
|
37 void ngx_quic_free_buffer(ngx_connection_t *c, ngx_quic_buffer_t *qb); |
8749
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
38 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
39 #if (NGX_DEBUG) |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
40 void ngx_quic_log_frame(ngx_log_t *log, ngx_quic_frame_t *f, ngx_uint_t tx); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
41 #else |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
42 #define ngx_quic_log_frame(log, f, tx) |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
43 #endif |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
44 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
45 #endif /* _NGX_EVENT_QUIC_FRAMES_H_INCLUDED_ */ |