You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2017/03/10 02:03:17 UTC
[trafficserver] branch 7.1.x updated: isuue #1399 add back partial
code of tcp_congestion_control erased by TS-3612
This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch 7.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/7.1.x by this push:
new d78c2d7 isuue #1399 add back partial code of tcp_congestion_control erased by TS-3612
d78c2d7 is described below
commit d78c2d728eb1096a2ae7f1a93707b443bbb982da
Author: Shen Zhang <se...@linkedin.com>
AuthorDate: Wed Feb 8 14:39:01 2017 -0800
isuue #1399 add back partial code of tcp_congestion_control erased by TS-3612
(cherry picked from commit f71b75ef6f32abd168ac646a50be238e4375cadf)
---
iocore/net/I_NetVConnection.h | 2 +-
iocore/net/P_UnixNetVConnection.h | 37 +++++++++++++++++++++++++++----------
proxy/PluginVC.cc | 2 +-
proxy/PluginVC.h | 2 +-
proxy/http/Http1ClientSession.cc | 2 ++
proxy/http/HttpServerSession.cc | 10 ++--------
proxy/http2/Http2ClientSession.cc | 2 ++
7 files changed, 36 insertions(+), 21 deletions(-)
diff --git a/iocore/net/I_NetVConnection.h b/iocore/net/I_NetVConnection.h
index 4b02516..4725580 100644
--- a/iocore/net/I_NetVConnection.h
+++ b/iocore/net/I_NetVConnection.h
@@ -591,7 +591,7 @@ public:
virtual int set_tcp_init_cwnd(int init_cwnd) = 0;
/** Set the TCP congestion control algorithm */
- virtual int set_tcp_congestion_control(const char *name, int len) = 0;
+ virtual int set_tcp_congestion_control(int side) = 0;
/** Set local sock addr struct. */
virtual void set_local_addr() = 0;
diff --git a/iocore/net/P_UnixNetVConnection.h b/iocore/net/P_UnixNetVConnection.h
index edd0fbb..77d0db0 100644
--- a/iocore/net/P_UnixNetVConnection.h
+++ b/iocore/net/P_UnixNetVConnection.h
@@ -98,6 +98,8 @@ struct OOB_callback : public Continuation {
}
};
+enum tcp_congestion_control_t { CLIENT_SIDE, SERVER_SIDE };
+
class UnixNetVConnection : public NetVConnection
{
public:
@@ -314,7 +316,7 @@ public:
virtual void set_local_addr();
virtual void set_remote_addr();
virtual int set_tcp_init_cwnd(int init_cwnd);
- virtual int set_tcp_congestion_control(const char *name, int len);
+ virtual int set_tcp_congestion_control(int side);
virtual void apply_options();
friend void write_to_net_io(NetHandler *, UnixNetVConnection *, EThread *);
@@ -445,18 +447,33 @@ UnixNetVConnection::set_tcp_init_cwnd(int init_cwnd)
}
TS_INLINE int
-UnixNetVConnection::set_tcp_congestion_control(const char *name, int len)
+UnixNetVConnection::set_tcp_congestion_control(int side)
{
#ifdef TCP_CONGESTION
- int rv = 0;
- rv = setsockopt(con.fd, IPPROTO_TCP, TCP_CONGESTION, reinterpret_cast<void *>(const_cast<char *>(name)), len);
- if (rv < 0) {
- Error("Unable to set TCP congestion control on socket %d to \"%.*s\", errno=%d (%s)", con.fd, len, name, errno,
- strerror(errno));
- } else {
- Debug("socket", "Setting TCP congestion control on socket [%d] to \"%.*s\" -> %d", con.fd, len, name, rv);
+ RecString congestion_control;
+ int ret;
+
+ if (side == CLIENT_SIDE)
+ ret = REC_ReadConfigStringAlloc(congestion_control, "proxy.config.net.tcp_congestion_control_in");
+ else
+ ret = REC_ReadConfigStringAlloc(congestion_control, "proxy.config.net.tcp_congestion_control_out");
+
+ if (ret == REC_ERR_OKAY) {
+ int len = strlen(congestion_control);
+ if (len > 0) {
+ int rv = 0;
+ rv = setsockopt(con.fd, IPPROTO_TCP, TCP_CONGESTION, reinterpret_cast<void *>(congestion_control), len);
+ if (rv < 0) {
+ Error("Unable to set TCP congestion control on socket %d to \"%.*s\", errno=%d (%s)", con.fd, len, congestion_control,
+ errno, strerror(errno));
+ } else {
+ Debug("socket", "Setting TCP congestion control on socket [%d] to \"%.*s\" -> %d", con.fd, len, congestion_control, rv);
+ }
+ }
+ ats_free(congestion_control);
+ return 0;
}
- return rv;
+ return -1;
#else
Debug("socket", "Setting TCP congestion control %.*s is not supported on this platform.", len, name);
return -1;
diff --git a/proxy/PluginVC.cc b/proxy/PluginVC.cc
index df1e111..9e7249a 100644
--- a/proxy/PluginVC.cc
+++ b/proxy/PluginVC.cc
@@ -937,7 +937,7 @@ PluginVC::set_tcp_init_cwnd(int /* init_cwnd ATS_UNUSED */)
}
int
-PluginVC::set_tcp_congestion_control(const char *ATS_UNUSED, int ATS_UNUSED)
+PluginVC::set_tcp_congestion_control(int ATS_UNUSED)
{
return -1;
}
diff --git a/proxy/PluginVC.h b/proxy/PluginVC.h
index 9f10f5d..6137848 100644
--- a/proxy/PluginVC.h
+++ b/proxy/PluginVC.h
@@ -104,7 +104,7 @@ public:
virtual void set_local_addr();
virtual void set_remote_addr();
virtual int set_tcp_init_cwnd(int init_cwnd);
- virtual int set_tcp_congestion_control(const char *name, int len);
+ virtual int set_tcp_congestion_control(int);
virtual void apply_options();
diff --git a/proxy/http/Http1ClientSession.cc b/proxy/http/Http1ClientSession.cc
index f1bb6aa..ba7cbf2 100644
--- a/proxy/http/Http1ClientSession.cc
+++ b/proxy/http/Http1ClientSession.cc
@@ -187,6 +187,8 @@ Http1ClientSession::new_connection(NetVConnection *new_vc, MIOBuffer *iobuf, IOB
DebugHttpSsn("[%" PRId64 "] session born, netvc %p", con_id, new_vc);
+ client_vc->set_tcp_congestion_control(CLIENT_SIDE);
+
read_buffer = iobuf ? iobuf : new_MIOBuffer(HTTP_HEADER_BUFFER_SIZE_INDEX);
sm_reader = reader ? reader : read_buffer->alloc_reader();
trans.set_reader(sm_reader);
diff --git a/proxy/http/HttpServerSession.cc b/proxy/http/HttpServerSession.cc
index 3bae75d..e7db34d 100644
--- a/proxy/http/HttpServerSession.cc
+++ b/proxy/http/HttpServerSession.cc
@@ -92,14 +92,8 @@ HttpServerSession::new_connection(NetVConnection *new_vc)
buf_reader = read_buffer->alloc_reader();
Debug("http_ss", "[%" PRId64 "] session born, netvc %p", con_id, new_vc);
state = HSS_INIT;
- RecString congestion_control_out;
- if (REC_ReadConfigStringAlloc(congestion_control_out, "proxy.config.net.tcp_congestion_control_out") == REC_ERR_OKAY) {
- int len = strlen(congestion_control_out);
- if (len > 0) {
- new_vc->set_tcp_congestion_control(congestion_control_out, len);
- }
- ats_free(congestion_control_out);
- }
+
+ new_vc->set_tcp_congestion_control(SERVER_SIDE);
}
VIO *
diff --git a/proxy/http2/Http2ClientSession.cc b/proxy/http2/Http2ClientSession.cc
index 5c4506d..35c3dda 100644
--- a/proxy/http2/Http2ClientSession.cc
+++ b/proxy/http2/Http2ClientSession.cc
@@ -184,6 +184,8 @@ Http2ClientSession::new_connection(NetVConnection *new_vc, MIOBuffer *iobuf, IOB
DebugHttp2Ssn("session born, netvc %p", this->client_vc);
+ this->client_vc->set_tcp_congestion_control(CLIENT_SIDE);
+
this->read_buffer = iobuf ? iobuf : new_MIOBuffer(HTTP2_HEADER_BUFFER_SIZE_INDEX);
this->read_buffer->water_mark = connection_state.server_settings.get(HTTP2_SETTINGS_MAX_FRAME_SIZE);
this->sm_reader = reader ? reader : this->read_buffer->alloc_reader();
--
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].