Wake a WebSocket read on a pong timeout on every platform

When max_missed_pongs ran out, the heartbeat thread shut down the read
side of the socket to end a read() blocked on the silent peer. On
Windows that does not wake the wait, so read() stayed blocked until its
read timeout and then returned Timeout. The heartbeat test never ran on
Windows, so CI did not catch it.

The heartbeat now sets a flag that the stream's read interrupt checks,
the mechanism SSEClient::stop() uses, and WebSocketSSLStream takes the
interrupt too. It is set only when a pong timeout can happen, so other
connections wait as before. read() reports a timeout on a connection
that has closed as Fail, since Timeout means it is still usable.

Build and run the heartbeat test in the Windows jobs, and add a TLS
pong timeout test.
This commit is contained in:
yhirose committed 2026-10-18 17:23:05 -04:00
1 parent 801bf2e0d2
commit 696b94b5ed
4 files changed
+76 -27

No files matched your search

+8
View File
@@ -31,6 +31,14 @@ target_compile_options(httplib-test PRIVATE "$<$<CXX_COMPILER_ID:MSVC>:/utf-8;/b
target_link_libraries(httplib-test PRIVATE httplib GTest::gtest_main CURL::libcurl)
gtest_discover_tests(httplib-test)
# It overrides the heartbeat macros, which a compiled library has fixed
if(NOT HTTPLIB_COMPILE)
add_executable(httplib-heartbeat-test test_websocket_heartbeat.cc)
target_compile_options(httplib-heartbeat-test PRIVATE "$<$<CXX_COMPILER_ID:MSVC>:/utf-8;/bigobj>")
target_link_libraries(httplib-heartbeat-test PRIVATE httplib GTest::gtest_main)
gtest_discover_tests(httplib-heartbeat-test)
endif()
file(
COPY www www2 www3 ca-bundle.crt image.jpg
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}