From 0a1b3430450f274aee273a9f792a2d43f771b85f Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Thu, 13 Sep 2007 17:29:16 +0000 Subject: Use frameset begin/end flags for determining frameset boundaries. Set frameset & segment begin/end flags for content bearing methods (i.e. messages). git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@575377 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/framing/SendContent.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'cpp/src/qpid/framing/SendContent.cpp') diff --git a/cpp/src/qpid/framing/SendContent.cpp b/cpp/src/qpid/framing/SendContent.cpp index 568cc01665..573ebca9e2 100644 --- a/cpp/src/qpid/framing/SendContent.cpp +++ b/cpp/src/qpid/framing/SendContent.cpp @@ -21,31 +21,47 @@ #include "SendContent.h" -qpid::framing::SendContent::SendContent(FrameHandler& h, uint16_t c, uint16_t mfs) : handler(h), channel(c), maxFrameSize(mfs) {} +qpid::framing::SendContent::SendContent(FrameHandler& h, uint16_t c, uint16_t mfs, uint efc) : handler(h), channel(c), + maxFrameSize(mfs), + expectedFrameCount(efc), frameCount(0) {} -void qpid::framing::SendContent::operator()(AMQFrame& f) const +void qpid::framing::SendContent::operator()(const AMQFrame& f) { + bool first = frameCount == 0; + bool last = ++frameCount == expectedFrameCount; + uint16_t maxContentSize = maxFrameSize - AMQFrame::frameOverhead(); const AMQContentBody* body(f.castBody()); if (body->size() > maxContentSize) { uint32_t offset = 0; for (int chunk = body->size() / maxContentSize; chunk > 0; chunk--) { - sendFragment(*body, offset, maxContentSize); + sendFragment(*body, offset, maxContentSize, first && offset == 0, last && offset + maxContentSize == body->size()); offset += maxContentSize; } uint32_t remainder = body->size() % maxContentSize; if (remainder) { - sendFragment(*body, offset, remainder); + sendFragment(*body, offset, remainder, first && offset == 0, last); } } else { AMQFrame copy(f); + setFlags(copy, first, last); copy.setChannel(channel); handler.handle(copy); } } -void qpid::framing::SendContent::sendFragment(const AMQContentBody& body, uint32_t offset, uint16_t size) const +void qpid::framing::SendContent::sendFragment(const AMQContentBody& body, uint32_t offset, uint16_t size, bool first, bool last) const { AMQFrame fragment(channel, AMQContentBody(body.getData().substr(offset, size))); + setFlags(fragment, first, last); handler.handle(fragment); } + +void qpid::framing::SendContent::setFlags(AMQFrame& f, bool first, bool last) const +{ + f.setBof(false); + f.setBos(first); + f.setEof(last); + f.setEos(last); +} + -- cgit v1.2.1