[ntcore] Fix EALREADY errors by tracking read state (#7202)

This commit is contained in:
Peter Johnson
2024-10-13 00:14:16 -07:00
committed by GitHub
parent 12885015ed
commit 4023cdc80a
2 changed files with 26 additions and 4 deletions

View File

@@ -59,8 +59,18 @@ class WebSocketConnection final
return m_ws.GetLastReceivedTime();
}
void StopRead() final { m_ws.GetStream().StopRead(); }
void StartRead() final { m_ws.GetStream().StartRead(); }
void StopRead() final {
if (m_readActive) {
m_ws.GetStream().StopRead();
m_readActive = false;
}
}
void StartRead() final {
if (!m_readActive) {
m_ws.GetStream().StartRead();
m_readActive = true;
}
}
void Disconnect(std::string_view reason) final;
@@ -80,6 +90,7 @@ class WebSocketConnection final
wpi::WebSocket& m_ws;
wpi::Logger& m_logger;
bool m_readActive = true;
class Stream;

View File

@@ -41,8 +41,18 @@ class UvStreamConnection3 final
uint64_t GetLastFlushTime() const final { return m_lastFlushTime; }
void StopRead() final { m_stream.StopRead(); }
void StartRead() final { m_stream.StartRead(); }
void StopRead() final {
if (m_readActive) {
m_stream.StopRead();
m_readActive = false;
}
}
void StartRead() final {
if (!m_readActive) {
m_stream.StartRead();
m_readActive = true;
}
}
void Disconnect(std::string_view reason) final;
@@ -62,6 +72,7 @@ class UvStreamConnection3 final
std::string m_reason;
uint64_t m_lastFlushTime = 0;
int m_sendsActive = 0;
bool m_readActive = true;
};
} // namespace nt::net3