Mercurial > hg > nginx-quic
annotate src/http/ngx_http_copy_filter_module.c @ 7726:f388c0ad3477 quic
Added processing of client transport parameters.
note:
+ parameters are available in SSL connection since they are obtained by ssl
stack
quote:
During connection establishment, both endpoints make authenticated
declarations of their transport parameters. These declarations are
made unilaterally by each endpoint.
and really, we send our parameters before we read client's.
no handling of incoming parameters is made by this patch.
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Sat, 21 Mar 2020 20:51:59 +0300 |
parents | ce37362a7a70 |
children | 555533169506 |
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:
386
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:
386
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:
386
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:
386
diff
changeset
|
6 |
3
34a521b1a148
nginx-0.0.1-2002-08-20-18:48:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 |
33
b2e039840718
nginx-0.0.1-2002-12-19-20:49:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
32
diff
changeset
|
8 #include <ngx_config.h> |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
9 #include <ngx_core.h> |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
10 #include <ngx_http.h> |
43
53cd05892261
nginx-0.0.1-2002-12-27-19:22:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
42
diff
changeset
|
11 |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
12 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
13 typedef struct { |
141
656d468f4ead
nginx-0.0.1-2003-10-08-19:32:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
135
diff
changeset
|
14 ngx_bufs_t bufs; |
334
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
15 } ngx_http_copy_filter_conf_t; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
16 |
43
53cd05892261
nginx-0.0.1-2002-12-27-19:22:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
42
diff
changeset
|
17 |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
18 #if (NGX_HAVE_FILE_AIO) |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
19 static void ngx_http_copy_aio_handler(ngx_output_chain_ctx_t *ctx, |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
20 ngx_file_t *file); |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
21 static void ngx_http_copy_aio_event_handler(ngx_event_t *ev); |
3065 | 22 #if (NGX_HAVE_AIO_SENDFILE) |
5980
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5498
diff
changeset
|
23 static ssize_t ngx_http_copy_aio_sendfile_preload(ngx_buf_t *file); |
3065 | 24 static void ngx_http_copy_aio_sendfile_event_handler(ngx_event_t *ev); |
25 #endif | |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
26 #endif |
6022
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
27 #if (NGX_THREADS) |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
28 static ngx_int_t ngx_http_copy_thread_handler(ngx_thread_task_t *task, |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
29 ngx_file_t *file); |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
30 static void ngx_http_copy_thread_event_handler(ngx_event_t *ev); |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
31 #endif |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
32 |
334
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
33 static void *ngx_http_copy_filter_create_conf(ngx_conf_t *cf); |
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
34 static char *ngx_http_copy_filter_merge_conf(ngx_conf_t *cf, |
501 | 35 void *parent, void *child); |
681 | 36 static ngx_int_t ngx_http_copy_filter_init(ngx_conf_t *cf); |
10
4f3879d9b6f6
nginx-0.0.1-2002-09-11-19:18:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
9
diff
changeset
|
37 |
4f3879d9b6f6
nginx-0.0.1-2002-09-11-19:18:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
9
diff
changeset
|
38 |
334
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
39 static ngx_command_t ngx_http_copy_filter_commands[] = { |
10
4f3879d9b6f6
nginx-0.0.1-2002-09-11-19:18:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
9
diff
changeset
|
40 |
501 | 41 { ngx_string("output_buffers"), |
42 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2, | |
43 ngx_conf_set_bufs_slot, | |
44 NGX_HTTP_LOC_CONF_OFFSET, | |
45 offsetof(ngx_http_copy_filter_conf_t, bufs), | |
46 NULL }, | |
10
4f3879d9b6f6
nginx-0.0.1-2002-09-11-19:18:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
9
diff
changeset
|
47 |
501 | 48 ngx_null_command |
9
6f58641241bb
nginx-0.0.1-2002-09-07-14:14:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
8
diff
changeset
|
49 }; |
3
34a521b1a148
nginx-0.0.1-2002-08-20-18:48:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
50 |
8
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
51 |
334
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
52 static ngx_http_module_t ngx_http_copy_filter_module_ctx = { |
509 | 53 NULL, /* preconfiguration */ |
681 | 54 ngx_http_copy_filter_init, /* postconfiguration */ |
177
4db54fdbcbe7
nginx-0.0.1-2003-11-10-20:17:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
55 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
56 NULL, /* create main configuration */ |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
57 NULL, /* init main configuration */ |
69
e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
Igor Sysoev <igor@sysoev.ru>
parents:
67
diff
changeset
|
58 |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
59 NULL, /* create server configuration */ |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
60 NULL, /* merge server configuration */ |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
90
diff
changeset
|
61 |
334
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
62 ngx_http_copy_filter_create_conf, /* create location configuration */ |
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
63 ngx_http_copy_filter_merge_conf /* merge location configuration */ |
26
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
64 }; |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
65 |
53cb81681040
nginx-0.0.1-2002-12-15-09:25:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
24
diff
changeset
|
66 |
334
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
67 ngx_module_t ngx_http_copy_filter_module = { |
509 | 68 NGX_MODULE_V1, |
334
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
69 &ngx_http_copy_filter_module_ctx, /* module context */ |
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
70 ngx_http_copy_filter_commands, /* module directives */ |
96
a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
95
diff
changeset
|
71 NGX_HTTP_MODULE, /* module type */ |
541 | 72 NULL, /* init master */ |
681 | 73 NULL, /* init module */ |
541 | 74 NULL, /* init process */ |
75 NULL, /* init thread */ | |
76 NULL, /* exit thread */ | |
77 NULL, /* exit process */ | |
78 NULL, /* exit master */ | |
79 NGX_MODULE_V1_PADDING | |
40
d5d4f3bba6f0
nginx-0.0.1-2002-12-26-10:24:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
33
diff
changeset
|
80 }; |
8
708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
Igor Sysoev <igor@sysoev.ru>
parents:
7
diff
changeset
|
81 |
3
34a521b1a148
nginx-0.0.1-2002-08-20-18:48:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
82 |
4542
586969d972b9
Local variable "ngx_http_next_filter" renamed to "ngx_http_next_body_filter"
Ruslan Ermilov <ru@nginx.com>
parents:
4415
diff
changeset
|
83 static ngx_http_output_body_filter_pt ngx_http_next_body_filter; |
141
656d468f4ead
nginx-0.0.1-2003-10-08-19:32:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
135
diff
changeset
|
84 |
334
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
85 |
501 | 86 static ngx_int_t |
87 ngx_http_copy_filter(ngx_http_request_t *r, ngx_chain_t *in) | |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
88 { |
583 | 89 ngx_int_t rc; |
90 ngx_connection_t *c; | |
334
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
91 ngx_output_chain_ctx_t *ctx; |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
92 ngx_http_core_loc_conf_t *clcf; |
334
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
93 ngx_http_copy_filter_conf_t *conf; |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
94 |
583 | 95 c = r->connection; |
96 | |
97 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
3062
aa720192937b
use local variable and fix debug log message
Igor Sysoev <igor@sysoev.ru>
parents:
3053
diff
changeset
|
98 "http copy filter: \"%V?%V\"", &r->uri, &r->args); |
509 | 99 |
100 ctx = ngx_http_get_module_ctx(r, ngx_http_copy_filter_module); | |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
101 |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
102 if (ctx == NULL) { |
501 | 103 ctx = ngx_pcalloc(r->pool, sizeof(ngx_output_chain_ctx_t)); |
104 if (ctx == NULL) { | |
105 return NGX_ERROR; | |
106 } | |
107 | |
108 ngx_http_set_ctx(r, ctx, ngx_http_copy_filter_module); | |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
109 |
3053 | 110 conf = ngx_http_get_module_loc_conf(r, ngx_http_copy_filter_module); |
111 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | |
112 | |
583 | 113 ctx->sendfile = c->sendfile; |
513 | 114 ctx->need_in_memory = r->main_filter_need_in_memory |
115 || r->filter_need_in_memory; | |
346
55e496a8ece3
nginx-0.0.3-2004-06-06-23:49:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
343
diff
changeset
|
116 ctx->need_in_temp = r->filter_need_temporary; |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
117 |
3053 | 118 ctx->alignment = clcf->directio_alignment; |
119 | |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
120 ctx->pool = r->pool; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
121 ctx->bufs = conf->bufs; |
343
6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
Igor Sysoev <igor@sysoev.ru>
parents:
334
diff
changeset
|
122 ctx->tag = (ngx_buf_tag_t) &ngx_http_copy_filter_module; |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
123 |
4542
586969d972b9
Local variable "ngx_http_next_filter" renamed to "ngx_http_next_body_filter"
Ruslan Ermilov <ru@nginx.com>
parents:
4415
diff
changeset
|
124 ctx->output_filter = (ngx_output_chain_filter_pt) |
586969d972b9
Local variable "ngx_http_next_filter" renamed to "ngx_http_next_body_filter"
Ruslan Ermilov <ru@nginx.com>
parents:
4415
diff
changeset
|
125 ngx_http_next_body_filter; |
294
5cfd65b8b0a7
nginx-0.0.3-2004-03-23-09:01:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
177
diff
changeset
|
126 ctx->filter_ctx = r; |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
127 |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
128 #if (NGX_HAVE_FILE_AIO) |
6022
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
129 if (ngx_file_aio && clcf->aio == NGX_HTTP_AIO_ON) { |
6004 | 130 ctx->aio_handler = ngx_http_copy_aio_handler; |
3065 | 131 #if (NGX_HAVE_AIO_SENDFILE) |
6004 | 132 ctx->aio_preload = ngx_http_copy_aio_sendfile_preload; |
3065 | 133 #endif |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
134 } |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
135 #endif |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
136 |
6022
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
137 #if (NGX_THREADS) |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
138 if (clcf->aio == NGX_HTTP_AIO_THREADS) { |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
139 ctx->thread_handler = ngx_http_copy_thread_handler; |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
140 } |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
141 #endif |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
142 |
3518
eb3aaf8bd2a9
fix SSI include stub for valid empty responses
Igor Sysoev <igor@sysoev.ru>
parents:
3294
diff
changeset
|
143 if (in && in->buf && ngx_buf_size(in->buf)) { |
eb3aaf8bd2a9
fix SSI include stub for valid empty responses
Igor Sysoev <igor@sysoev.ru>
parents:
3294
diff
changeset
|
144 r->request_output = 1; |
eb3aaf8bd2a9
fix SSI include stub for valid empty responses
Igor Sysoev <igor@sysoev.ru>
parents:
3294
diff
changeset
|
145 } |
60
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
146 } |
50186b49f2ad
nginx-0.0.1-2003-02-11-10:14:40 import
Igor Sysoev <igor@sysoev.ru>
parents:
59
diff
changeset
|
147 |
6022
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
148 #if (NGX_HAVE_FILE_AIO || NGX_THREADS) |
3119
4c90c9129a82
fix case when the output filter should add incoming buffers
Igor Sysoev <igor@sysoev.ru>
parents:
3110
diff
changeset
|
149 ctx->aio = r->aio; |
4c90c9129a82
fix case when the output filter should add incoming buffers
Igor Sysoev <igor@sysoev.ru>
parents:
3110
diff
changeset
|
150 #endif |
4c90c9129a82
fix case when the output filter should add incoming buffers
Igor Sysoev <igor@sysoev.ru>
parents:
3110
diff
changeset
|
151 |
5980
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5498
diff
changeset
|
152 rc = ngx_output_chain(ctx, in); |
583 | 153 |
5980
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5498
diff
changeset
|
154 if (ctx->in == NULL) { |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5498
diff
changeset
|
155 r->buffered &= ~NGX_HTTP_COPY_BUFFERED; |
3071
ffc270f696ed
retry aio sendfile if data are ready
Igor Sysoev <igor@sysoev.ru>
parents:
3070
diff
changeset
|
156 |
5980
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5498
diff
changeset
|
157 } else { |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5498
diff
changeset
|
158 r->buffered |= NGX_HTTP_COPY_BUFFERED; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5498
diff
changeset
|
159 } |
3065 | 160 |
5980
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5498
diff
changeset
|
161 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0, |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5498
diff
changeset
|
162 "http copy filter: %i \"%V?%V\"", rc, &r->uri, &r->args); |
3071
ffc270f696ed
retry aio sendfile if data are ready
Igor Sysoev <igor@sysoev.ru>
parents:
3070
diff
changeset
|
163 |
5980
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5498
diff
changeset
|
164 return rc; |
4
c5f071d376e5
nginx-0.0.1-2002-08-22-19:24:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
3
diff
changeset
|
165 } |
9
6f58641241bb
nginx-0.0.1-2002-09-07-14:14:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
8
diff
changeset
|
166 |
6f58641241bb
nginx-0.0.1-2002-09-07-14:14:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
8
diff
changeset
|
167 |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
168 #if (NGX_HAVE_FILE_AIO) |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
169 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
170 static void |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
171 ngx_http_copy_aio_handler(ngx_output_chain_ctx_t *ctx, ngx_file_t *file) |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
172 { |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
173 ngx_http_request_t *r; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
174 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
175 r = ctx->filter_ctx; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
176 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
177 file->aio->data = r; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
178 file->aio->handler = ngx_http_copy_aio_event_handler; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
179 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
180 r->main->blocked++; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
181 r->aio = 1; |
3776
7450029ff51e
file AIO read may be posted inside loop
Igor Sysoev <igor@sysoev.ru>
parents:
3518
diff
changeset
|
182 ctx->aio = 1; |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
183 } |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
184 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
185 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
186 static void |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
187 ngx_http_copy_aio_event_handler(ngx_event_t *ev) |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
188 { |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
189 ngx_event_aio_t *aio; |
6951
ce37362a7a70
Copy filter: wake up subrequests after aio operations.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
190 ngx_connection_t *c; |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
191 ngx_http_request_t *r; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
192 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
193 aio = ev->data; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
194 r = aio->data; |
6951
ce37362a7a70
Copy filter: wake up subrequests after aio operations.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
195 c = r->connection; |
ce37362a7a70
Copy filter: wake up subrequests after aio operations.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
196 |
ce37362a7a70
Copy filter: wake up subrequests after aio operations.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
197 ngx_http_set_log_request(c->log, r); |
ce37362a7a70
Copy filter: wake up subrequests after aio operations.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
198 |
ce37362a7a70
Copy filter: wake up subrequests after aio operations.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
199 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, |
ce37362a7a70
Copy filter: wake up subrequests after aio operations.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
200 "http aio: \"%V?%V\"", &r->uri, &r->args); |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
201 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
202 r->main->blocked--; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
203 r->aio = 0; |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
204 |
6951
ce37362a7a70
Copy filter: wake up subrequests after aio operations.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
205 r->write_event_handler(r); |
ce37362a7a70
Copy filter: wake up subrequests after aio operations.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
206 |
ce37362a7a70
Copy filter: wake up subrequests after aio operations.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
207 ngx_http_run_posted_requests(c); |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
208 } |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
209 |
3065 | 210 |
211 #if (NGX_HAVE_AIO_SENDFILE) | |
212 | |
5980
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5498
diff
changeset
|
213 static ssize_t |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5498
diff
changeset
|
214 ngx_http_copy_aio_sendfile_preload(ngx_buf_t *file) |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5498
diff
changeset
|
215 { |
6423
c5f81dcf97a7
Copy filter: fixed sendfile aio handlers to set ctx->aio.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6250
diff
changeset
|
216 ssize_t n; |
c5f81dcf97a7
Copy filter: fixed sendfile aio handlers to set ctx->aio.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6250
diff
changeset
|
217 static u_char buf[1]; |
c5f81dcf97a7
Copy filter: fixed sendfile aio handlers to set ctx->aio.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6250
diff
changeset
|
218 ngx_event_aio_t *aio; |
c5f81dcf97a7
Copy filter: fixed sendfile aio handlers to set ctx->aio.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6250
diff
changeset
|
219 ngx_http_request_t *r; |
c5f81dcf97a7
Copy filter: fixed sendfile aio handlers to set ctx->aio.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6250
diff
changeset
|
220 ngx_output_chain_ctx_t *ctx; |
5980
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5498
diff
changeset
|
221 |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5498
diff
changeset
|
222 n = ngx_file_aio_read(file->file, buf, 1, file->file_pos, NULL); |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5498
diff
changeset
|
223 |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5498
diff
changeset
|
224 if (n == NGX_AGAIN) { |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5498
diff
changeset
|
225 aio = file->file->aio; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5498
diff
changeset
|
226 aio->handler = ngx_http_copy_aio_sendfile_event_handler; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5498
diff
changeset
|
227 |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5498
diff
changeset
|
228 r = aio->data; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5498
diff
changeset
|
229 r->main->blocked++; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5498
diff
changeset
|
230 r->aio = 1; |
6423
c5f81dcf97a7
Copy filter: fixed sendfile aio handlers to set ctx->aio.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6250
diff
changeset
|
231 |
c5f81dcf97a7
Copy filter: fixed sendfile aio handlers to set ctx->aio.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6250
diff
changeset
|
232 ctx = ngx_http_get_module_ctx(r, ngx_http_copy_filter_module); |
c5f81dcf97a7
Copy filter: fixed sendfile aio handlers to set ctx->aio.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6250
diff
changeset
|
233 ctx->aio = 1; |
5980
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5498
diff
changeset
|
234 } |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5498
diff
changeset
|
235 |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5498
diff
changeset
|
236 return n; |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5498
diff
changeset
|
237 } |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5498
diff
changeset
|
238 |
ccad84a174e0
Refactored sendfile() AIO preload.
Valentin Bartenev <vbart@nginx.com>
parents:
5498
diff
changeset
|
239 |
3065 | 240 static void |
241 ngx_http_copy_aio_sendfile_event_handler(ngx_event_t *ev) | |
242 { | |
243 ngx_event_aio_t *aio; | |
244 ngx_http_request_t *r; | |
245 | |
246 aio = ev->data; | |
247 r = aio->data; | |
248 | |
249 r->main->blocked--; | |
250 r->aio = 0; | |
251 ev->complete = 0; | |
252 | |
253 r->connection->write->handler(r->connection->write); | |
254 } | |
255 | |
256 #endif | |
3052
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
257 #endif |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
258 |
6060225e9261
FreeBSD and Linux AIO support
Igor Sysoev <igor@sysoev.ru>
parents:
3050
diff
changeset
|
259 |
6022
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
260 #if (NGX_THREADS) |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
261 |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
262 static ngx_int_t |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
263 ngx_http_copy_thread_handler(ngx_thread_task_t *task, ngx_file_t *file) |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
264 { |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
265 ngx_str_t name; |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
266 ngx_thread_pool_t *tp; |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
267 ngx_http_request_t *r; |
6423
c5f81dcf97a7
Copy filter: fixed sendfile aio handlers to set ctx->aio.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6250
diff
changeset
|
268 ngx_output_chain_ctx_t *ctx; |
6022
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
269 ngx_http_core_loc_conf_t *clcf; |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
270 |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
271 r = file->thread_ctx; |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
272 |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
273 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
274 tp = clcf->thread_pool; |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
275 |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
276 if (tp == NULL) { |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
277 if (ngx_http_complex_value(r, clcf->thread_pool_value, &name) |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
278 != NGX_OK) |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
279 { |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
280 return NGX_ERROR; |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
281 } |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
282 |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
283 tp = ngx_thread_pool_get((ngx_cycle_t *) ngx_cycle, &name); |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
284 |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
285 if (tp == NULL) { |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
286 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
287 "thread pool \"%V\" not found", &name); |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
288 return NGX_ERROR; |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
289 } |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
290 } |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
291 |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
292 task->event.data = r; |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
293 task->event.handler = ngx_http_copy_thread_event_handler; |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
294 |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
295 if (ngx_thread_task_post(tp, task) != NGX_OK) { |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
296 return NGX_ERROR; |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
297 } |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
298 |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
299 r->main->blocked++; |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
300 r->aio = 1; |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
301 |
6423
c5f81dcf97a7
Copy filter: fixed sendfile aio handlers to set ctx->aio.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6250
diff
changeset
|
302 ctx = ngx_http_get_module_ctx(r, ngx_http_copy_filter_module); |
c5f81dcf97a7
Copy filter: fixed sendfile aio handlers to set ctx->aio.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6250
diff
changeset
|
303 ctx->aio = 1; |
c5f81dcf97a7
Copy filter: fixed sendfile aio handlers to set ctx->aio.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6250
diff
changeset
|
304 |
6022
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
305 return NGX_OK; |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
306 } |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
307 |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
308 |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
309 static void |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
310 ngx_http_copy_thread_event_handler(ngx_event_t *ev) |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
311 { |
6951
ce37362a7a70
Copy filter: wake up subrequests after aio operations.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
312 ngx_connection_t *c; |
6022
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
313 ngx_http_request_t *r; |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
314 |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
315 r = ev->data; |
6951
ce37362a7a70
Copy filter: wake up subrequests after aio operations.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
316 c = r->connection; |
ce37362a7a70
Copy filter: wake up subrequests after aio operations.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
317 |
ce37362a7a70
Copy filter: wake up subrequests after aio operations.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
318 ngx_http_set_log_request(c->log, r); |
ce37362a7a70
Copy filter: wake up subrequests after aio operations.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
319 |
ce37362a7a70
Copy filter: wake up subrequests after aio operations.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
320 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, |
ce37362a7a70
Copy filter: wake up subrequests after aio operations.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
321 "http thread: \"%V?%V\"", &r->uri, &r->args); |
6022
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
322 |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
323 r->main->blocked--; |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
324 r->aio = 0; |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
325 |
6951
ce37362a7a70
Copy filter: wake up subrequests after aio operations.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
326 if (r->done) { |
ce37362a7a70
Copy filter: wake up subrequests after aio operations.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
327 /* |
ce37362a7a70
Copy filter: wake up subrequests after aio operations.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
328 * trigger connection event handler if the subrequest was |
ce37362a7a70
Copy filter: wake up subrequests after aio operations.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
329 * already finalized; this can happen if the handler is used |
ce37362a7a70
Copy filter: wake up subrequests after aio operations.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
330 * for sendfile() in threads |
ce37362a7a70
Copy filter: wake up subrequests after aio operations.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
331 */ |
ce37362a7a70
Copy filter: wake up subrequests after aio operations.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
332 |
ce37362a7a70
Copy filter: wake up subrequests after aio operations.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
333 c->write->handler(c->write); |
ce37362a7a70
Copy filter: wake up subrequests after aio operations.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
334 |
ce37362a7a70
Copy filter: wake up subrequests after aio operations.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
335 } else { |
ce37362a7a70
Copy filter: wake up subrequests after aio operations.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
336 r->write_event_handler(r); |
ce37362a7a70
Copy filter: wake up subrequests after aio operations.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
337 ngx_http_run_posted_requests(c); |
ce37362a7a70
Copy filter: wake up subrequests after aio operations.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6423
diff
changeset
|
338 } |
6022
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
339 } |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
340 |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
341 #endif |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
342 |
1fdba317ee6d
Added support for offloading read() in thread pools.
Valentin Bartenev <vbart@nginx.com>
parents:
6004
diff
changeset
|
343 |
501 | 344 static void * |
345 ngx_http_copy_filter_create_conf(ngx_conf_t *cf) | |
9
6f58641241bb
nginx-0.0.1-2002-09-07-14:14:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
8
diff
changeset
|
346 { |
334
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
347 ngx_http_copy_filter_conf_t *conf; |
9
6f58641241bb
nginx-0.0.1-2002-09-07-14:14:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
8
diff
changeset
|
348 |
501 | 349 conf = ngx_palloc(cf->pool, sizeof(ngx_http_copy_filter_conf_t)); |
350 if (conf == NULL) { | |
351 return NULL; | |
352 } | |
9
6f58641241bb
nginx-0.0.1-2002-09-07-14:14:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
8
diff
changeset
|
353 |
141
656d468f4ead
nginx-0.0.1-2003-10-08-19:32:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
135
diff
changeset
|
354 conf->bufs.num = 0; |
10
4f3879d9b6f6
nginx-0.0.1-2002-09-11-19:18:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
9
diff
changeset
|
355 |
4f3879d9b6f6
nginx-0.0.1-2002-09-11-19:18:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
9
diff
changeset
|
356 return conf; |
9
6f58641241bb
nginx-0.0.1-2002-09-07-14:14:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
8
diff
changeset
|
357 } |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
43
diff
changeset
|
358 |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
43
diff
changeset
|
359 |
501 | 360 static char * |
361 ngx_http_copy_filter_merge_conf(ngx_conf_t *cf, void *parent, void *child) | |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
43
diff
changeset
|
362 { |
334
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
363 ngx_http_copy_filter_conf_t *prev = parent; |
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
364 ngx_http_copy_filter_conf_t *conf = child; |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
43
diff
changeset
|
365 |
6250
0256738454dc
Increased the default number of output buffers.
Valentin Bartenev <vbart@nginx.com>
parents:
6022
diff
changeset
|
366 ngx_conf_merge_bufs_value(conf->bufs, prev->bufs, 2, 32768); |
44
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
43
diff
changeset
|
367 |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
43
diff
changeset
|
368 return NULL; |
0e81ac0bb3e2
nginx-0.0.1-2003-01-09-08:36:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
43
diff
changeset
|
369 } |
334
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
370 |
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
371 |
501 | 372 static ngx_int_t |
681 | 373 ngx_http_copy_filter_init(ngx_conf_t *cf) |
334
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
374 { |
4542
586969d972b9
Local variable "ngx_http_next_filter" renamed to "ngx_http_next_body_filter"
Ruslan Ermilov <ru@nginx.com>
parents:
4415
diff
changeset
|
375 ngx_http_next_body_filter = ngx_http_top_body_filter; |
334
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
376 ngx_http_top_body_filter = ngx_http_copy_filter; |
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
377 |
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
378 return NGX_OK; |
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
379 } |
af451db3fe99
nginx-0.0.3-2004-05-12-09:37:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
380 |