Mercurial > hg > nginx
annotate src/core/ngx_bpf.h @ 9300:5be23505292b
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 | d3747ba486e7 |
children |
rev | line source |
---|---|
8675
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1 |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
2 /* |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
3 * Copyright (C) Nginx, Inc. |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
4 */ |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
5 |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
6 |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
7 #ifndef _NGX_BPF_H_INCLUDED_ |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
8 #define _NGX_BPF_H_INCLUDED_ |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
9 |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
10 |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
11 #include <ngx_config.h> |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
12 #include <ngx_core.h> |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
13 |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
14 #include <linux/bpf.h> |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
15 |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
16 |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
17 typedef struct { |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
18 char *name; |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
19 int offset; |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
20 } ngx_bpf_reloc_t; |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
21 |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
22 typedef struct { |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
23 char *license; |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
24 enum bpf_prog_type type; |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
25 struct bpf_insn *ins; |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
26 size_t nins; |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
27 ngx_bpf_reloc_t *relocs; |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
28 size_t nrelocs; |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
29 } ngx_bpf_program_t; |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
30 |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
31 |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
32 void ngx_bpf_program_link(ngx_bpf_program_t *program, const char *symbol, |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
33 int fd); |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
34 int ngx_bpf_load_program(ngx_log_t *log, ngx_bpf_program_t *program); |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
35 |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
36 int ngx_bpf_map_create(ngx_log_t *log, enum bpf_map_type type, int key_size, |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
37 int value_size, int max_entries, uint32_t map_flags); |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
38 int ngx_bpf_map_update(int fd, const void *key, const void *value, |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
39 uint64_t flags); |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
40 int ngx_bpf_map_delete(int fd, const void *key); |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
41 int ngx_bpf_map_lookup(int fd, const void *key, void *value); |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
42 |
d3747ba486e7
Core: added interface to linux bpf() system call.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
43 #endif /* _NGX_BPF_H_INCLUDED_ */ |