diff options
author | Carl C. Trieloff <cctrieloff@apache.org> | 2008-10-11 18:24:50 +0000 |
---|---|---|
committer | Carl C. Trieloff <cctrieloff@apache.org> | 2008-10-11 18:24:50 +0000 |
commit | 493993c4b8851ba1a1170abb928d2f37d8060e83 (patch) | |
tree | 6e7e3caf48995fdc5055dd83e1cc60d735a680a2 /cpp/src | |
parent | 7a4f554f249787b7de06d1bf6e61d5c587a28f1a (diff) | |
download | qpid-python-493993c4b8851ba1a1170abb928d2f37d8060e83.tar.gz |
QPID-1306
- Added aquire safety check + test.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@703704 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/qpid/broker/Queue.cpp | 3 | ||||
-rw-r--r-- | cpp/src/tests/QueueTest.cpp | 9 |
2 files changed, 8 insertions, 4 deletions
diff --git a/cpp/src/qpid/broker/Queue.cpp b/cpp/src/qpid/broker/Queue.cpp index 4382ac2e57..315da23965 100644 --- a/cpp/src/qpid/broker/Queue.cpp +++ b/cpp/src/qpid/broker/Queue.cpp @@ -202,7 +202,8 @@ bool Queue::acquire(const QueuedMessage& msg) { Mutex::ScopedLock locker(messageLock); QPID_LOG(debug, "attempting to acquire " << msg.position); for (Messages::iterator i = messages.begin(); i != messages.end(); i++) { - if (i->position == msg.position) { + if ((i->position == msg.position && !lastValueQueue) // note that in some cases payload not be set + || (lastValueQueue && i->position == msg.position && i->payload.get() == msg.payload.get())) { if (lastValueQueue){ const framing::FieldTable* ft = msg.payload->getApplicationHeaders(); string key = ft->getString(qpidVQMatchProperty); diff --git a/cpp/src/tests/QueueTest.cpp b/cpp/src/tests/QueueTest.cpp index a189dc1f15..ccc2fc2391 100644 --- a/cpp/src/tests/QueueTest.cpp +++ b/cpp/src/tests/QueueTest.cpp @@ -423,9 +423,12 @@ QPID_AUTO_TEST_CASE(testLVQAcquire){ BOOST_CHECK_EQUAL(queue->getMessageCount(), 3u); - framing::SequenceNumber sequence; - QueuedMessage qmsg(queue.get(), msg2, ++sequence); - queue->acquire(qmsg); + framing::SequenceNumber sequence(1); + QueuedMessage qmsg(queue.get(), msg1, sequence); + QueuedMessage qmsg2(queue.get(), msg2, ++sequence); + + BOOST_CHECK(!queue->acquire(qmsg)); + BOOST_CHECK(queue->acquire(qmsg2)); BOOST_CHECK_EQUAL(queue->getMessageCount(), 2u); |