From 4351730550bc48c4237de4e616f8e420e084c081 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Fri, 15 Feb 2008 08:26:00 +0000 Subject: * updated c++ build to work with recent gentools changes * add null exchange.bound impl to SessionHandlerImpl (to reflect change to spec file) * pass AMQDataBlocks rather than AMQFrames to OutputHandler * allow client to pass messages frames to io layer in one go (via FrameList) if it will fit in a single buffer git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/M2.1@627971 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/lib/client/ClientChannel.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'cpp/lib/client/ClientChannel.cpp') diff --git a/cpp/lib/client/ClientChannel.cpp b/cpp/lib/client/ClientChannel.cpp index a97d79dcf9..92f8ae63ca 100644 --- a/cpp/lib/client/ClientChannel.cpp +++ b/cpp/lib/client/ClientChannel.cpp @@ -23,6 +23,7 @@ #include #include #include +#include using namespace boost; //to use dynamic_pointer_cast using namespace qpid::client; @@ -219,19 +220,25 @@ void Channel::publish(Message& msg, const Exchange& exchange, const std::string& string e = exchange.getName(); string key = routingKey; - out->send(new AMQFrame(version, id, new BasicPublishBody(version, 0, e, key, mandatory, immediate))); + std::auto_ptr message(new FrameList()); + + message->add(new AMQFrame(version, id, new BasicPublishBody(version, 0, e, key, mandatory, immediate))); //break msg up into header frame and content frame(s) and send these string data = msg.getData(); msg.header->setContentSize(data.length()); AMQBody::shared_ptr body(static_pointer_cast(msg.header)); - out->send(new AMQFrame(version, id, body)); + message->add(new AMQFrame(version, id, body)); u_int64_t data_length = data.length(); if(data_length > 0){ u_int32_t frag_size = con->getMaxFrameSize() - 8;//frame itself uses 8 bytes - if(data_length < frag_size){ - out->send(new AMQFrame(version, id, new AMQContentBody(data))); + if(data_length + message->size() < frag_size){ + message->add(new AMQFrame(version, id, new AMQContentBody(data))); + } else if(data_length < frag_size){ + out->send(message.release()); + out->send(new AMQFrame(version, id, new AMQContentBody(data))); }else{ + out->send(message.release()); u_int32_t offset = 0; u_int32_t remaining = data_length - offset; while (remaining > 0) { @@ -244,6 +251,7 @@ void Channel::publish(Message& msg, const Exchange& exchange, const std::string& } } } + if (message.get()) out->send(message.release()); } void Channel::commit(){ -- cgit v1.2.1