aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2024-03-05 14:06:13 +0100
committerGitHub <[email protected]>2024-03-05 14:06:13 +0100
commit1c5fadd56944c3aedefaf6065bbce4a028e620e4 (patch)
tree6078f2b10c1b66b4ca7fbc7c81144115b1a458e7
parent5.4.2-pre0 (diff)
downloadzen-1c5fadd56944c3aedefaf6065bbce4a028e620e4.tar.xz
zen-1c5fadd56944c3aedefaf6065bbce4a028e620e4.zip
some asio HTTP server tweaks for correctness (#663)
-rw-r--r--CHANGELOG.md1
-rw-r--r--src/zenhttp/servers/httpasio.cpp20
2 files changed, 12 insertions, 9 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 863e628f8..db305dd8f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@
- Improvement: Improved logging for block store GCV2 operations
- Improvement: Added more tests for GCV2 (added GCV2 versions of existing GCV2 tests)
- Improvement: Add disk cache to reading and writing blocks when moving data in GCV2
+- Improvement: Cleaned up some asio server state machine details (minor)
- Removed: `--cache-reference-cache-enabled` option has been removed along with the implementation for reference caching in disk cache
## 5.4.1
diff --git a/src/zenhttp/servers/httpasio.cpp b/src/zenhttp/servers/httpasio.cpp
index 6b45c259d..c75057733 100644
--- a/src/zenhttp/servers/httpasio.cpp
+++ b/src/zenhttp/servers/httpasio.cpp
@@ -293,7 +293,7 @@ HttpServerConnection::TerminateConnection()
void
HttpServerConnection::EnqueueRead()
{
- if (m_RequestState == RequestState::kInitialRead)
+ if ((m_RequestState == RequestState::kInitialRead) || (m_RequestState == RequestState::kReadingMore))
{
m_RequestState = RequestState::kReadingMore;
}
@@ -315,15 +315,17 @@ HttpServerConnection::OnDataReceived(const asio::error_code& Ec, [[maybe_unused]
{
if (Ec)
{
- if (m_RequestState == RequestState::kDone || m_RequestState == RequestState::kInitialRead)
+ switch (m_RequestState)
{
- ZEN_TRACE_VERBOSE("on data received ERROR (EXPECTED), connection: {}, reason: '{}'", m_ConnectionId, Ec.message());
- return;
- }
- else
- {
- ZEN_WARN("on data received ERROR, connection: {}, reason '{}'", m_ConnectionId, Ec.message());
- return TerminateConnection();
+ case RequestState::kDone:
+ case RequestState::kInitialRead:
+ case RequestState::kTerminated:
+ ZEN_TRACE_VERBOSE("on data received ERROR (EXPECTED), connection: {}, reason: '{}'", m_ConnectionId, Ec.message());
+ return;
+
+ default:
+ ZEN_WARN("on data received ERROR, connection: {}, reason '{}'", m_ConnectionId, Ec.message());
+ return TerminateConnection();
}
}