diff options
author | Maxim Dounin <mdounin@mdounin.ru> | 2017-05-29 16:34:29 +0300 |
---|---|---|
committer | Maxim Dounin <mdounin@mdounin.ru> | 2017-05-29 16:34:29 +0300 |
commit | 2db69fed2c200a4f4017e82bc9239f22dfac846f (patch) | |
tree | 1c867137daf53bc2e73d16d260bbe3752f15a87e /src/stream/ngx_stream_ssl_module.c | |
parent | b66c18d2d50c53b063cd14a2c3e4c8ff8b1b22a5 (diff) | |
download | nginx-2db69fed2c200a4f4017e82bc9239f22dfac846f.tar.gz nginx-2db69fed2c200a4f4017e82bc9239f22dfac846f.zip |
SSL: set TCP_NODELAY on SSL connections before handshake.
With OpenSSL 1.1.0+, the workaround for handshake buffer size as introduced
in a720f0b0e083 (ticket #413) no longer works, as OpenSSL no longer exposes
handshake buffers, see https://github.com/openssl/openssl/commit/2e7dc7cd688.
Moreover, it is no longer possible to adjust handshake buffers at all now.
To avoid additional RTT if handshake uses more than 4k we now set TCP_NODELAY
on SSL connections before handshake. While this still results in sub-optimal
network utilization due to incomplete packets being sent, it seems to be
better than nothing.
Diffstat (limited to 'src/stream/ngx_stream_ssl_module.c')
-rw-r--r-- | src/stream/ngx_stream_ssl_module.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/stream/ngx_stream_ssl_module.c b/src/stream/ngx_stream_ssl_module.c index 593776b1f..937efea57 100644 --- a/src/stream/ngx_stream_ssl_module.c +++ b/src/stream/ngx_stream_ssl_module.c @@ -352,12 +352,19 @@ ngx_stream_ssl_handler(ngx_stream_session_t *s) static ngx_int_t ngx_stream_ssl_init_connection(ngx_ssl_t *ssl, ngx_connection_t *c) { - ngx_int_t rc; - ngx_stream_session_t *s; - ngx_stream_ssl_conf_t *sslcf; + ngx_int_t rc; + ngx_stream_session_t *s; + ngx_stream_ssl_conf_t *sslcf; + ngx_stream_core_srv_conf_t *cscf; s = c->data; + cscf = ngx_stream_get_module_srv_conf(s, ngx_stream_core_module); + + if (cscf->tcp_nodelay && ngx_tcp_nodelay(c) != NGX_OK) { + return NGX_ERROR; + } + if (ngx_ssl_create_connection(ssl, c, 0) == NGX_ERROR) { return NGX_ERROR; } |