Author: pmoravec
Date: Sat Jun 21 20:48:01 2014
New Revision: 1604455

URL: http://svn.apache.org/r1604455
Log:
QPID-5835: [C++ broker] Broker recovery forgets auto-delete flag on queues and 
exchanges

Modified:
    qpid/trunk/qpid/cpp/src/qpid/broker/Exchange.cpp
    qpid/trunk/qpid/cpp/src/qpid/broker/Queue.cpp

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/Exchange.cpp
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/Exchange.cpp?rev=1604455&r1=1604454&r2=1604455&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/Exchange.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/Exchange.cpp Sat Jun 21 20:48:01 2014
@@ -253,9 +253,11 @@ Exchange::shared_ptr Exchange::decode(Ex
     // For backwards compatibility on restoring exchanges from before the 
alt-exchange update, perform check
     if (buffer.available())
         buffer.getShortString(altName);
+    // Check autodelete bool; for backwards compatibility if the bool isn't 
present, assume false
+    bool _autodelete = ((buffer.available()) && (buffer.getInt8()));
 
     try {
-        Exchange::shared_ptr exch = exchanges.declare(name, type, durable, 
false, args).first;
+        Exchange::shared_ptr exch = exchanges.declare(name, type, durable, 
_autodelete, args).first;
         exch->sequenceNo = args.getAsInt64(qpidSequenceCounter);
         exch->alternateName.assign(altName);
         return exch;
@@ -274,6 +276,7 @@ void Exchange::encode(Buffer& buffer) co
         args.setInt64(std::string(qpidSequenceCounter),sequenceNo);
     buffer.put(args);
     buffer.putShortString(alternate.get() ? alternate->getName() : string(""));
+    buffer.putInt8(isAutoDelete());
 }
 
 uint32_t Exchange::encodedSize() const
@@ -282,7 +285,8 @@ uint32_t Exchange::encodedSize() const
         + 1 /*durable*/
         + getType().size() + 1/*short string size*/
         + (alternate.get() ? alternate->getName().size() : 0) + 1/*short 
string size*/
-        + args.encodedSize();
+        + args.encodedSize()
+        + 1 /* autodelete bool as int_8 */;
 }
 
 void Exchange::recoveryComplete(ExchangeRegistry& exchanges)

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/Queue.cpp
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/Queue.cpp?rev=1604455&r1=1604454&r2=1604455&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/Queue.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/Queue.cpp Sat Jun 21 20:48:01 2014
@@ -1187,6 +1187,7 @@ void Queue::encode(Buffer& buffer) const
     buffer.put(encodableSettings);
     buffer.putShortString(alternateExchange.get() ? 
alternateExchange->getName() : std::string(""));
     buffer.putShortString(userId);
+    buffer.putInt8(isAutoDelete());
 }
 
 uint32_t Queue::encodedSize() const
@@ -1194,6 +1195,7 @@ uint32_t Queue::encodedSize() const
     return name.size() + 1/*short string size octet*/
         + (alternateExchange.get() ? alternateExchange->getName().size() : 0) 
+ 1 /* short string */
         + userId.size() + 1 /* short string */
+        + 1 /* autodelete flag */
         + encodableSettings.encodedSize();
 }
 
@@ -1207,25 +1209,37 @@ Queue::shared_ptr Queue::restore( QueueR
 {
     string name;
     string _userId;
-    buffer.getShortString(name);
     FieldTable ft;
-    buffer.get(ft);
     boost::shared_ptr<Exchange> alternate;
-    QueueSettings settings(true, false);
+    QueueSettings settings(true, false); // settings.autodelete might be 
overwritten
+    string altExch;
+    bool has_userId = false;
+    bool has_altExch = false;
+
+    buffer.getShortString(name);
+    buffer.get(ft);
     settings.populate(ft, settings.storeSettings);
-    std::pair<Queue::shared_ptr, bool> result = queues.declare(name, settings, 
alternate, true);
+    //get alternate exchange
     if (buffer.available()) {
-        string altExch;
         buffer.getShortString(altExch);
-        result.first->alternateExchangeName.assign(altExch);
+        has_altExch = true;
     }
-
     //get userId of queue's creator; ACL counters for userId are done after 
ACL plugin is initialized
     if (buffer.available()) {
         buffer.getShortString(_userId);
-        result.first->setOwningUser(_userId);
+        has_userId = true;
+    }
+    //get autodelete flag
+    if (buffer.available()) {
+        settings.autodelete = buffer.getInt8();
     }
 
+    std::pair<Queue::shared_ptr, bool> result = queues.declare(name, settings, 
alternate, true);
+    if (has_altExch)
+        result.first->alternateExchangeName.assign(altExch);
+    if (has_userId)
+        result.first->setOwningUser(_userId);
+
     return result.first;
 }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to