From ee5fcbce34eaef87ffced2a993c8443af4af4fe2 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Fri, 14 Jun 2024 22:12:57 +0200 Subject: don't assert that we have moved bytes if source block is zero size (#97) * don't assert that we have moved bytes if source block is zero size * handle invalid session ids gracefully --- src/zenhttp/servers/httpparser.cpp | 2 +- src/zenhttp/servers/httpsys.cpp | 2 +- src/zenstore/blockstore.cpp | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/zenhttp/servers/httpparser.cpp b/src/zenhttp/servers/httpparser.cpp index b848a5243..6829faa4a 100644 --- a/src/zenhttp/servers/httpparser.cpp +++ b/src/zenhttp/servers/httpparser.cpp @@ -149,7 +149,7 @@ HttpRequestParser::AppendCurrentHeader() } else if (HeaderHash == HashSession) { - m_SessionId = Oid::FromHexString(HeaderValue); + m_SessionId = Oid::TryFromHexString(HeaderValue); } else if (HeaderHash == HashRequest) { diff --git a/src/zenhttp/servers/httpsys.cpp b/src/zenhttp/servers/httpsys.cpp index 2b97e3f25..ac17d3ba0 100644 --- a/src/zenhttp/servers/httpsys.cpp +++ b/src/zenhttp/servers/httpsys.cpp @@ -1668,7 +1668,7 @@ HttpSysServerRequest::ParseSessionId() const { if (Header.RawValueLength == Oid::StringLength) { - return Oid::FromHexString({Header.pRawValue, Header.RawValueLength}); + return Oid::TryFromHexString({Header.pRawValue, Header.RawValueLength}); } } } diff --git a/src/zenstore/blockstore.cpp b/src/zenstore/blockstore.cpp index 6e289409c..4b650e2d5 100644 --- a/src/zenstore/blockstore.cpp +++ b/src/zenstore/blockstore.cpp @@ -1382,7 +1382,8 @@ BlockStore::CompactBlocks(const BlockStoreCompactState& CompactState, MovedSize += NewBlockSize; NewBlockFile = nullptr; - ZEN_ASSERT(!MovedChunks.empty() || RemovedSize > 0); // We should not have a new block if we haven't moved anything + ZEN_ASSERT(!MovedChunks.empty() || + (RemovedSize > 0 || OldBlockSize == 0)); // We should not have a new block if we haven't moved anything ZEN_INFO("{}wrote block {} ({})", LogPrefix, -- cgit v1.2.3