Mercurial > hg > nginx
comparison src/event/ngx_event_connect.c @ 7371:8b68d50090e4
Upstream: proxy_socket_keepalive and friends.
The directives enable the use of the SO_KEEPALIVE option on
upstream connections. By default, the value is left unchanged.
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Wed, 03 Oct 2018 14:08:51 +0300 |
parents | 91ea68dd1501 |
children | fdc3d40979b0 |
comparison
equal
deleted
inserted
replaced
7370:aa1c9f846567 | 7371:8b68d50090e4 |
---|---|
18 | 18 |
19 | 19 |
20 ngx_int_t | 20 ngx_int_t |
21 ngx_event_connect_peer(ngx_peer_connection_t *pc) | 21 ngx_event_connect_peer(ngx_peer_connection_t *pc) |
22 { | 22 { |
23 int rc, type; | 23 int rc, type, value; |
24 #if (NGX_HAVE_IP_BIND_ADDRESS_NO_PORT || NGX_LINUX) | 24 #if (NGX_HAVE_IP_BIND_ADDRESS_NO_PORT || NGX_LINUX) |
25 in_port_t port; | 25 in_port_t port; |
26 #endif | 26 #endif |
27 ngx_int_t event; | 27 ngx_int_t event; |
28 ngx_err_t err; | 28 ngx_err_t err; |
68 (const void *) &pc->rcvbuf, sizeof(int)) == -1) | 68 (const void *) &pc->rcvbuf, sizeof(int)) == -1) |
69 { | 69 { |
70 ngx_log_error(NGX_LOG_ALERT, pc->log, ngx_socket_errno, | 70 ngx_log_error(NGX_LOG_ALERT, pc->log, ngx_socket_errno, |
71 "setsockopt(SO_RCVBUF) failed"); | 71 "setsockopt(SO_RCVBUF) failed"); |
72 goto failed; | 72 goto failed; |
73 } | |
74 } | |
75 | |
76 if (pc->so_keepalive) { | |
77 value = 1; | |
78 | |
79 if (setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, | |
80 (const void *) &value, sizeof(int)) | |
81 == -1) | |
82 { | |
83 ngx_log_error(NGX_LOG_ALERT, pc->log, ngx_socket_errno, | |
84 "setsockopt(SO_KEEPALIVE) failed, ignored"); | |
73 } | 85 } |
74 } | 86 } |
75 | 87 |
76 if (ngx_nonblocking(s) == -1) { | 88 if (ngx_nonblocking(s) == -1) { |
77 ngx_log_error(NGX_LOG_ALERT, pc->log, ngx_socket_errno, | 89 ngx_log_error(NGX_LOG_ALERT, pc->log, ngx_socket_errno, |