Mercurial > hg > nginx
annotate src/core/ngx_syslog.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 | 1c9264603adc |
children |
rev | line source |
---|---|
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
2 /* |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
3 * Copyright (C) Nginx, Inc. |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
4 */ |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
5 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
6 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
7 #ifndef _NGX_SYSLOG_H_INCLUDED_ |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
8 #define _NGX_SYSLOG_H_INCLUDED_ |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
9 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
10 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
11 typedef struct { |
8149
29adacffdefa
Syslog: removed usage of ngx_cycle->log and ngx_cycle->hostname.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7277
diff
changeset
|
12 ngx_uint_t facility; |
29adacffdefa
Syslog: removed usage of ngx_cycle->log and ngx_cycle->hostname.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7277
diff
changeset
|
13 ngx_uint_t severity; |
29adacffdefa
Syslog: removed usage of ngx_cycle->log and ngx_cycle->hostname.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7277
diff
changeset
|
14 ngx_str_t tag; |
29adacffdefa
Syslog: removed usage of ngx_cycle->log and ngx_cycle->hostname.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7277
diff
changeset
|
15 |
29adacffdefa
Syslog: removed usage of ngx_cycle->log and ngx_cycle->hostname.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7277
diff
changeset
|
16 ngx_str_t *hostname; |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
17 |
8149
29adacffdefa
Syslog: removed usage of ngx_cycle->log and ngx_cycle->hostname.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7277
diff
changeset
|
18 ngx_addr_t server; |
29adacffdefa
Syslog: removed usage of ngx_cycle->log and ngx_cycle->hostname.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7277
diff
changeset
|
19 ngx_connection_t conn; |
29adacffdefa
Syslog: removed usage of ngx_cycle->log and ngx_cycle->hostname.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7277
diff
changeset
|
20 |
8150
8771d35d55d0
Syslog: introduced error log handler.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8149
diff
changeset
|
21 ngx_log_t log; |
8771d35d55d0
Syslog: introduced error log handler.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8149
diff
changeset
|
22 ngx_log_t *logp; |
8149
29adacffdefa
Syslog: removed usage of ngx_cycle->log and ngx_cycle->hostname.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7277
diff
changeset
|
23 |
9225
1c9264603adc
Syslog: introduced ngx_syslog_send() error logging moderation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8150
diff
changeset
|
24 time_t error_log_time; |
1c9264603adc
Syslog: introduced ngx_syslog_send() error logging moderation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8150
diff
changeset
|
25 time_t connect_error_time; |
1c9264603adc
Syslog: introduced ngx_syslog_send() error logging moderation.
Maxim Dounin <mdounin@mdounin.ru>
parents:
8150
diff
changeset
|
26 |
8149
29adacffdefa
Syslog: removed usage of ngx_cycle->log and ngx_cycle->hostname.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7277
diff
changeset
|
27 unsigned busy:1; |
29adacffdefa
Syslog: removed usage of ngx_cycle->log and ngx_cycle->hostname.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7277
diff
changeset
|
28 unsigned nohostname:1; |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
29 } ngx_syslog_peer_t; |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
30 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
31 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
32 char *ngx_syslog_process_conf(ngx_conf_t *cf, ngx_syslog_peer_t *peer); |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
33 u_char *ngx_syslog_add_header(ngx_syslog_peer_t *peer, u_char *buf); |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
34 void ngx_syslog_writer(ngx_log_t *log, ngx_uint_t level, u_char *buf, |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
35 size_t len); |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
36 ssize_t ngx_syslog_send(ngx_syslog_peer_t *peer, u_char *buf, size_t len); |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
37 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
38 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
39 #endif /* _NGX_SYSLOG_H_INCLUDED_ */ |