diff options
| author | Stephen D. Huston <shuston@apache.org> | 2009-05-04 21:44:59 +0000 |
|---|---|---|
| committer | Stephen D. Huston <shuston@apache.org> | 2009-05-04 21:44:59 +0000 |
| commit | abdf1ec27a07d5067e185e970c8229e06df28823 (patch) | |
| tree | 50886fef8a3cc5e64c5299d7a09707c2d7ad227c /cpp/src/qpid/agent | |
| parent | 3c20c531712c067b040320d2fc48af915c8de112 (diff) | |
| download | qpid-python-abdf1ec27a07d5067e185e970c8229e06df28823.tar.gz | |
Add portability support for QMF agent, thanks to Pete McKinnon - partially fixes QPID-1731
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@771457 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/agent')
| -rw-r--r-- | cpp/src/qpid/agent/ManagementAgent.h | 7 | ||||
| -rw-r--r-- | cpp/src/qpid/agent/ManagementAgentImpl.cpp | 43 | ||||
| -rw-r--r-- | cpp/src/qpid/agent/ManagementAgentImpl.h | 4 | ||||
| -rw-r--r-- | cpp/src/qpid/agent/QmfAgentImportExport.h | 33 |
4 files changed, 57 insertions, 30 deletions
diff --git a/cpp/src/qpid/agent/ManagementAgent.h b/cpp/src/qpid/agent/ManagementAgent.h index c94291c9e7..1ab888c4ef 100644 --- a/cpp/src/qpid/agent/ManagementAgent.h +++ b/cpp/src/qpid/agent/ManagementAgent.h @@ -20,6 +20,7 @@ // under the License. // +#include "QmfAgentImportExport.h" #include "qpid/management/ManagementObject.h" #include "qpid/management/ManagementEvent.h" #include "qpid/management/Manageable.h" @@ -35,9 +36,9 @@ class ManagementAgent class Singleton { public: - Singleton(bool disableManagement = false); - ~Singleton(); - static ManagementAgent* getInstance(); + QMF_AGENT_EXTERN Singleton(bool disableManagement = false); + QMF_AGENT_EXTERN ~Singleton(); + QMF_AGENT_EXTERN static ManagementAgent* getInstance(); private: static sys::Mutex lock; static bool disabled; diff --git a/cpp/src/qpid/agent/ManagementAgentImpl.cpp b/cpp/src/qpid/agent/ManagementAgentImpl.cpp index 7c70c12213..6c6fbdfe3c 100644 --- a/cpp/src/qpid/agent/ManagementAgentImpl.cpp +++ b/cpp/src/qpid/agent/ManagementAgentImpl.cpp @@ -21,14 +21,12 @@ #include "qpid/management/Manageable.h" #include "qpid/management/ManagementObject.h" #include "qpid/log/Statement.h" +#include "qpid/sys/PipeHandle.h" #include "ManagementAgentImpl.h" #include <list> #include <string.h> #include <stdlib.h> #include <sys/types.h> -#include <sys/socket.h> -#include <unistd.h> -#include <fcntl.h> #include <iostream> #include <fstream> @@ -80,7 +78,7 @@ ManagementAgent* ManagementAgent::Singleton::getInstance() const string ManagementAgentImpl::storeMagicNumber("MA02"); ManagementAgentImpl::ManagementAgentImpl() : - extThread(false), writeFd(-1), readFd(-1), + extThread(false), initialized(false), connected(false), lastFailure("never connected"), clientWasAdded(true), requestedBrokerBank(0), requestedAgentBank(0), assignedBrokerBank(0), assignedAgentBank(0), bootSequence(0), @@ -112,6 +110,10 @@ ManagementAgentImpl::~ManagementAgentImpl() } managementObjects.clear(); } + if (pipeHandle) { + delete pipeHandle; + pipeHandle = 0; + } } void ManagementAgentImpl::init(const string& brokerHost, @@ -134,7 +136,7 @@ void ManagementAgentImpl::init(const string& brokerHost, init(settings, intervalSeconds, useExternalThread, _storeFile); } -void ManagementAgentImpl::init(const client::ConnectionSettings& settings, +void ManagementAgentImpl::init(const qpid::client::ConnectionSettings& settings, uint16_t intervalSeconds, bool useExternalThread, const std::string& _storeFile) @@ -149,18 +151,9 @@ void ManagementAgentImpl::init(const client::ConnectionSettings& settings, connectionSettings = settings; // TODO: Abstract the socket calls for portability + // qpid::sys::PipeHandle to create a pipe if (extThread) { - int pair[2]; - int result = socketpair(PF_UNIX, SOCK_STREAM, 0, pair); - if (result == -1) { - return; - } - writeFd = pair[0]; - readFd = pair[1]; - - // Set the readFd to non-blocking - int flags = fcntl(readFd, F_GETFL); - fcntl(readFd, F_SETFL, flags | O_NONBLOCK); + pipeHandle = new PipeHandle(true); } retrieveData(); @@ -175,7 +168,7 @@ void ManagementAgentImpl::init(const client::ConnectionSettings& settings, void ManagementAgentImpl::registerClass(const string& packageName, const string& className, uint8_t* md5Sum, - management::ManagementObject::writeSchemaCall_t schemaCall) + qpid::management::ManagementObject::writeSchemaCall_t schemaCall) { Mutex::ScopedLock lock(agentLock); PackageMap::iterator pIter = findOrAddPackage(packageName); @@ -185,7 +178,7 @@ void ManagementAgentImpl::registerClass(const string& packageName, void ManagementAgentImpl::registerEvent(const string& packageName, const string& eventName, uint8_t* md5Sum, - management::ManagementObject::writeSchemaCall_t schemaCall) + qpid::management::ManagementObject::writeSchemaCall_t schemaCall) { Mutex::ScopedLock lock(agentLock); PackageMap::iterator pIter = findOrAddPackage(packageName); @@ -247,15 +240,15 @@ uint32_t ManagementAgentImpl::pollCallbacks(uint32_t callLimit) delete item; } } - - uint8_t rbuf[100]; - while (read(readFd, rbuf, 100) > 0) ; // Consume all signaling bytes + + char rbuf[100]; + while (pipeHandle->read(rbuf, 100) > 0) ; // Consume all signaling bytes return methodQueue.size(); } int ManagementAgentImpl::getSignalFd(void) { - return readFd; + return pipeHandle->getReadHandle(); } void ManagementAgentImpl::startProtocol() @@ -536,7 +529,7 @@ void ManagementAgentImpl::handleMethodRequest(Buffer& inBuffer, uint32_t sequenc inBuffer.getRawData(body, inBuffer.available()); methodQueue.push_back(new QueuedMethod(sequence, replyTo, body)); - write(writeFd, "X", 1); + pipeHandle->write("X", 1); } else { invokeMethodRequest(inBuffer, sequence, replyTo); } @@ -631,7 +624,7 @@ void ManagementAgentImpl::addClassLocal(uint8_t classKind, PackageMap::iterator pIter, const string& className, uint8_t* md5Sum, - management::ManagementObject::writeSchemaCall_t schemaCall) + qpid::management::ManagementObject::writeSchemaCall_t schemaCall) { SchemaClassKey key; ClassMap& cMap = pIter->second; @@ -906,7 +899,7 @@ bool ManagementAgentImpl::ConnectionThread::isSleeping() const void ManagementAgentImpl::PublishThread::run() { while (true) { - ::sleep(agent.getInterval()); agent.periodicProcessing(); + ::sleep(agent.getInterval()); } } diff --git a/cpp/src/qpid/agent/ManagementAgentImpl.h b/cpp/src/qpid/agent/ManagementAgentImpl.h index 53eb690ba8..cc668b4995 100644 --- a/cpp/src/qpid/agent/ManagementAgentImpl.h +++ b/cpp/src/qpid/agent/ManagementAgentImpl.h @@ -31,6 +31,7 @@ #include "qpid/sys/Thread.h" #include "qpid/sys/Runnable.h" #include "qpid/sys/Mutex.h" +#include "qpid/sys/PipeHandle.h" #include "qpid/framing/Uuid.h" #include <iostream> #include <sstream> @@ -132,8 +133,7 @@ class ManagementAgentImpl : public ManagementAgent, public client::MessageListen uint16_t interval; bool extThread; - int writeFd; - int readFd; + sys::PipeHandle* pipeHandle; uint64_t nextObjectId; std::string storeFile; sys::Mutex agentLock; diff --git a/cpp/src/qpid/agent/QmfAgentImportExport.h b/cpp/src/qpid/agent/QmfAgentImportExport.h new file mode 100644 index 0000000000..9eee4a18fd --- /dev/null +++ b/cpp/src/qpid/agent/QmfAgentImportExport.h @@ -0,0 +1,33 @@ +#ifndef QMF_AGENT_IMPORT_EXPORT_H +#define QMF_AGENT_IMPORT_EXPORT_H + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#if defined(WIN32) && !defined(QPID_DECLARE_STATIC) +#if defined(QMF_AGENT_EXPORT) || defined (qmfagent_EXPORTS) +#define QMF_AGENT_EXTERN __declspec(dllexport) +#else +#define QMF_AGENT_EXTERN __declspec(dllimport) +#endif +#else +#define QMF_AGENT_EXTERN +#endif + +#endif |
