You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by vm...@apache.org on 2019/04/26 12:41:50 UTC
[trafficserver] branch 8.0.x updated: Throttling results in tight
loop if there are no new connections
This is an automated email from the ASF dual-hosted git repository.
vmamidi pushed a commit to branch 8.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/8.0.x by this push:
new 1aa2150 Throttling results in tight loop if there are no new connections
1aa2150 is described below
commit 1aa215015d8bb13f3a106a06207184a376997f8b
Author: Vijay Mamidi <vi...@yahoo.com>
AuthorDate: Tue Apr 23 10:12:17 2019 +0800
Throttling results in tight loop if there are no new connections
(cherry picked from commit 1e9e4ed3be52dc8ef2433baba6816df4eb032055)
Conflicts:
iocore/net/UnixNetAccept.cc
---
iocore/net/UnixNetAccept.cc | 47 +++++++++------------------------------------
1 file changed, 9 insertions(+), 38 deletions(-)
diff --git a/iocore/net/UnixNetAccept.cc b/iocore/net/UnixNetAccept.cc
index e494f5a..b5d80a7 100644
--- a/iocore/net/UnixNetAccept.cc
+++ b/iocore/net/UnixNetAccept.cc
@@ -41,29 +41,6 @@ safe_delay(int msec)
socketManager.poll(nullptr, 0, msec);
}
-static int
-drain_throttled_accepts(NetAccept *na)
-{
- struct pollfd afd;
- Connection con[THROTTLE_AT_ONCE];
-
- afd.fd = na->server.fd;
- afd.events = POLLIN;
-
- // Try to close at most THROTTLE_AT_ONCE accept requests
- // Stop if there is nothing waiting
- int n = 0;
- for (; n < THROTTLE_AT_ONCE && socketManager.poll(&afd, 1, 0) > 0; n++) {
- int res = 0;
- if ((res = na->server.accept(&con[n])) < 0) {
- return res;
- }
- con[n].close();
- }
- // Return the number of accept cases we closed
- return n;
-}
-
//
// General case network connection accept code
//
@@ -279,21 +256,7 @@ NetAccept::do_blocking_accept(EThread *t)
// do-while for accepting all the connections
// added by YTS Team, yamsat
do {
- ink_hrtime now = Thread::get_hrtime();
-
- // Throttle accepts
- while (!opt.backdoor && check_net_throttle(ACCEPT)) {
- check_throttle_warning(ACCEPT);
- int num_throttled = drain_throttled_accepts(this);
- if (num_throttled < 0) {
- goto Lerror;
- }
- NET_SUM_DYN_STAT(net_connections_throttled_in_stat, num_throttled);
- now = Thread::get_hrtime();
- }
-
if ((res = server.accept(&con)) < 0) {
- Lerror:
int seriousness = accept_error_seriousness(res);
if (seriousness >= 0) { // not so bad
if (!seriousness) { // bad enough to warn about
@@ -309,6 +272,14 @@ NetAccept::do_blocking_accept(EThread *t)
}
return -1;
}
+ // check for throttle
+ if (!opt.backdoor && check_net_throttle(ACCEPT)) {
+ check_throttle_warning(ACCEPT);
+ // close the connection as we are in throttle state
+ con.close();
+ NET_SUM_DYN_STAT(net_connections_throttled_in_stat, 1);
+ continue;
+ }
if (shutdown_event_system == true) {
return -1;
@@ -324,7 +295,7 @@ NetAccept::do_blocking_accept(EThread *t)
NET_SUM_GLOBAL_DYN_STAT(net_tcp_accept_stat, 1);
vc->id = net_next_connection_number();
vc->con.move(con);
- vc->submit_time = now;
+ vc->submit_time = Thread::get_hrtime();
vc->mutex = new_ProxyMutex();
vc->action_ = *action_;
vc->set_is_transparent(opt.f_inbound_transparent);