From bcc85c7e5cbcf0737f5180e3d601e63b480e8949 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Fri, 30 Sep 2022 15:13:45 +0200 Subject: De/reduce buffer creation in parsepackedmessage (#175) * Don't create call CreateBuffer for attachement data that we only read and not keep * changelog * don't read oplog attachments into memory just to do a redundant store of them --- zenhttp/httpshared.cpp | 49 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 12 deletions(-) (limited to 'zenhttp/httpshared.cpp') diff --git a/zenhttp/httpshared.cpp b/zenhttp/httpshared.cpp index 2b96f32fc..f9aa3af82 100644 --- a/zenhttp/httpshared.cpp +++ b/zenhttp/httpshared.cpp @@ -253,14 +253,11 @@ ParsePackageMessage(IoBuffer Payload, std::functionPayloadByteOffset, AttachRefHdr->PayloadByteSize)) { CompressedBuffer CompBuf(CompressedBuffer::FromCompressed(SharedBuffer(ChunkReference))); - CbAttachment Attachment(std::move(CompBuf)); + if (!CompBuf) + { + throw std::runtime_error(fmt::format("invalid format for chunk #{} at '{}' (offset {}, size {})", + i, + PathToUtf8(Path), + AttachRefHdr->PayloadByteOffset, + AttachRefHdr->PayloadByteSize)); + } + CbAttachment Attachment(std::move(CompBuf)); Package.AddAttachment(Attachment); } else { // Unable to open chunk reference - throw std::runtime_error(fmt::format("unable to resolve chunk #{} at '{}' (offset {}, size {})", i, PathToUtf8(Path), @@ -295,12 +299,15 @@ ParsePackageMessage(IoBuffer Payload, std::function