mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-11-24 20:31:50 +00:00
Drop the heartbeat's own closed_ update and the vacuous test check
send_frame now marks the connection closed whenever it returns false, so the heartbeat no longer needs to. The second send() in the test fails before the fix too, since the client is not reading, so it does not check anything; large_sent becomes an ASSERT as the precondition.
This commit is contained in:
1 parent
77b035c892
commit
baf27c5993
2 files changed
+2
-9
No files matched your search
@@ -25052,11 +25052,7 @@ inline void WebSocket::start_heartbeat() {
|
||||
return;
|
||||
}
|
||||
lock.unlock();
|
||||
if (!send_frame(Opcode::Ping, nullptr, 0)) {
|
||||
lock.lock();
|
||||
closed_ = true;
|
||||
break;
|
||||
}
|
||||
if (!send_frame(Opcode::Ping, nullptr, 0)) { return; }
|
||||
lock.lock();
|
||||
unacked_pings_++;
|
||||
}
|
||||
|
||||
+1
-4
@@ -29625,7 +29625,6 @@ TEST(WebSocketPartialWriteTest, FailedWriteClosesConnection) {
|
||||
const std::string large(4 * 1024 * 1024, 'A');
|
||||
std::atomic<bool> large_sent{true};
|
||||
std::atomic<bool> open_after_failure{true};
|
||||
std::atomic<bool> small_sent{true};
|
||||
std::atomic<bool> handler_done{false};
|
||||
|
||||
Server svr;
|
||||
@@ -29638,7 +29637,6 @@ TEST(WebSocketPartialWriteTest, FailedWriteClosesConnection) {
|
||||
svr.WebSocket("/ws", [&](const Request &, ws::WebSocket &ws) {
|
||||
large_sent = ws.send(large.data(), large.size());
|
||||
open_after_failure = ws.is_open();
|
||||
small_sent = ws.send("after");
|
||||
handler_done = true;
|
||||
});
|
||||
|
||||
@@ -29665,9 +29663,8 @@ TEST(WebSocketPartialWriteTest, FailedWriteClosesConnection) {
|
||||
}
|
||||
ASSERT_TRUE(handler_done);
|
||||
|
||||
EXPECT_FALSE(large_sent);
|
||||
ASSERT_FALSE(large_sent);
|
||||
EXPECT_FALSE(open_after_failure);
|
||||
EXPECT_FALSE(small_sent);
|
||||
|
||||
client.close();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user