summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorTed Ross <tross@apache.org>2010-03-05 21:10:26 +0000
committerTed Ross <tross@apache.org>2010-03-05 21:10:26 +0000
commit0c680d094fe9090fd60d7a76dd86416234547733 (patch)
treee3c7a81c17d0489e6cd672ea7e83ac8f1d5b1c89 /cpp
parent398343948b60572569c3b7b9dc535a40075d65d7 (diff)
downloadqpid-python-0c680d094fe9090fd60d7a76dd86416234547733.tar.gz
Fix QPID-2435. This patch removes the "publishNow" feature from the broker agent.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@919619 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/qpid/broker/Connection.cpp2
-rw-r--r--cpp/src/qpid/management/ManagementAgent.cpp55
-rw-r--r--cpp/src/qpid/management/ManagementAgent.h13
3 files changed, 30 insertions, 40 deletions
diff --git a/cpp/src/qpid/broker/Connection.cpp b/cpp/src/qpid/broker/Connection.cpp
index ca018ce4f8..2bb68b9f2d 100644
--- a/cpp/src/qpid/broker/Connection.cpp
+++ b/cpp/src/qpid/broker/Connection.cpp
@@ -101,7 +101,7 @@ Connection::Connection(ConnectionOutputHandler* out_, Broker& broker_, const std
if (agent != 0) {
mgmtObject = new _qmf::Connection(agent, this, parent, mgmtId, !isLink, false);
mgmtObject->set_shadow(shadow);
- agent->addObject(mgmtObject, objectId, true);
+ agent->addObject(mgmtObject, objectId);
}
ConnectionState::setUrl(mgmtId);
}
diff --git a/cpp/src/qpid/management/ManagementAgent.cpp b/cpp/src/qpid/management/ManagementAgent.cpp
index e4a3bd343f..dbe7062a25 100644
--- a/cpp/src/qpid/management/ManagementAgent.cpp
+++ b/cpp/src/qpid/management/ManagementAgent.cpp
@@ -185,11 +185,8 @@ void ManagementAgent::registerEvent (const string& packageName,
addClassLH(ManagementItem::CLASS_KIND_EVENT, pIter, eventName, md5Sum, schemaCall);
}
-ObjectId ManagementAgent::addObject(ManagementObject* object,
- uint64_t persistId,
- bool publishNow)
+ObjectId ManagementAgent::addObject(ManagementObject* object, uint64_t persistId)
{
- Mutex::ScopedLock lock (addLock);
uint16_t sequence;
uint64_t objectNum;
@@ -203,34 +200,22 @@ ObjectId ManagementAgent::addObject(ManagementObject* object,
ObjectId objId(0 /*flags*/ , sequence, brokerBank, 0, objectNum);
objId.setV2Key(*object);
-
object->setObjectId(objId);
- ManagementObjectMap::iterator destIter = newManagementObjects.find(objId);
- if (destIter != newManagementObjects.end()) {
- if (destIter->second->isDeleted()) {
- newDeletedManagementObjects.push_back(destIter->second);
- newManagementObjects.erase(destIter);
- } else {
- QPID_LOG(error, "ObjectId collision in addObject. class=" << object->getClassName() <<
- " key=" << objId.getV2Key());
- return objId;
- }
- }
- newManagementObjects[objId] = object;
- if (publishNow) {
-#define IMM_BUFSIZE 65536
- char rawBuf[IMM_BUFSIZE];
- Buffer msgBuffer(rawBuf, IMM_BUFSIZE);
-
- encodeHeader(msgBuffer, 'c');
- object->writeProperties(msgBuffer);
- uint32_t contentSize = msgBuffer.getPosition();
- stringstream key;
- key << "console.obj.1.0." << object->getPackageName() << "." << object->getClassName();
- msgBuffer.reset();
- sendBuffer(msgBuffer, contentSize, mExchange, key.str());
- QPID_LOG(trace, "SEND Immediate ContentInd to=" << key.str());
+ {
+ Mutex::ScopedLock lock (addLock);
+ ManagementObjectMap::iterator destIter = newManagementObjects.find(objId);
+ if (destIter != newManagementObjects.end()) {
+ if (destIter->second->isDeleted()) {
+ newDeletedManagementObjects.push_back(destIter->second);
+ newManagementObjects.erase(destIter);
+ } else {
+ QPID_LOG(error, "ObjectId collision in addObject. class=" << object->getClassName() <<
+ " key=" << objId.getV2Key());
+ return objId;
+ }
+ }
+ newManagementObjects[objId] = object;
}
return objId;
@@ -990,7 +975,7 @@ void ManagementAgent::handleAttachRequestLH (Buffer& inBuffer, string replyToKey
agent->mgmtObject->set_systemId (systemId);
agent->mgmtObject->set_brokerBank (brokerBank);
agent->mgmtObject->set_agentBank (assignedBank);
- addObject (agent->mgmtObject, 0, true);
+ addObject (agent->mgmtObject, 0);
remoteAgents[connectionRef] = agent;
QPID_LOG(trace, "Remote Agent registered bank=[" << brokerBank << "." << assignedBank << "] replyTo=" << replyToKey);
@@ -1368,13 +1353,13 @@ ManagementObjectMap::iterator ManagementAgent::numericFind(const ObjectId& oid)
void ManagementAgent::setAllocator(std::auto_ptr<IdAllocator> a)
{
- Mutex::ScopedLock lock (addLock);
+ Mutex::ScopedLock lock (userLock);
allocator = a;
}
uint64_t ManagementAgent::allocateId(Manageable* object)
{
- Mutex::ScopedLock lock (addLock);
+ Mutex::ScopedLock lock (userLock);
if (allocator.get()) return allocator->getIdFor(object);
return 0;
}
@@ -1467,7 +1452,7 @@ void ManagementAgent::RemoteAgent::decode(qpid::framing::Buffer& inBuf) {
connectionRef.decode(inBuf);
mgmtObject = new _qmf::Agent(&agent, this);
mgmtObject->readProperties(inBuf);
- agent.addObject(mgmtObject, 0, true);
+ agent.addObject(mgmtObject, 0);
}
uint32_t ManagementAgent::RemoteAgent::encodedSize() const {
@@ -1501,7 +1486,7 @@ void ManagementAgent::importAgents(qpid::framing::Buffer& inBuf) {
id.decode(inBuf);
std::auto_ptr<RemoteAgent> agent(new RemoteAgent(*this));
agent->decode(inBuf);
- addObject (agent->mgmtObject, 0, false);
+ addObject (agent->mgmtObject, 0);
remoteAgents[agent->connectionRef] = agent.release();
}
}
diff --git a/cpp/src/qpid/management/ManagementAgent.h b/cpp/src/qpid/management/ManagementAgent.h
index cea6cc66bc..5ea951d8d0 100644
--- a/cpp/src/qpid/management/ManagementAgent.h
+++ b/cpp/src/qpid/management/ManagementAgent.h
@@ -87,8 +87,7 @@ public:
uint8_t* md5Sum,
ManagementObject::writeSchemaCall_t schemaCall);
QPID_BROKER_EXTERN ObjectId addObject (ManagementObject* object,
- uint64_t persistId = 0,
- bool publishNow = false);
+ uint64_t persistId = 0);
QPID_BROKER_EXTERN void raiseEvent(const ManagementEvent& event,
severity_t severity = SEV_DEFAULT);
QPID_BROKER_EXTERN void clientAdded (const std::string& routingKey);
@@ -231,8 +230,14 @@ private:
ManagementObjectVector newDeletedManagementObjects;
framing::Uuid uuid;
- sys::Mutex addLock;
- sys::Mutex userLock;
+
+ //
+ // Lock hierarchy: If a thread needs to take both addLock and userLock,
+ // it MUST take userLock first, then addLock.
+ //
+ sys::Mutex userLock;
+ sys::Mutex addLock;
+
qpid::broker::Exchange::shared_ptr mExchange;
qpid::broker::Exchange::shared_ptr dExchange;
std::string dataDir;