This is an automated email from the ASF dual-hosted git repository.
scw00 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 00c11d0 Move setsockopt from UnixNetProcessor to
Server::setup_fd_for_listen
00c11d0 is described below
commit 00c11d0666ab3a03144d2c4cfab1772745353a64
Author: scw00 <[email protected]>
AuthorDate: Thu May 2 06:49:58 2019 +0000
Move setsockopt from UnixNetProcessor to Server::setup_fd_for_listen
---
iocore/net/Connection.cc | 19 ++++++++++++++++++-
iocore/net/I_NetProcessor.h | 8 ++++++++
iocore/net/UnixNetProcessor.cc | 26 --------------------------
proxy/http/HttpProxyServerMain.cc | 4 ++++
4 files changed, 30 insertions(+), 27 deletions(-)
diff --git a/iocore/net/Connection.cc b/iocore/net/Connection.cc
index a8370a6..0b6d14d 100644
--- a/iocore/net/Connection.cc
+++ b/iocore/net/Connection.cc
@@ -140,7 +140,8 @@ Server::setup_fd_for_listen(bool non_blocking, const
NetProcessor::AcceptOptions
ink_assert(fd != NO_FD);
- if (http_accept_filter) {
+ if (opt.etype == ET_NET && opt.defer_accept > 0) {
+ http_accept_filter = true;
add_http_filter(fd);
}
@@ -253,6 +254,22 @@ Server::setup_fd_for_listen(bool non_blocking, const
NetProcessor::AcceptOptions
}
#endif
+#ifdef TCP_DEFER_ACCEPT
+ // set tcp defer accept timeout if it is configured, this will not trigger
an accept until there is
+ // data on the socket ready to be read
+ if (opt.defer_accept > 0 && (res = setsockopt(fd, IPPROTO_TCP,
TCP_DEFER_ACCEPT, &opt.defer_accept, sizeof(int))) < 0) {
+ // FIXME: should we go to the error
+ // goto error;
+ Error("[Server::listen] Defer accept is configured but set failed: %d",
errno);
+ }
+#endif
+
+#ifdef TCP_INIT_CWND
+ if (opt.init_cwnd > 0 && (res = setsockopt(fd, IPPROTO_TCP, TCP_INIT_CWND,
&opt.init_cwnd, sizeof(int))) < 0) {
+ Error("[Server::listen] Cannot set initial congestion window to %d error:
%d", tcp_init_cwnd, errno);
+ }
+#endif
+
if (non_blocking) {
if ((res = safe_nonblocking(fd)) < 0) {
goto Lerror;
diff --git a/iocore/net/I_NetProcessor.h b/iocore/net/I_NetProcessor.h
index 5f94cd6..04dedf3 100644
--- a/iocore/net/I_NetProcessor.h
+++ b/iocore/net/I_NetProcessor.h
@@ -80,6 +80,14 @@ public:
/// Socket transmit buffer size.
/// 0 => OS default.
int send_bufsize;
+ /// defer accpet for @c sockopt.
+ /// 0 => OS default.
+ int defer_accept;
+#ifdef TCP_INIT_CWND
+ /// tcp init cwnd for @c sockopt
+ /// OS default
+ int init_cwnd;
+#endif
/// Socket options for @c sockopt.
/// 0 => do not set options.
uint32_t sockopt_flags;
diff --git a/iocore/net/UnixNetProcessor.cc b/iocore/net/UnixNetProcessor.cc
index 488f6db..c55b618 100644
--- a/iocore/net/UnixNetProcessor.cc
+++ b/iocore/net/UnixNetProcessor.cc
@@ -129,13 +129,6 @@ UnixNetProcessor::accept_internal(Continuation *cont, int
fd, AcceptOptions cons
Debug("http_tproxy", "Marked accept server %p on port %d for proxy
protocol", na, opt.local_port);
}
- int should_filter_int = 0;
- na->server.http_accept_filter = false;
- REC_ReadConfigInteger(should_filter_int, "proxy.config.net.defer_accept");
- if (should_filter_int > 0 && opt.etype == ET_NET) {
- na->server.http_accept_filter = true;
- }
-
SessionAccept *sa = dynamic_cast<SessionAccept *>(cont);
na->proxyPort = sa ? sa->proxyPort : nullptr;
na->snpa = dynamic_cast<SSLNextProtocolAccept *>(cont);
@@ -173,25 +166,6 @@ UnixNetProcessor::accept_internal(Continuation *cont, int
fd, AcceptOptions cons
naVec.push_back(na);
}
-#ifdef TCP_DEFER_ACCEPT
- // set tcp defer accept timeout if it is configured, this will not trigger
an accept until there is
- // data on the socket ready to be read
- if (should_filter_int > 0) {
- setsockopt(na->server.fd, IPPROTO_TCP, TCP_DEFER_ACCEPT,
&should_filter_int, sizeof(int));
- }
-#endif
-
-#ifdef TCP_INIT_CWND
- int tcp_init_cwnd = 0;
- REC_ReadConfigInteger(tcp_init_cwnd,
"proxy.config.http.server_tcp_init_cwnd");
- if (tcp_init_cwnd > 0) {
- Debug("net", "Setting initial congestion window to %d", tcp_init_cwnd);
- if (setsockopt(na->server.fd, IPPROTO_TCP, TCP_INIT_CWND, &tcp_init_cwnd,
sizeof(int)) != 0) {
- Error("Cannot set initial congestion window to %d", tcp_init_cwnd);
- }
- }
-#endif
-
return na->action_.get();
}
diff --git a/proxy/http/HttpProxyServerMain.cc
b/proxy/http/HttpProxyServerMain.cc
index 11abf90..631d542 100644
--- a/proxy/http/HttpProxyServerMain.cc
+++ b/proxy/http/HttpProxyServerMain.cc
@@ -151,6 +151,10 @@ make_net_accept_options(const HttpProxyPort *port,
unsigned nthreads)
REC_ReadConfigInteger(net.recv_bufsize,
"proxy.config.net.sock_recv_buffer_size_in");
REC_ReadConfigInteger(net.send_bufsize,
"proxy.config.net.sock_send_buffer_size_in");
REC_ReadConfigInteger(net.sockopt_flags,
"proxy.config.net.sock_option_flag_in");
+ REC_ReadConfigInteger(net.defer_accept, "proxy.config.net.defer_accept");
+#ifdef TCP_INIT_CWND
+ REC_ReadConfigInteger(net.init_cwnd,
"proxy.config.http.server_tcp_init_cwnd");
+#endif
#ifdef TCP_FASTOPEN
REC_ReadConfigInteger(net.tfo_queue_length,
"proxy.config.net.sock_option_tfo_queue_size_in");