From a2ded139f371d273afa858f49a5b7f6e0efc2394 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Tue, 6 Nov 2007 17:27:27 +0000 Subject: Add support for array type to c++ (and python, decode only for now) Change the type of the in-doubt field in dtx-coordination.recover to an array (to bring in line with amqp spec) git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@592494 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/broker/DtxHandlerImpl.cpp | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'cpp/src/qpid/broker') diff --git a/cpp/src/qpid/broker/DtxHandlerImpl.cpp b/cpp/src/qpid/broker/DtxHandlerImpl.cpp index ec042ff56a..533872e849 100644 --- a/cpp/src/qpid/broker/DtxHandlerImpl.cpp +++ b/cpp/src/qpid/broker/DtxHandlerImpl.cpp @@ -20,6 +20,7 @@ #include #include "Broker.h" #include "qpid/framing/constants.h" +#include "qpid/framing/Array.h" using namespace qpid::broker; using namespace qpid::framing; @@ -136,25 +137,14 @@ DtxCoordinationRecoverResult DtxHandlerImpl::recover(u_int16_t /*ticket*/, // strictly 'legal', but that is ok for testing std::set xids; getBroker().getStore().collectPreparedXids(xids); - uint size(0); - for (std::set::iterator i = xids.begin(); i != xids.end(); i++) { - size += i->size() + 1/*shortstr size*/; - } - char* bytes = static_cast(::alloca(size + 4/*longstr size*/)); - Buffer wbuffer(bytes, size + 4/*longstr size*/); - wbuffer.putLong(size); + //TODO: remove the need to copy from one container type to another + std::vector data; for (std::set::iterator i = xids.begin(); i != xids.end(); i++) { - wbuffer.putShortString(*i); + data.push_back(*i); } - - Buffer rbuffer(bytes, size + 4/*longstr size*/); - string data; - rbuffer.getLongString(data); - - FieldTable response; - response.setString("xids", data); - return DtxCoordinationRecoverResult(response); + Array indoubt(data); + return DtxCoordinationRecoverResult(indoubt); } void DtxHandlerImpl::forget(u_int16_t /*ticket*/, -- cgit v1.2.1