| 2587 | |
| 2588 | template <typename T> |
| 2589 | inline bool |
| 2590 | process_server_socket_core(const std::atomic<socket_t> &svr_sock, socket_t sock, |
| 2591 | size_t keep_alive_max_count, |
| 2592 | time_t keep_alive_timeout_sec, T callback) { |
| 2593 | assert(keep_alive_max_count > 0); |
| 2594 | auto ret = false; |
| 2595 | auto count = keep_alive_max_count; |
| 2596 | while (svr_sock != INVALID_SOCKET && count > 0 && |
| 2597 | keep_alive(sock, keep_alive_timeout_sec)) { |
| 2598 | auto close_connection = count == 1; |
| 2599 | auto connection_closed = false; |
| 2600 | ret = callback(close_connection, connection_closed); |
| 2601 | if (!ret || connection_closed) { break; } |
| 2602 | count--; |
| 2603 | } |
| 2604 | return ret; |
| 2605 | } |
| 2606 | |
| 2607 | template <typename T> |
| 2608 | inline bool |
no test coverage detected