Welcome! Log In Create A New Profile

Advanced

[nginx] Copy filter: wake up subrequests after aio operations.

Maxim Dounin
March 28, 2017 12:26PM
details: http://hg.nginx.org/nginx/rev/ce37362a7a70
branches:
changeset: 6951:ce37362a7a70
user: Maxim Dounin <mdounin@mdounin.ru>
date: Tue Mar 28 18:15:42 2017 +0300
description:
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.

diffstat:

src/http/ngx_http_copy_filter_module.c | 32 ++++++++++++++++++++++++++++++--
1 files changed, 30 insertions(+), 2 deletions(-)

diffs (64 lines):

diff --git a/src/http/ngx_http_copy_filter_module.c b/src/http/ngx_http_copy_filter_module.c
--- a/src/http/ngx_http_copy_filter_module.c
+++ b/src/http/ngx_http_copy_filter_module.c
@@ -187,15 +187,24 @@ static void
ngx_http_copy_aio_event_handler(ngx_event_t *ev)
{
ngx_event_aio_t *aio;
+ ngx_connection_t *c;
ngx_http_request_t *r;

aio = ev->data;
r = aio->data;
+ c = r->connection;
+
+ ngx_http_set_log_request(c->log, r);
+
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
+ "http aio: \"%V?%V\"", &r->uri, &r->args);

r->main->blocked--;
r->aio = 0;

- r->connection->write->handler(r->connection->write);
+ r->write_event_handler(r);
+
+ ngx_http_run_posted_requests(c);
}


@@ -300,14 +309,33 @@ ngx_http_copy_thread_handler(ngx_thread_
static void
ngx_http_copy_thread_event_handler(ngx_event_t *ev)
{
+ ngx_connection_t *c;
ngx_http_request_t *r;

r = ev->data;
+ c = r->connection;
+
+ ngx_http_set_log_request(c->log, r);
+
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
+ "http thread: \"%V?%V\"", &r->uri, &r->args);

r->main->blocked--;
r->aio = 0;

- r->connection->write->handler(r->connection->write);
+ if (r->done) {
+ /*
+ * trigger connection event handler if the subrequest was
+ * already finalized; this can happen if the handler is used
+ * for sendfile() in threads
+ */
+
+ c->write->handler(c->write);
+
+ } else {
+ r->write_event_handler(r);
+ ngx_http_run_posted_requests(c);
+ }
}

#endif
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Copy filter: wake up subrequests after aio operations.

Maxim Dounin 558 March 28, 2017 12:26PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 116
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready