qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tr...@apache.org
Subject svn commit: r919619 - in /qpid/trunk/qpid/cpp/src/qpid: broker/Connection.cpp management/ManagementAgent.cpp management/ManagementAgent.h
Date Fri, 05 Mar 2010 21:10:26 GMT
Author: tross
Date: Fri Mar  5 21:10:26 2010
New Revision: 919619

URL: http://svn.apache.org/viewvc?rev=919619&view=rev
Log:
Fix QPID-2435.  This patch removes the "publishNow" feature from the broker agent.

Modified:
    qpid/trunk/qpid/cpp/src/qpid/broker/Connection.cpp
    qpid/trunk/qpid/cpp/src/qpid/management/ManagementAgent.cpp
    qpid/trunk/qpid/cpp/src/qpid/management/ManagementAgent.h

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/Connection.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/Connection.cpp?rev=919619&r1=919618&r2=919619&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/Connection.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/Connection.cpp Fri Mar  5 21:10:26 2010
@@ -101,7 +101,7 @@
         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);
     }

Modified: qpid/trunk/qpid/cpp/src/qpid/management/ManagementAgent.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/management/ManagementAgent.cpp?rev=919619&r1=919618&r2=919619&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/management/ManagementAgent.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/management/ManagementAgent.cpp Fri Mar  5 21:10:26 2010
@@ -185,11 +185,8 @@
     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 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 @@
     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 @@
 
 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 @@
     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 @@
         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();
     }
 }

Modified: qpid/trunk/qpid/cpp/src/qpid/management/ManagementAgent.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/management/ManagementAgent.h?rev=919619&r1=919618&r2=919619&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/management/ManagementAgent.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/management/ManagementAgent.h Fri Mar  5 21:10:26 2010
@@ -87,8 +87,7 @@
                                              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 @@
     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;



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message