| 2463 | |
| 2464 | template <typename T> |
| 2465 | inline bool |
| 2466 | process_server_socket_core(const std::atomic<socket_t> &svr_sock, socket_t sock, |
| 2467 | size_t keep_alive_max_count, |
| 2468 | time_t keep_alive_timeout_sec, T callback) { |
| 2469 | assert(keep_alive_max_count > 0); |
| 2470 | auto ret = false; |
| 2471 | auto count = keep_alive_max_count; |
| 2472 | while (svr_sock != INVALID_SOCKET && count > 0 && |
| 2473 | keep_alive(sock, keep_alive_timeout_sec)) { |
| 2474 | auto close_connection = count == 1; |
| 2475 | auto connection_closed = false; |
| 2476 | ret = callback(close_connection, connection_closed); |
| 2477 | if (!ret || connection_closed) { break; } |
| 2478 | count--; |
| 2479 | } |
| 2480 | return ret; |
| 2481 | } |
| 2482 | |
| 2483 | template <typename T> |
| 2484 | inline bool |
no test coverage detected