summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorKenneth Anthony Giusti <kgiusti@apache.org>2012-03-02 14:49:56 +0000
committerKenneth Anthony Giusti <kgiusti@apache.org>2012-03-02 14:49:56 +0000
commitaf7c9ae82ad2392a6c1369c93a3ea1903362b510 (patch)
tree536f50a139ef37c504df2146ba78a9e54ed5cca6 /cpp
parent323524c6b0c8d01298d735ef1f9d87d2a5df7296 (diff)
downloadqpid-python-af7c9ae82ad2392a6c1369c93a3ea1903362b510.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')
-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>());