| 2493 | |
| 2494 | template <typename T> |
| 2495 | inline bool |
| 2496 | process_server_socket_core(const std::atomic<socket_t>& svr_sock, socket_t sock, |
| 2497 | size_t keep_alive_max_count, |
| 2498 | time_t keep_alive_timeout_sec, T callback) { |
| 2499 | assert(keep_alive_max_count > 0); |
| 2500 | auto ret = false; |
| 2501 | auto count = keep_alive_max_count; |
| 2502 | while (svr_sock != INVALID_SOCKET && count > 0 && |
| 2503 | keep_alive(sock, keep_alive_timeout_sec)) { |
| 2504 | auto close_connection = count == 1; |
| 2505 | auto connection_closed = false; |
| 2506 | ret = callback(close_connection, connection_closed); |
| 2507 | if (!ret || connection_closed) { break; } |
| 2508 | count--; |
| 2509 | } |
| 2510 | return ret; |
| 2511 | } |
| 2512 | |
| 2513 | template <typename T> |
| 2514 | inline bool |
no test coverage detected