@@ -3189,43 +3189,6 @@ class SSLSocketStream final : public Stream {
3189
3189
};
3190
3190
#endif
3191
3191
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
-
3229
3192
template <typename T>
3230
3193
inline bool
3231
3194
process_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,
3235
3198
auto ret = false ;
3236
3199
auto count = keep_alive_max_count;
3237
3200
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 ) {
3239
3202
auto close_connection = count == 1 ;
3240
3203
auto connection_closed = false ;
3241
3204
ret = callback (close_connection, connection_closed);
@@ -4103,13 +4066,12 @@ inline bool read_headers(Stream &strm, Headers &headers) {
4103
4066
if (line_reader.end_with_crlf ()) {
4104
4067
// Blank line indicates end of headers.
4105
4068
if (line_reader.size () == 2 ) { break ; }
4106
- #ifdef CPPHTTPLIB_ALLOW_LF_AS_LINE_TERMINATOR
4107
4069
} else {
4070
+ #ifdef CPPHTTPLIB_ALLOW_LF_AS_LINE_TERMINATOR
4108
4071
// Blank line indicates end of headers.
4109
4072
if (line_reader.size () == 1 ) { break ; }
4110
4073
line_terminator_len = 1 ;
4111
4074
#else
4112
- } else {
4113
4075
continue ; // Skip invalid line.
4114
4076
#endif
4115
4077
}
@@ -8730,7 +8692,7 @@ inline void ssl_delete(std::mutex &ctx_mutex, SSL *ssl, socket_t sock,
8730
8692
8731
8693
auto ret = SSL_shutdown (ssl);
8732
8694
while (ret == 0 ) {
8733
- std::this_thread::sleep_for (std::chrono::microseconds{ 10 });
8695
+ std::this_thread::sleep_for (std::chrono::milliseconds{ 100 });
8734
8696
ret = SSL_shutdown (ssl);
8735
8697
}
8736
8698
#endif
0 commit comments