diff --git a/iocore/net/P_UnixNet.h b/iocore/net/P_UnixNet.h index a92c73c90b9..5299c673f68 100644 --- a/iocore/net/P_UnixNet.h +++ b/iocore/net/P_UnixNet.h @@ -207,7 +207,7 @@ class NetHandler : public Continuation int mainNetEventExt(int event, Event *data); void process_enabled_list(NetHandler *); void manage_keep_alive_queue(); - bool manage_active_queue(); + bool manage_active_queue(bool ignore_queue_size); void add_to_keep_alive_queue(UnixNetVConnection *vc); void remove_from_keep_alive_queue(UnixNetVConnection *vc); bool add_to_active_queue(UnixNetVConnection *vc); diff --git a/iocore/net/UnixNet.cc b/iocore/net/UnixNet.cc index 7eb252a7d63..b616f4a55d9 100644 --- a/iocore/net/UnixNet.cc +++ b/iocore/net/UnixNet.cc @@ -104,7 +104,7 @@ class InactivityCop : public Continuation } // Cleanup the active and keep-alive queues periodically - nh.manage_active_queue(); + nh.manage_active_queue(true); // close any connections over the active timeout nh.manage_keep_alive_queue(); return 0; @@ -569,7 +569,7 @@ NetHandler::mainNetEvent(int event, Event *e) } bool -NetHandler::manage_active_queue() +NetHandler::manage_active_queue(bool ignore_queue_size = false) { const int total_connections_in = active_queue_size + keep_alive_queue_size; Debug("net_queue", "max_connections_per_thread_in: %d max_connections_active_per_thread_in: %d total_connections_in: %d " @@ -577,7 +577,7 @@ NetHandler::manage_active_queue() max_connections_per_thread_in, max_connections_active_per_thread_in, total_connections_in, active_queue_size, keep_alive_queue_size); - if (max_connections_active_per_thread_in > active_queue_size) { + if (ignore_queue_size == false && max_connections_active_per_thread_in > active_queue_size) { return true; } @@ -595,11 +595,15 @@ NetHandler::manage_active_queue() if ((vc->next_inactivity_timeout_at <= now) || (vc->next_activity_timeout_at <= now)) { _close_vc(vc, now, handle_event, closed, total_idle_time, total_idle_count); } - if (max_connections_active_per_thread_in > active_queue_size) { + if (ignore_queue_size == false && max_connections_active_per_thread_in > active_queue_size) { return true; } } + if (max_connections_active_per_thread_in > active_queue_size) { + return true; + } + return false; // failed to make room in the queue, all connections are active }