From bf746b5958b0107e66dabad39024f7ad933820ad Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Thu, 12 Sep 2013 09:26:30 +0000 Subject: QPID-5122: QPID-5134: fix build on windows by avoiding use of templated Buffer method (don't need variable sized delivery tag) git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1522499 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/qpid/broker/amqp/Outgoing.cpp | 15 +++++++++------ qpid/cpp/src/qpid/broker/amqp/Outgoing.h | 8 ++++++-- 2 files changed, 15 insertions(+), 8 deletions(-) (limited to 'qpid/cpp/src') diff --git a/qpid/cpp/src/qpid/broker/amqp/Outgoing.cpp b/qpid/cpp/src/qpid/broker/amqp/Outgoing.cpp index 8b2b380173..e8c05ed7b0 100644 --- a/qpid/cpp/src/qpid/broker/amqp/Outgoing.cpp +++ b/qpid/cpp/src/qpid/broker/amqp/Outgoing.cpp @@ -256,14 +256,17 @@ qpid::broker::OwnershipToken* OutgoingFromQueue::getSession() return 0; } -OutgoingFromQueue::Record::Record() : delivery(0), disposition(0), index(0) {} +OutgoingFromQueue::Record::Record() : delivery(0), disposition(0), index(0) +{ + tag.bytes = tagData; + tag.size = TAG_WIDTH; +} void OutgoingFromQueue::Record::init(size_t i) { index = i; - qpid::framing::Buffer buffer(tagData, Record::TAG_WIDTH); - buffer.putUInt(index); - tag.bytes = tagData; - tag.size = Record::TAG_WIDTH; + qpid::framing::Buffer buffer(tagData, tag.size); + assert(index <= std::numeric_limits::max()); + buffer.putLong(index); } void OutgoingFromQueue::Record::reset() { @@ -277,7 +280,7 @@ size_t OutgoingFromQueue::Record::getIndex(pn_delivery_tag_t t) { assert(t.size == TAG_WIDTH); qpid::framing::Buffer buffer(const_cast(t.bytes)/*won't ever be written to*/, t.size); - return (size_t) buffer.getUInt(); + return (size_t) buffer.getLong(); } diff --git a/qpid/cpp/src/qpid/broker/amqp/Outgoing.h b/qpid/cpp/src/qpid/broker/amqp/Outgoing.h index 38d9e17190..81994f2b66 100644 --- a/qpid/cpp/src/qpid/broker/amqp/Outgoing.h +++ b/qpid/cpp/src/qpid/broker/amqp/Outgoing.h @@ -118,8 +118,12 @@ class OutgoingFromQueue : public Outgoing, public qpid::broker::Consumer, public int disposition; size_t index; pn_delivery_tag_t tag; - static const size_t TAG_WIDTH = sizeof(size_t); - char tagData[TAG_WIDTH];//index in encoded form, used for tag + //The delivery tag is a 4 byte value representing the + //index. It is encoded separately to avoid alignment issues. + //The number of deliveries held here is always strictly + //bounded, so 4 bytes is more than enough. + static const size_t TAG_WIDTH = sizeof(uint32_t); + char tagData[TAG_WIDTH]; Record(); void init(size_t i); -- cgit v1.2.1