summaryrefslogtreecommitdiff
path: root/qpid/cpp/src
diff options
context:
space:
mode:
authorPavel Moravec <pmoravec@apache.org>2014-06-21 20:48:01 +0000
committerPavel Moravec <pmoravec@apache.org>2014-06-21 20:48:01 +0000
commitab365406ac0e22bef13ad9bcc4f29fce70b2d059 (patch)
tree05e6e4a4dbd9a2933e4776837696bff8b3f58b28 /qpid/cpp/src
parentedb54259c0b24e7060ec6d2d5f62349e6f2fb4f8 (diff)
downloadqpid-python-ab365406ac0e22bef13ad9bcc4f29fce70b2d059.tar.gz
QPID-5835: [C++ broker] Broker recovery forgets auto-delete flag on queues and exchanges
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1604455 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src')
-rw-r--r--qpid/cpp/src/qpid/broker/Exchange.cpp8
-rw-r--r--qpid/cpp/src/qpid/broker/Queue.cpp30
2 files changed, 28 insertions, 10 deletions
diff --git a/qpid/cpp/src/qpid/broker/Exchange.cpp b/qpid/cpp/src/qpid/broker/Exchange.cpp
index cfd31a16c1..c9ed648735 100644
--- a/qpid/cpp/src/qpid/broker/Exchange.cpp
+++ b/qpid/cpp/src/qpid/broker/Exchange.cpp
@@ -253,9 +253,11 @@ Exchange::shared_ptr Exchange::decode(ExchangeRegistry& exchanges, Buffer& buffe
// 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) const
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)
diff --git a/qpid/cpp/src/qpid/broker/Queue.cpp b/qpid/cpp/src/qpid/broker/Queue.cpp
index 07dbfccb95..39ad2021ed 100644
--- a/qpid/cpp/src/qpid/broker/Queue.cpp
+++ b/qpid/cpp/src/qpid/broker/Queue.cpp
@@ -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( QueueRegistry& queues, Buffer& buffer )
{
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;
}