| 2886 | |
| 2887 | template <typename T> |
| 2888 | inline bool |
| 2889 | process_server_socket_core(const std::atomic<socket_t> &svr_sock, socket_t sock, |
| 2890 | size_t keep_alive_max_count, |
| 2891 | time_t keep_alive_timeout_sec, T callback) { |
| 2892 | assert(keep_alive_max_count > 0); |
| 2893 | auto ret = false; |
| 2894 | auto count = keep_alive_max_count; |
| 2895 | while (svr_sock != INVALID_SOCKET && count > 0 && |
| 2896 | keep_alive(sock, keep_alive_timeout_sec)) { |
| 2897 | auto close_connection = count == 1; |
| 2898 | auto connection_closed = false; |
| 2899 | ret = callback(close_connection, connection_closed); |
| 2900 | if (!ret || connection_closed) { break; } |
| 2901 | count--; |
| 2902 | } |
| 2903 | return ret; |
| 2904 | } |
| 2905 | |
| 2906 | template <typename T> |
| 2907 | inline bool |
no test coverage detected