Mercurial > hg > nginx
annotate src/os/unix/ngx_thread.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 | d230c797b168 |
children |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
383
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
383
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
4412 | 4 * Copyright (C) Nginx, Inc. |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
383
diff
changeset
|
5 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
383
diff
changeset
|
6 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
383
diff
changeset
|
7 |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #ifndef _NGX_THREAD_H_INCLUDED_ |
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #define _NGX_THREAD_H_INCLUDED_ |
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 |
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
12 #include <ngx_config.h> |
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
13 #include <ngx_core.h> |
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
14 |
6018
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
15 #if (NGX_THREADS) |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
16 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
17 #include <pthread.h> |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
18 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
19 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
20 typedef pthread_mutex_t ngx_thread_mutex_t; |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
21 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
22 ngx_int_t ngx_thread_mutex_create(ngx_thread_mutex_t *mtx, ngx_log_t *log); |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
23 ngx_int_t ngx_thread_mutex_destroy(ngx_thread_mutex_t *mtx, ngx_log_t *log); |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
24 ngx_int_t ngx_thread_mutex_lock(ngx_thread_mutex_t *mtx, ngx_log_t *log); |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
25 ngx_int_t ngx_thread_mutex_unlock(ngx_thread_mutex_t *mtx, ngx_log_t *log); |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
26 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
27 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
28 typedef pthread_cond_t ngx_thread_cond_t; |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
29 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
30 ngx_int_t ngx_thread_cond_create(ngx_thread_cond_t *cond, ngx_log_t *log); |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
31 ngx_int_t ngx_thread_cond_destroy(ngx_thread_cond_t *cond, ngx_log_t *log); |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
32 ngx_int_t ngx_thread_cond_signal(ngx_thread_cond_t *cond, ngx_log_t *log); |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
33 ngx_int_t ngx_thread_cond_wait(ngx_thread_cond_t *cond, ngx_thread_mutex_t *mtx, |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
34 ngx_log_t *log); |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
35 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
36 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
37 #if (NGX_LINUX) |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
38 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
39 typedef pid_t ngx_tid_t; |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
40 #define NGX_TID_T_FMT "%P" |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
41 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
42 #elif (NGX_FREEBSD) |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
43 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
44 typedef uint32_t ngx_tid_t; |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
45 #define NGX_TID_T_FMT "%uD" |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
46 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
47 #elif (NGX_DARWIN) |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
48 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
49 typedef uint64_t ngx_tid_t; |
7323
d230c797b168
Fixed NGX_TID_T_FMT format specification for uint64_t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6032
diff
changeset
|
50 #define NGX_TID_T_FMT "%uL" |
6018
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
51 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
52 #else |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
53 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
54 typedef uint64_t ngx_tid_t; |
7323
d230c797b168
Fixed NGX_TID_T_FMT format specification for uint64_t.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6032
diff
changeset
|
55 #define NGX_TID_T_FMT "%uL" |
6018
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
56 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
57 #endif |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
58 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
59 ngx_tid_t ngx_thread_tid(void); |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
60 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
61 #define ngx_log_tid ngx_thread_tid() |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
62 |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
63 #else |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
64 |
461 | 65 #define ngx_log_tid 0 |
66 #define NGX_TID_T_FMT "%d" | |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
67 |
6018
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
68 #endif |
466bd63b63d1
Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
6016
diff
changeset
|
69 |
266
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
70 |
5238e93961a1
nginx-0.0.2-2004-02-23-23:57:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
71 #endif /* _NGX_THREAD_H_INCLUDED_ */ |