summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/sys
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-06-27 21:19:14 +0000
committerAlan Conway <aconway@apache.org>2007-06-27 21:19:14 +0000
commit0efcf2c5c91f4927ccc00ad1cf391c2f964cc2e1 (patch)
treea9318ac4787cf588dd1329c2e557d8f870be20cc /cpp/src/qpid/sys
parent548abd065f91bc1f238ac98c24edf410edf10356 (diff)
downloadqpid-python-0efcf2c5c91f4927ccc00ad1cf391c2f964cc2e1.tar.gz
* 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
Diffstat (limited to 'cpp/src/qpid/sys')
-rw-r--r--cpp/src/qpid/sys/apr/LFSessionContext.cpp14
-rw-r--r--cpp/src/qpid/sys/apr/LFSessionContext.h5
2 files changed, 9 insertions, 10 deletions
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 <apr_time.h>
#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<qpid::framing::AMQFrame*> framesToWrite;
+ std::queue<qpid::framing::AMQFrame> 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();