@@ -3189,43 +3189,6 @@ class SSLSocketStream final : public Stream {
31893189};
31903190#endif
31913191
3192- inline bool keep_alive (socket_t sock, time_t keep_alive_timeout_sec) {
3193- const auto timeout = keep_alive_timeout_sec * 1000 ;
3194-
3195- #ifdef CPPHTTPLIB_USE_STEADY_TIMER_FOR_KEEP_ALIVE
3196- const auto start = std::chrono::steady_clock::now ();
3197- #else
3198- time_t elapse = 0 ;
3199- #endif
3200- while (true ) {
3201- auto val = select_read (sock, 0 , 10000 );
3202-
3203- #ifndef CPPHTTPLIB_USE_STEADY_TIMER_FOR_KEEP_ALIVE
3204- elapse += 12 ; // heuristic...
3205- #endif
3206-
3207- if (val < 0 ) {
3208- return false ;
3209- } else if (val == 0 ) {
3210- #ifdef CPPHTTPLIB_USE_STEADY_TIMER_FOR_KEEP_ALIVE
3211- auto current = std::chrono::steady_clock::now ();
3212- auto duration = duration_cast<milliseconds>(current - start);
3213- if (duration.count () > timeout) { return false ; }
3214- #else
3215- if (elapse > timeout) { return false ; }
3216- #endif
3217-
3218- std::this_thread::sleep_for (std::chrono::milliseconds{10 });
3219-
3220- #ifndef CPPHTTPLIB_USE_STEADY_TIMER_FOR_KEEP_ALIVE
3221- elapse += 12 ; // heuristic...
3222- #endif
3223- } else {
3224- return true ;
3225- }
3226- }
3227- }
3228-
32293192template <typename T>
32303193inline bool
32313194process_server_socket_core (const std::atomic<socket_t > &svr_sock, socket_t sock,
@@ -3235,7 +3198,7 @@ process_server_socket_core(const std::atomic<socket_t> &svr_sock, socket_t sock,
32353198 auto ret = false ;
32363199 auto count = keep_alive_max_count;
32373200 while (svr_sock != INVALID_SOCKET && count > 0 &&
3238- keep_alive (sock, keep_alive_timeout_sec) ) {
3201+ select_read (sock, keep_alive_timeout_sec, 0 ) > 0 ) {
32393202 auto close_connection = count == 1 ;
32403203 auto connection_closed = false ;
32413204 ret = callback (close_connection, connection_closed);
@@ -4103,13 +4066,12 @@ inline bool read_headers(Stream &strm, Headers &headers) {
41034066 if (line_reader.end_with_crlf ()) {
41044067 // Blank line indicates end of headers.
41054068 if (line_reader.size () == 2 ) { break ; }
4106- #ifdef CPPHTTPLIB_ALLOW_LF_AS_LINE_TERMINATOR
41074069 } else {
4070+ #ifdef CPPHTTPLIB_ALLOW_LF_AS_LINE_TERMINATOR
41084071 // Blank line indicates end of headers.
41094072 if (line_reader.size () == 1 ) { break ; }
41104073 line_terminator_len = 1 ;
41114074#else
4112- } else {
41134075 continue ; // Skip invalid line.
41144076#endif
41154077 }
@@ -8730,7 +8692,7 @@ inline void ssl_delete(std::mutex &ctx_mutex, SSL *ssl, socket_t sock,
87308692
87318693 auto ret = SSL_shutdown (ssl);
87328694 while (ret == 0 ) {
8733- std::this_thread::sleep_for (std::chrono::microseconds{ 10 });
8695+ std::this_thread::sleep_for (std::chrono::milliseconds{ 100 });
87348696 ret = SSL_shutdown (ssl);
87358697 }
87368698#endif
0 commit comments