Mercurial > hg > nginx
comparison src/http/ngx_http_upstream.c @ 6068:643f2ce02f1c
Upstream: abbreviated SSL handshake may interact badly with Nagle.
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Tue, 07 Apr 2015 00:07:04 +0300 |
parents | a08fad30aeac |
children | 4dc8e7b62216 50169ef2f3fe |
comparison
equal
deleted
inserted
replaced
6067:231a5bbd9e9c | 6068:643f2ce02f1c |
---|---|
1446 | 1446 |
1447 static void | 1447 static void |
1448 ngx_http_upstream_ssl_init_connection(ngx_http_request_t *r, | 1448 ngx_http_upstream_ssl_init_connection(ngx_http_request_t *r, |
1449 ngx_http_upstream_t *u, ngx_connection_t *c) | 1449 ngx_http_upstream_t *u, ngx_connection_t *c) |
1450 { | 1450 { |
1451 ngx_int_t rc; | 1451 int tcp_nodelay; |
1452 ngx_int_t rc; | |
1453 ngx_http_core_loc_conf_t *clcf; | |
1452 | 1454 |
1453 if (ngx_http_upstream_test_connect(c) != NGX_OK) { | 1455 if (ngx_http_upstream_test_connect(c) != NGX_OK) { |
1454 ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_ERROR); | 1456 ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_ERROR); |
1455 return; | 1457 return; |
1456 } | 1458 } |
1478 if (u->conf->ssl_session_reuse) { | 1480 if (u->conf->ssl_session_reuse) { |
1479 if (u->peer.set_session(&u->peer, u->peer.data) != NGX_OK) { | 1481 if (u->peer.set_session(&u->peer, u->peer.data) != NGX_OK) { |
1480 ngx_http_upstream_finalize_request(r, u, | 1482 ngx_http_upstream_finalize_request(r, u, |
1481 NGX_HTTP_INTERNAL_SERVER_ERROR); | 1483 NGX_HTTP_INTERNAL_SERVER_ERROR); |
1482 return; | 1484 return; |
1485 } | |
1486 | |
1487 /* abbreviated SSL handshake may interact badly with Nagle */ | |
1488 | |
1489 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | |
1490 | |
1491 if (clcf->tcp_nodelay && c->tcp_nodelay == NGX_TCP_NODELAY_UNSET) { | |
1492 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "tcp_nodelay"); | |
1493 | |
1494 tcp_nodelay = 1; | |
1495 | |
1496 if (setsockopt(c->fd, IPPROTO_TCP, TCP_NODELAY, | |
1497 (const void *) &tcp_nodelay, sizeof(int)) == -1) | |
1498 { | |
1499 ngx_connection_error(c, ngx_socket_errno, | |
1500 "setsockopt(TCP_NODELAY) failed"); | |
1501 ngx_http_upstream_finalize_request(r, u, | |
1502 NGX_HTTP_INTERNAL_SERVER_ERROR); | |
1503 return; | |
1504 } | |
1505 | |
1506 c->tcp_nodelay = NGX_TCP_NODELAY_SET; | |
1483 } | 1507 } |
1484 } | 1508 } |
1485 | 1509 |
1486 r->connection->log->action = "SSL handshaking to upstream"; | 1510 r->connection->log->action = "SSL handshaking to upstream"; |
1487 | 1511 |