From 0efcf2c5c91f4927ccc00ad1cf391c2f964cc2e1 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Wed, 27 Jun 2007 21:19:14 +0000 Subject: * src/qpid/framing/ChannelAdapter.cpp: Use handler chains for in and outbound frames. * src/qpid/framing/InputHandler.h, OutputHandler.h, FrameHandler.h: All handlers pass AMQFrame& and have consistent memory management. Terminal OutputHandlers used to take ownership and delete frame, now they make a shallow copy instead. * src/qpid/framing/Handler.h, FrameHandler.h: Simplified. * src/qpid/client/ClientConnection.cpp: * src/qpid/broker/Connection.cpp: * src/qpid/broker/BrokerChannel.cpp: Update for ChannelAdapter changes. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@551336 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/sys/apr/LFSessionContext.cpp | 14 ++++++-------- cpp/src/qpid/sys/apr/LFSessionContext.h | 5 +++-- 2 files changed, 9 insertions(+), 10 deletions(-) (limited to 'cpp/src/qpid/sys/apr') diff --git a/cpp/src/qpid/sys/apr/LFSessionContext.cpp b/cpp/src/qpid/sys/apr/LFSessionContext.cpp index 0717dcc9ae..4e708fd747 100644 --- a/cpp/src/qpid/sys/apr/LFSessionContext.cpp +++ b/cpp/src/qpid/sys/apr/LFSessionContext.cpp @@ -62,7 +62,7 @@ void LFSessionContext::read(){ try{ while(frame.decode(in)){ QPID_LOG(debug, "RECV: " << frame); - handler->received(&frame); + handler->received(frame); } }catch(const std::exception& e){ QPID_LOG(error, e.what()); @@ -94,14 +94,12 @@ void LFSessionContext::write(){ if(!framesToWrite.empty()){ out.clear(); bool encoded(false); - AMQFrame* frame = framesToWrite.front(); - while(frame && out.available() >= frame->size()){ + while(!framesToWrite.empty() && out.available() >= framesToWrite.front().size()){ + AMQFrame& frame = framesToWrite.front(); encoded = true; - frame->encode(out); - QPID_LOG(debug, "SENT: " << *frame); - delete frame; + frame.encode(out); + QPID_LOG(debug, "SENT: " << frame); framesToWrite.pop(); - frame = framesToWrite.empty() ? 0 : framesToWrite.front(); } if(!encoded) THROW_QPID_ERROR(FRAMING_ERROR, "Could not write frame, too large for buffer."); out.flip(); @@ -118,7 +116,7 @@ void LFSessionContext::write(){ } } -void LFSessionContext::send(AMQFrame* frame){ +void LFSessionContext::send(AMQFrame& frame){ Mutex::ScopedLock l(writeLock); if(!closing){ framesToWrite.push(frame); diff --git a/cpp/src/qpid/sys/apr/LFSessionContext.h b/cpp/src/qpid/sys/apr/LFSessionContext.h index 5248d8f5bd..0ff80eccec 100644 --- a/cpp/src/qpid/sys/apr/LFSessionContext.h +++ b/cpp/src/qpid/sys/apr/LFSessionContext.h @@ -28,6 +28,7 @@ #include #include "qpid/framing/AMQFrame.h" +#include "qpid/framing/FrameHandler.h" #include "qpid/framing/Buffer.h" #include "qpid/sys/Monitor.h" #include "qpid/sys/Mutex.h" @@ -55,7 +56,7 @@ class LFSessionContext : public virtual qpid::sys::ConnectionOutputHandler apr_pollfd_t fd; - std::queue framesToWrite; + std::queue framesToWrite; qpid::sys::Mutex writeLock; bool processing; @@ -66,7 +67,7 @@ class LFSessionContext : public virtual qpid::sys::ConnectionOutputHandler LFProcessor* const processor, bool debug = false); virtual ~LFSessionContext(); - virtual void send(qpid::framing::AMQFrame* frame); + virtual void send(framing::AMQFrame& frame); virtual void close(); void read(); void write(); -- cgit v1.2.1