Commit e65047ce authored by levlam's avatar levlam

Disable TCP keep-alive and lingering.

parent e1acd116
......@@ -2092,7 +2092,7 @@ void mtfront_pre_loop (void) {
}
if (!workers) {
for (i = 0; i < http_ports_num; i++) {
init_listening_tcpv6_connection (http_sfd[i], &ct_tcp_rpc_ext_server_mtfront, &ext_rpc_methods, enable_ipv6 | SM_LOWPRIO | SM_NOQACK | (max_special_connections ? SM_SPECIAL : 0));
init_listening_tcpv6_connection (http_sfd[i], &ct_tcp_rpc_ext_server_mtfront, &ext_rpc_methods, enable_ipv6 | SM_LOWPRIO | (domain_count == 0 ? SM_NOQACK : 0) | (max_special_connections ? SM_SPECIAL : 0));
// assert (setsockopt (http_sfd[i], IPPROTO_TCP, TCP_MAXSEG, (int[]){1410}, sizeof (int)) >= 0);
// assert (setsockopt (http_sfd[i], IPPROTO_TCP, TCP_NODELAY, (int[]){1}, sizeof (int)) >= 0);
if (window_clamp) {
......
......@@ -557,8 +557,9 @@ struct in_addr settings_addr;
int server_socket (int port, struct in_addr in_addr, int backlog, int mode) {
int socket_fd;
struct linger ling = {0, 0};
// struct linger ling = {0, 0};
int flags = 1;
int enable_tcp_keep_alive = 0;
if ((socket_fd = new_socket (mode, 1)) == -1) {
return -1;
......@@ -574,16 +575,20 @@ int server_socket (int port, struct in_addr in_addr, int backlog, int mode) {
maximize_sndbuf (socket_fd, 0);
maximize_rcvbuf (socket_fd, 0);
}
assert (setsockopt (socket_fd, SOL_SOCKET, SO_KEEPALIVE, &flags, sizeof (flags)) >= 0);
assert (flags == 1);
setsockopt (socket_fd, SOL_SOCKET, SO_LINGER, &ling, sizeof (ling));
// setsockopt (socket_fd, SOL_SOCKET, SO_LINGER, &ling, sizeof (ling));
setsockopt (socket_fd, IPPROTO_TCP, TCP_NODELAY, &flags, sizeof (flags));
int x = 40;
assert (setsockopt (socket_fd, IPPROTO_TCP, TCP_KEEPIDLE, &x, sizeof (x)) >= 0);
assert (setsockopt (socket_fd, IPPROTO_TCP, TCP_KEEPINTVL, &x, sizeof (x)) >= 0);
x = 5;
assert (setsockopt (socket_fd, IPPROTO_TCP, TCP_KEEPCNT, &x, sizeof (x)) >= 0);
if (enable_tcp_keep_alive) {
assert (flags == 1);
assert (setsockopt (socket_fd, SOL_SOCKET, SO_KEEPALIVE, &flags, sizeof (flags)) >= 0);
int x = 40;
assert (setsockopt (socket_fd, IPPROTO_TCP, TCP_KEEPIDLE, &x, sizeof (x)) >= 0);
assert (setsockopt (socket_fd, IPPROTO_TCP, TCP_KEEPINTVL, &x, sizeof (x)) >= 0);
x = 5;
assert (setsockopt (socket_fd, IPPROTO_TCP, TCP_KEEPCNT, &x, sizeof (x)) >= 0);
}
}
if (mode & SM_REUSE) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment