qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject svn commit: r1515793 - in /qpid/trunk/qpid/cpp/src: qpid/broker/PriorityQueue.cpp tests/MessagingSessionTests.cpp
Date Tue, 20 Aug 2013 12:17:07 GMT
Author: gsim
Date: Tue Aug 20 12:17:06 2013
New Revision: 1515793

URL: http://svn.apache.org/r1515793
Log:
QPID-5085: ensure messages released 'behind' a cursor on a priority queue don't get missed

Modified:
    qpid/trunk/qpid/cpp/src/qpid/broker/PriorityQueue.cpp
    qpid/trunk/qpid/cpp/src/tests/MessagingSessionTests.cpp

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/PriorityQueue.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/PriorityQueue.cpp?rev=1515793&r1=1515792&r2=1515793&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/PriorityQueue.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/PriorityQueue.cpp Tue Aug 20 12:17:06 2013
@@ -135,7 +135,12 @@ void PriorityQueue::publish(const Messag
 Message* PriorityQueue::release(const QueueCursor& cursor)
 {
     MessagePointer* ptr = fifo.release(cursor);
-    return ptr ? &(ptr->holder->message) : 0;
+    if (ptr) {
+        messages[ptr->holder->priority].resetCursors();
+        return &(ptr->holder->message);
+    } else {
+        return 0;
+    }
 }
 
 void PriorityQueue::foreach(Functor f)

Modified: qpid/trunk/qpid/cpp/src/tests/MessagingSessionTests.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/MessagingSessionTests.cpp?rev=1515793&r1=1515792&r2=1515793&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/MessagingSessionTests.cpp (original)
+++ qpid/trunk/qpid/cpp/src/tests/MessagingSessionTests.cpp Tue Aug 20 12:17:06 2013
@@ -1332,6 +1332,26 @@ QPID_AUTO_TEST_CASE(testReroutingRingQue
     }
 }
 
+QPID_AUTO_TEST_CASE(testReleaseOnPriorityQueue)
+{
+    MessagingFixture fix;
+    std::string queue("queue; {create:always, node:{x-declare:{auto-delete:True, arguments:{qpid.priorities:10}}}}");
+    std::string text("my message");
+    Sender sender = fix.session.createSender(queue);
+    sender.send(Message(text));
+    Receiver receiver = fix.session.createReceiver(queue);
+    Message msg;
+    for (uint i = 0; i < 10; ++i) {
+        if (receiver.fetch(msg, Duration::SECOND)) {
+            BOOST_CHECK_EQUAL(msg.getContent(), text);
+            fix.session.release(msg);
+        } else {
+            BOOST_FAIL("Released message not redelivered as expected.");
+        }
+    }
+    fix.session.acknowledge();
+}
+
 QPID_AUTO_TEST_SUITE_END()
 
 }} // namespace qpid::tests



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message