mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-10-18 11:09:39 +00:00
Remove semantically redundant closed_ checks in ping thread. (#2613)
This commit is contained in:
1 parent
09fa6820fe
commit
d59f3e438c
1 file changed
+3
-5
@@ -22830,11 +22830,9 @@ inline void WebSocket::start_heartbeat() {
|
|||||||
if (ping_interval_sec_ == 0) { return; }
|
if (ping_interval_sec_ == 0) { return; }
|
||||||
ping_thread_ = std::thread([this]() {
|
ping_thread_ = std::thread([this]() {
|
||||||
std::unique_lock<std::mutex> lock(ping_mutex_);
|
std::unique_lock<std::mutex> lock(ping_mutex_);
|
||||||
while (!closed_) {
|
// The predicate keeps a spurious wakeup from sending a ping early
|
||||||
// The predicate keeps a spurious wakeup from sending a ping early
|
while (!ping_cv_.wait_for(lock, std::chrono::seconds(ping_interval_sec_),
|
||||||
ping_cv_.wait_for(lock, std::chrono::seconds(ping_interval_sec_),
|
[this]() { return closed_.load(); })) {
|
||||||
[this]() { return closed_.load(); });
|
|
||||||
if (closed_) { break; }
|
|
||||||
// If the peer has failed to respond to the previous pings, give up.
|
// If the peer has failed to respond to the previous pings, give up.
|
||||||
// RFC 6455 does not define a pong-timeout mechanism; this is an
|
// RFC 6455 does not define a pong-timeout mechanism; this is an
|
||||||
// opt-in liveness check controlled by max_missed_pongs_.
|
// opt-in liveness check controlled by max_missed_pongs_.
|
||||||
|
|||||||
Reference in new issue
Block a user