summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorKen Giusti <kgiusti@apache.org>2012-03-02 14:49:56 +0000
committerKen Giusti <kgiusti@apache.org>2012-03-02 14:49:56 +0000
commitef65a902a26c54f6baed71bba684f9904bddf8ba (patch)
tree536f50a139ef37c504df2146ba78a9e54ed5cca6 /cpp/src
parentd532662b125d5173f87c12bd6facc480315405fc (diff)
downloadqpid-python-ef65a902a26c54f6baed71bba684f9904bddf8ba.tar.gz
QPID-3877: hold lock during message header encode.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1296230 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/qpid/broker/Message.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/cpp/src/qpid/broker/Message.cpp b/cpp/src/qpid/broker/Message.cpp
index ae4503328a..7093a68d6c 100644
--- a/cpp/src/qpid/broker/Message.cpp
+++ b/cpp/src/qpid/broker/Message.cpp
@@ -131,9 +131,12 @@ uint32_t Message::getRequiredCredit()
void Message::encode(framing::Buffer& buffer) const
{
- //encode method and header frames
- EncodeFrame f1(buffer);
- frames.map_if(f1, TypeFilter2<METHOD_BODY, HEADER_BODY>());
+ {
+ sys::Mutex::ScopedLock l(lock); // prevent header modifications while encoding
+ //encode method and header frames
+ EncodeFrame f1(buffer);
+ frames.map_if(f1, TypeFilter2<METHOD_BODY, HEADER_BODY>());
+ }
//then encode the payload of each content frame
framing::EncodeBody f2(buffer);
@@ -159,6 +162,7 @@ uint32_t Message::encodedContentSize() const
uint32_t Message::encodedHeaderSize() const
{
+ sys::Mutex::ScopedLock l(lock); // prevent modifications while computing size
//add up the size for all method and header frames in the frameset
SumFrameSize sum;
frames.map_if(sum, TypeFilter2<METHOD_BODY, HEADER_BODY>());
@@ -354,6 +358,7 @@ public:
AMQHeaderBody* Message::getHeaderBody()
{
+ // expects lock to be held
if (copyHeaderOnWrite) {
CloneHeaderBody f;
frames.map_if(f, TypeFilter<HEADER_BODY>());