aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorValentin Bartenev <vbart@nginx.com>2013-03-15 19:49:54 +0000
committerValentin Bartenev <vbart@nginx.com>2013-03-15 19:49:54 +0000
commit23e692b58df18e47f5c8080ce8812ed574d7c4a2 (patch)
treef57168e9cbf372bc3a4ce239b96abbb4cf3b91b7 /src
parent3f70ddcfc69cc16f1d1b9b8bb450a0e21135c30a (diff)
downloadnginx-23e692b58df18e47f5c8080ce8812ed574d7c4a2.tar.gz
nginx-23e692b58df18e47f5c8080ce8812ed574d7c4a2.zip
Allow to reuse connections that wait their first request.
This should improve behavior under deficiency of connections. Since SSL handshake usually takes significant amount of time, we exclude connections from reusable queue during this period to avoid premature flush of them.
Diffstat (limited to 'src')
-rw-r--r--src/http/ngx_http_request.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index 87df26237..1cab9ee2b 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -355,6 +355,7 @@ ngx_http_init_connection(ngx_connection_t *c)
}
ngx_add_timer(rev, c->listening->post_accept_timeout);
+ ngx_reusable_connection(c, 1);
if (ngx_handle_read_event(rev, 0) != NGX_OK) {
ngx_http_close_connection(c);
@@ -383,6 +384,11 @@ ngx_http_wait_request_handler(ngx_event_t *rev)
return;
}
+ if (c->close) {
+ ngx_http_close_connection(c);
+ return;
+ }
+
hc = c->data;
cscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_core_module);
@@ -432,6 +438,7 @@ ngx_http_wait_request_handler(ngx_event_t *rev)
if (!rev->timer_set) {
ngx_add_timer(rev, c->listening->post_accept_timeout);
+ ngx_reusable_connection(c, 1);
}
if (ngx_handle_read_event(rev, 0) != NGX_OK) {
@@ -466,6 +473,8 @@ ngx_http_wait_request_handler(ngx_event_t *rev)
c->log->action = "reading client request line";
+ ngx_reusable_connection(c, 0);
+
c->data = ngx_http_create_request(c);
if (c->data == NULL) {
ngx_http_close_connection(c);
@@ -611,6 +620,11 @@ ngx_http_ssl_handshake(ngx_event_t *rev)
return;
}
+ if (c->close) {
+ ngx_http_close_connection(c);
+ return;
+ }
+
n = recv(c->fd, (char *) buf, 1, MSG_PEEK);
err = ngx_socket_errno;
@@ -631,6 +645,7 @@ ngx_http_ssl_handshake(ngx_event_t *rev)
if (!rev->timer_set) {
ngx_add_timer(rev, c->listening->post_accept_timeout);
+ ngx_reusable_connection(c, 1);
}
if (ngx_handle_read_event(rev, 0) != NGX_OK) {
@@ -670,6 +685,8 @@ ngx_http_ssl_handshake(ngx_event_t *rev)
ngx_add_timer(rev, c->listening->post_accept_timeout);
}
+ ngx_reusable_connection(c, 0);
+
c->ssl->handler = ngx_http_ssl_handshake_handler;
return;
}
@@ -714,6 +731,8 @@ ngx_http_ssl_handshake_handler(ngx_connection_t *c)
c->read->handler = ngx_http_wait_request_handler;
/* STUB: epoll edge */ c->write->handler = ngx_http_empty_handler;
+ ngx_reusable_connection(c, 1);
+
ngx_http_wait_request_handler(c->read);
return;