Mercurial > hg > nginx
comparison src/http/ngx_http_copy_filter_module.c @ 6951:ce37362a7a70
Copy filter: wake up subrequests after aio operations.
Previously, connection write handler was called, resulting in wake up
of the active subrequest. This change makes it possible to read data
in non-active subrequests as well. For example, this allows SSI to
process instructions in non-active subrequests earlier and start
additional subrequests if needed, reducing overall response time.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 28 Mar 2017 18:15:42 +0300 |
parents | c5f81dcf97a7 |
children | 555533169506 |
comparison
equal
deleted
inserted
replaced
6950:4cb4ffe06785 | 6951:ce37362a7a70 |
---|---|
185 | 185 |
186 static void | 186 static void |
187 ngx_http_copy_aio_event_handler(ngx_event_t *ev) | 187 ngx_http_copy_aio_event_handler(ngx_event_t *ev) |
188 { | 188 { |
189 ngx_event_aio_t *aio; | 189 ngx_event_aio_t *aio; |
190 ngx_connection_t *c; | |
190 ngx_http_request_t *r; | 191 ngx_http_request_t *r; |
191 | 192 |
192 aio = ev->data; | 193 aio = ev->data; |
193 r = aio->data; | 194 r = aio->data; |
195 c = r->connection; | |
196 | |
197 ngx_http_set_log_request(c->log, r); | |
198 | |
199 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
200 "http aio: \"%V?%V\"", &r->uri, &r->args); | |
194 | 201 |
195 r->main->blocked--; | 202 r->main->blocked--; |
196 r->aio = 0; | 203 r->aio = 0; |
197 | 204 |
198 r->connection->write->handler(r->connection->write); | 205 r->write_event_handler(r); |
206 | |
207 ngx_http_run_posted_requests(c); | |
199 } | 208 } |
200 | 209 |
201 | 210 |
202 #if (NGX_HAVE_AIO_SENDFILE) | 211 #if (NGX_HAVE_AIO_SENDFILE) |
203 | 212 |
298 | 307 |
299 | 308 |
300 static void | 309 static void |
301 ngx_http_copy_thread_event_handler(ngx_event_t *ev) | 310 ngx_http_copy_thread_event_handler(ngx_event_t *ev) |
302 { | 311 { |
312 ngx_connection_t *c; | |
303 ngx_http_request_t *r; | 313 ngx_http_request_t *r; |
304 | 314 |
305 r = ev->data; | 315 r = ev->data; |
316 c = r->connection; | |
317 | |
318 ngx_http_set_log_request(c->log, r); | |
319 | |
320 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
321 "http thread: \"%V?%V\"", &r->uri, &r->args); | |
306 | 322 |
307 r->main->blocked--; | 323 r->main->blocked--; |
308 r->aio = 0; | 324 r->aio = 0; |
309 | 325 |
310 r->connection->write->handler(r->connection->write); | 326 if (r->done) { |
327 /* | |
328 * trigger connection event handler if the subrequest was | |
329 * already finalized; this can happen if the handler is used | |
330 * for sendfile() in threads | |
331 */ | |
332 | |
333 c->write->handler(c->write); | |
334 | |
335 } else { | |
336 r->write_event_handler(r); | |
337 ngx_http_run_posted_requests(c); | |
338 } | |
311 } | 339 } |
312 | 340 |
313 #endif | 341 #endif |
314 | 342 |
315 | 343 |