| 397 | } |
| 398 | |
| 399 | bool |
| 400 | NetHandler::manage_active_queue(NetEvent *enabling_ne, bool ignore_queue_size = false) |
| 401 | { |
| 402 | const int total_connections_in = active_queue_size + keep_alive_queue_size; |
| 403 | Dbg(dbg_ctl_v_net_queue, |
| 404 | "max_connections_per_thread_in: %d max_requests_per_thread_in: %d total_connections_in: %d " |
| 405 | "active_queue_size: %d keep_alive_queue_size: %d", |
| 406 | max_connections_per_thread_in, max_requests_per_thread_in, total_connections_in, active_queue_size, keep_alive_queue_size); |
| 407 | |
| 408 | if (!max_requests_per_thread_in) { |
| 409 | // active queue has no max |
| 410 | return true; |
| 411 | } |
| 412 | |
| 413 | if (ignore_queue_size == false && max_requests_per_thread_in > active_queue_size) { |
| 414 | return true; |
| 415 | } |
| 416 | |
| 417 | ink_hrtime now = ink_get_hrtime(); |
| 418 | |
| 419 | // loop over the non-active connections and try to close them |
| 420 | NetEvent *ne = active_queue.head; |
| 421 | NetEvent *ne_next = nullptr; |
| 422 | int closed = 0; |
| 423 | int handle_event = 0; |
| 424 | int total_idle_time = 0; |
| 425 | int total_idle_count = 0; |
| 426 | for (; ne != nullptr; ne = ne_next) { |
| 427 | ne_next = ne->active_queue_link.next; |
| 428 | // It seems dangerous closing the current ne at this point |
| 429 | // Let the activity_cop deal with it |
| 430 | if (ne == enabling_ne) { |
| 431 | continue; |
| 432 | } |
| 433 | if ((ne->next_inactivity_timeout_at && ne->next_inactivity_timeout_at <= now) || |
| 434 | (ne->next_activity_timeout_at && ne->next_activity_timeout_at <= now)) { |
| 435 | _close_ne(ne, now, handle_event, closed, total_idle_time, total_idle_count); |
| 436 | } |
| 437 | if (ignore_queue_size == false && max_requests_per_thread_in > active_queue_size) { |
| 438 | return true; |
| 439 | } |
| 440 | } |
| 441 | |
| 442 | if (max_requests_per_thread_in > active_queue_size) { |
| 443 | return true; |
| 444 | } |
| 445 | |
| 446 | return false; // failed to make room in the queue, all connections are active |
| 447 | } |
| 448 | |
| 449 | void |
| 450 | NetHandler::configure_per_thread_values() |
no test coverage detected