Author: gsim
Date: Tue Oct  2 03:36:28 2007
New Revision: 581185

URL: http://svn.apache.org/viewvc?rev=581185&view=rev
Log:
Fixed bug introduced in r577027 where the header frame of a message is directly 
passed to output handler where the channel is changed. This causing problems 
when the message is sent to multiple channels concurrently. I've added a const 
modifier to preventthe message being altered by sendHeader().


Modified:
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Message.cpp
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Message.h
    incubator/qpid/trunk/qpid/cpp/src/qpid/framing/frame_functors.h

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Message.cpp
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Message.cpp?rev=581185&r1=581184&r2=581185&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Message.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Message.cpp Tue Oct  2 
03:36:28 2007
@@ -173,9 +173,10 @@
     }
 }
 
-void Message::sendHeader(framing::FrameHandler& out, uint16_t /*maxFrameSize*/)
+void Message::sendHeader(framing::FrameHandler& out, uint16_t 
/*maxFrameSize*/) const
 {
-    frames.map_if(out, TypeFilter(HEADER_BODY));    
+    Relay f(out);
+    frames.map_if(f, TypeFilter(HEADER_BODY));    
 }
 
 MessageAdapter& Message::getAdapter() const

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Message.h
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Message.h?rev=581185&r1=581184&r2=581185&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Message.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Message.h Tue Oct  2 03:36:28 
2007
@@ -115,7 +115,7 @@
     void releaseContent(MessageStore* store);
 
     void sendContent(framing::FrameHandler& out, uint16_t maxFrameSize);
-    void sendHeader(framing::FrameHandler& out, uint16_t maxFrameSize);
+    void sendHeader(framing::FrameHandler& out, uint16_t maxFrameSize) const;
 
     bool isContentLoaded() const;
 
@@ -132,7 +132,7 @@
     static PublishAdapter PUBLISH;
 
     MessageAdapter& getAdapter() const;
-    bool isContentReleased() { return store; } 
+    bool isContentReleased() const { return store; } 
 };
 
 }}

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/frame_functors.h
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/frame_functors.h?rev=581185&r1=581184&r2=581185&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/frame_functors.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/frame_functors.h Tue Oct  2 
03:36:28 2007
@@ -82,6 +82,23 @@
     void operator()(const AMQFrame& f) { content += 
f.castBody<AMQContentBody>()->getData(); }
 };
 
+/**
+ * Sends a copy of the frame its applied to to the specified handler
+ */
+class Relay
+{
+    FrameHandler& handler;
+
+public:
+    Relay(FrameHandler& h) : handler(h) {}
+
+    void operator()(const AMQFrame& f)
+    {
+        AMQFrame copy(f);
+        handler.handle(copy);
+    }
+};
+
 class Print
 {
     std::ostream& out;


Reply via email to