Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion iocore/net/P_UnixNet.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ class NetHandler : public Continuation, public EThread::LoopTailHandler
void process_enabled_list();
void process_ready_list();
void manage_keep_alive_queue();
bool manage_active_queue(bool ignore_queue_size);
bool manage_active_queue(NetEvent *ne, bool ignore_queue_size);
void add_to_keep_alive_queue(NetEvent *ne);
void remove_from_keep_alive_queue(NetEvent *ne);
bool add_to_active_queue(NetEvent *ne);
Expand Down
11 changes: 8 additions & 3 deletions iocore/net/UnixNet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class InactivityCop : public Continuation
// Therefore we don't have to check all the NetEvents as much as open_list.

// Cleanup the active and keep-alive queues periodically
nh.manage_active_queue(true); // close any connections over the active timeout
nh.manage_active_queue(nullptr, true); // close any connections over the active timeout
nh.manage_keep_alive_queue();

return 0;
Expand Down Expand Up @@ -565,7 +565,7 @@ NetHandler::signalActivity()
}

bool
NetHandler::manage_active_queue(bool ignore_queue_size = false)
NetHandler::manage_active_queue(NetEvent *enabling_ne, bool ignore_queue_size = false)
{
const int total_connections_in = active_queue_size + keep_alive_queue_size;
Debug("v_net_queue",
Expand Down Expand Up @@ -594,6 +594,11 @@ NetHandler::manage_active_queue(bool ignore_queue_size = false)
int total_idle_count = 0;
for (; ne != nullptr; ne = ne_next) {
ne_next = ne->active_queue_link.next;
// It seems dangerous closing the current ne at this point
// Let the activity_cop deal with it
if (ne == enabling_ne) {
continue;
}
if ((ne->inactivity_timeout_in && ne->next_inactivity_timeout_at <= now) ||
(ne->active_timeout_in && ne->next_activity_timeout_at <= now)) {
_close_ne(ne, now, handle_event, closed, total_idle_time, total_idle_count);
Expand Down Expand Up @@ -741,7 +746,7 @@ NetHandler::add_to_active_queue(NetEvent *ne)
bool active_queue_full = false;

// if active queue is over size then close inactive connections
if (manage_active_queue() == false) {
if (manage_active_queue(ne) == false) {
active_queue_full = true;
}

Expand Down
2 changes: 1 addition & 1 deletion mgmt/RecordsConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ static const RecordElement RecordsConfig[] =
,
{RECT_CONFIG, "proxy.config.net.max_connections_in", RECD_INT, "30000", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL}
,
{RECT_CONFIG, "proxy.config.net.max_connections_active_in", RECD_INT, "10000", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL}
{RECT_CONFIG, "proxy.config.net.max_connections_active_in", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_STR, "^[0-9]+$", RECA_NULL}
,

// ###########################
Expand Down
1 change: 1 addition & 0 deletions proxy/http2/Http2ClientSession.cc
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ Http2ClientSession::main_event_handler(int event, void *edata)
case VC_EVENT_INACTIVITY_TIMEOUT:
case VC_EVENT_ERROR:
case VC_EVENT_EOS:
Http2SsnDebug("Closing event %d", event);
this->set_dying_event(event);
this->do_io_close();
if (_vc != nullptr) {
Expand Down
29 changes: 17 additions & 12 deletions tests/gold_tests/h2/h2active_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,25 @@
import time


def makerequest(port):
def makerequest(port, active_timeout):
hyper.tls._context = hyper.tls.init_context()
hyper.tls._context.check_hostname = False
hyper.tls._context.verify_mode = hyper.compat.ssl.CERT_NONE

conn = HTTPConnection('localhost:{0}'.format(port), secure=True)

active_timeout = 3
request_interval = 0.1
loop_cnt = int((active_timeout + 2) / request_interval)
for _ in range(loop_cnt):
try:
conn.request('GET', '/')
time.sleep(request_interval)
except:
print('CONNECTION_TIMEOUT')
return
try:
# delay after sending the first request
# so the H2 session active timeout triggers
# Then the next request should fail
req_id = conn.request('GET', '/')
time.sleep(active_timeout)
response = conn.get_response(req_id)
req_id = conn.request('GET', '/')
response = conn.get_response(req_id)
except:
print('CONNECTION_TIMEOUT')
return

print('NO_TIMEOUT')

Expand All @@ -48,8 +50,11 @@ def main():
parser.add_argument("--port", "-p",
type=int,
help="Port to use")
parser.add_argument("--delay", "-d",
type=int,
help="Time to delay in seconds")
args = parser.parse_args()
makerequest(args.port)
makerequest(args.port, args.delay)


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion tests/gold_tests/h2/http2.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@

# Test Case 5: h2_active_timeout
tr = Test.AddTestRun()
tr.Processes.Default.Command = 'python3 h2active_timeout.py -p {0}'.format(ts.Variables.ssl_port)
tr.Processes.Default.Command = 'python3 h2active_timeout.py -p {0} -d 4'.format(ts.Variables.ssl_port)
tr.Processes.Default.ReturnCode = 0
tr.Processes.Default.Streams.All = "gold/active_timeout.gold"
tr.StillRunningAfter = server
Expand Down