summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuslan Ermilov <ru@nginx.com>2015-04-07 00:07:04 +0300
committerRuslan Ermilov <ru@nginx.com>2015-04-07 00:07:04 +0300
commit8c82b7512758eececa878993e03ca7d4a470c00d (patch)
tree584db5fc2b471e691f80246a70fcf33f4d200ff0
parent3f72e18908bd71d20bca6923163ce8b5b194285d (diff)
downloadnginx-8c82b7512758eececa878993e03ca7d4a470c00d.tar.gz
Upstream: abbreviated SSL handshake may interact badly with Nagle.
-rw-r--r--src/http/ngx_http_upstream.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
index 0a04e611c..56091fa98 100644
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -1448,7 +1448,9 @@ static void
ngx_http_upstream_ssl_init_connection(ngx_http_request_t *r,
ngx_http_upstream_t *u, ngx_connection_t *c)
{
- ngx_int_t rc;
+ int tcp_nodelay;
+ ngx_int_t rc;
+ ngx_http_core_loc_conf_t *clcf;
if (ngx_http_upstream_test_connect(c) != NGX_OK) {
ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_ERROR);
@@ -1481,6 +1483,28 @@ ngx_http_upstream_ssl_init_connection(ngx_http_request_t *r,
NGX_HTTP_INTERNAL_SERVER_ERROR);
return;
}
+
+ /* abbreviated SSL handshake may interact badly with Nagle */
+
+ clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
+
+ if (clcf->tcp_nodelay && c->tcp_nodelay == NGX_TCP_NODELAY_UNSET) {
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "tcp_nodelay");
+
+ tcp_nodelay = 1;
+
+ if (setsockopt(c->fd, IPPROTO_TCP, TCP_NODELAY,
+ (const void *) &tcp_nodelay, sizeof(int)) == -1)
+ {
+ ngx_connection_error(c, ngx_socket_errno,
+ "setsockopt(TCP_NODELAY) failed");
+ ngx_http_upstream_finalize_request(r, u,
+ NGX_HTTP_INTERNAL_SERVER_ERROR);
+ return;
+ }
+
+ c->tcp_nodelay = NGX_TCP_NODELAY_SET;
+ }
}
r->connection->log->action = "SSL handshaking to upstream";