diff options
author | Matthew Newhook <matthew@zeroc.com> | 2005-08-05 07:54:40 +0000 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2005-08-05 07:54:40 +0000 |
commit | 9ad872312904cb29cbe8f031711a81cb55af63f0 (patch) | |
tree | 4710da697e429148bdf01f5830bfcdaa3354f34a /cppe/src | |
parent | cleanup. (diff) | |
download | ice-9ad872312904cb29cbe8f031711a81cb55af63f0.tar.bz2 ice-9ad872312904cb29cbe8f031711a81cb55af63f0.tar.xz ice-9ad872312904cb29cbe8f031711a81cb55af63f0.zip |
cleanup.
Diffstat (limited to 'cppe/src')
-rw-r--r-- | cppe/src/IceE/Acceptor.h | 1 | ||||
-rwxr-xr-x | cppe/src/IceE/Communicator.cpp | 191 | ||||
-rwxr-xr-x | cppe/src/IceE/Connection.cpp | 140 | ||||
-rwxr-xr-x | cppe/src/IceE/Connector.h | 8 | ||||
-rw-r--r-- | cppe/src/IceE/Endpoint.h | 3 | ||||
-rw-r--r-- | cppe/src/IceE/Instance.cpp | 4 | ||||
-rw-r--r-- | cppe/src/IceE/Instance.h | 14 | ||||
-rw-r--r-- | cppe/src/IceE/LocatorInfo.h | 1 | ||||
-rw-r--r-- | cppe/src/IceE/Network.cpp | 1 | ||||
-rw-r--r-- | cppe/src/IceE/Network.h | 78 | ||||
-rw-r--r-- | cppe/src/IceE/ObjectAdapter.cpp | 33 | ||||
-rwxr-xr-x | cppe/src/IceE/OutgoingConnectionFactory.cpp | 4 | ||||
-rw-r--r-- | cppe/src/IceE/Properties.cpp | 2 | ||||
-rw-r--r-- | cppe/src/IceE/Proxy.cpp | 2 | ||||
-rw-r--r-- | cppe/src/IceE/ProxyFactory.cpp | 2 | ||||
-rw-r--r-- | cppe/src/IceE/ProxyFactory.h | 8 | ||||
-rw-r--r-- | cppe/src/IceE/Reference.cpp | 59 | ||||
-rw-r--r-- | cppe/src/IceE/Reference.h | 2 | ||||
-rw-r--r-- | cppe/src/IceE/ReferenceFactory.cpp | 67 | ||||
-rw-r--r-- | cppe/src/IceE/RoutingTable.h | 59 | ||||
-rw-r--r-- | cppe/src/IceE/RoutingTableF.h | 25 | ||||
-rw-r--r-- | cppe/src/IceE/Time.cpp | 16 | ||||
-rw-r--r-- | cppe/src/TcpTransport/TcpEndpoint.cpp | 2 | ||||
-rw-r--r-- | cppe/src/TcpTransport/Transceiver.cpp | 9 |
24 files changed, 412 insertions, 319 deletions
diff --git a/cppe/src/IceE/Acceptor.h b/cppe/src/IceE/Acceptor.h index 4d95d1c7bbe..500f54840c5 100644 --- a/cppe/src/IceE/Acceptor.h +++ b/cppe/src/IceE/Acceptor.h @@ -29,7 +29,6 @@ typedef int ssize_t; namespace IceInternal { -// XXX: EndpointF? class Endpoint; class ICEE_API Acceptor : public ::IceUtil::Shared diff --git a/cppe/src/IceE/Communicator.cpp b/cppe/src/IceE/Communicator.cpp index dcde42015b7..d0a63453f64 100755 --- a/cppe/src/IceE/Communicator.cpp +++ b/cppe/src/IceE/Communicator.cpp @@ -14,8 +14,9 @@ #include <IceE/ProxyFactory.h> #include <IceE/LoggerUtil.h> #include <IceE/LocalException.h> +
#ifndef ICEE_PURE_CLIENT -# include <IceE/ObjectAdapterFactory.h> +# include <IceE/ObjectAdapterFactory.h> #endif using namespace std; @@ -56,6 +57,53 @@ Ice::Communicator::destroy() } } +#ifndef ICEE_PURE_CLIENT + +void +Ice::Communicator::shutdown() +{ + ObjectAdapterFactoryPtr objectAdapterFactory; + + { + RecMutex::Lock sync(*this); + if(_destroyed) + { + throw CommunicatorDestroyedException(__FILE__, __LINE__); + } + objectAdapterFactory = _instance->objectAdapterFactory(); + } + + // + // We must call shutdown on the object adapter factory outside the + // synchronization, otherwise the communicator is blocked during + // shutdown. + // + objectAdapterFactory->shutdown(); +} + +void +Ice::Communicator::waitForShutdown() +{ + ObjectAdapterFactoryPtr objectAdapterFactory; + + { + RecMutex::Lock sync(*this); + if(_destroyed) + { + throw CommunicatorDestroyedException(__FILE__, __LINE__); + } + objectAdapterFactory = _instance->objectAdapterFactory(); + } + + // + // We must call waitForShutdown on the object adapter factory + // outside the synchronization, otherwise the communicator is + // blocked during shutdown. + // + objectAdapterFactory->waitForShutdown(); +} +#endif + ObjectPrx Ice::Communicator::stringToProxy(const string& s) const { @@ -78,6 +126,54 @@ Ice::Communicator::proxyToString(const ObjectPrx& proxy) const return _instance->proxyFactory()->proxyToString(proxy); } +#ifndef ICEE_PURE_CLIENT + +ObjectAdapterPtr +Ice::Communicator::createObjectAdapter(const string& name) +{ + RecMutex::Lock sync(*this); + if(_destroyed) + { + throw CommunicatorDestroyedException(__FILE__, __LINE__); + } +
+ assert(_instance); + ObjectAdapterPtr adapter = _instance->objectAdapterFactory()->createObjectAdapter(name); + + return adapter; +} + +ObjectAdapterPtr +Ice::Communicator::createObjectAdapterWithEndpoints(const string& name, const string& endpoints) +{ + getProperties()->setProperty(name + ".Endpoints", endpoints); + return createObjectAdapter(name); +} + +#endif + +void +Ice::Communicator::setDefaultContext(const Context& ctx) +{ + RecMutex::Lock sync(*this); + if(_destroyed) + { + throw CommunicatorDestroyedException(__FILE__, __LINE__); + } + _instance->setDefaultContext(ctx); +} + +Ice::Context +Ice::Communicator::getDefaultContext() const +{ + RecMutex::Lock sync(*this); + if(_destroyed) + { + throw CommunicatorDestroyedException(__FILE__, __LINE__); + } + return _instance->getDefaultContext(); +} + PropertiesPtr Ice::Communicator::getProperties() const { @@ -161,34 +257,14 @@ Ice::Communicator::setDefaultLocator(const LocatorPrx& locator) #endif -void -Ice::Communicator::setDefaultContext(const Context& ctx) -{ - RecMutex::Lock sync(*this); - if(_destroyed) - { - throw CommunicatorDestroyedException(__FILE__, __LINE__); - } - _instance->setDefaultContext(ctx); -} - -Ice::Context -Ice::Communicator::getDefaultContext() const -{ - RecMutex::Lock sync(*this); - if(_destroyed) - { - throw CommunicatorDestroyedException(__FILE__, __LINE__); - } - return _instance->getDefaultContext(); -} - #ifdef ICEE_HAS_BATCH + void Ice::Communicator::flushBatchRequests() { _instance->flushBatchRequests(); } + #endif Ice::Communicator::Communicator(const PropertiesPtr& properties) : @@ -236,72 +312,3 @@ Ice::Communicator::finishSetup(int& argc, char* argv[]) _instance->finishSetup(argc, argv); } -#ifndef ICEE_PURE_CLIENT - -void -Ice::Communicator::shutdown() -{ - ObjectAdapterFactoryPtr objectAdapterFactory; - - { - RecMutex::Lock sync(*this); - if(_destroyed) - { - throw CommunicatorDestroyedException(__FILE__, __LINE__); - } - objectAdapterFactory = _instance->objectAdapterFactory(); - } - - // - // We must call shutdown on the object adapter factory outside the - // synchronization, otherwise the communicator is blocked during - // shutdown. - // - objectAdapterFactory->shutdown(); -} - -void -Ice::Communicator::waitForShutdown() -{ - ObjectAdapterFactoryPtr objectAdapterFactory; - - { - RecMutex::Lock sync(*this); - if(_destroyed) - { - throw CommunicatorDestroyedException(__FILE__, __LINE__); - } - objectAdapterFactory = _instance->objectAdapterFactory(); - } - - // - // We must call waitForShutdown on the object adapter factory - // outside the synchronization, otherwise the communicator is - // blocked during shutdown. - // - objectAdapterFactory->waitForShutdown(); -} - -ObjectAdapterPtr -Ice::Communicator::createObjectAdapter(const string& name) -{ - RecMutex::Lock sync(*this); - if(_destroyed) - { - throw CommunicatorDestroyedException(__FILE__, __LINE__); - } -
- assert(_instance); - ObjectAdapterPtr adapter = _instance->objectAdapterFactory()->createObjectAdapter(name); - - return adapter; -} - -ObjectAdapterPtr -Ice::Communicator::createObjectAdapterWithEndpoints(const string& name, const string& endpoints) -{ - getProperties()->setProperty(name + ".Endpoints", endpoints); - return createObjectAdapter(name); -} - -#endif diff --git a/cppe/src/IceE/Connection.cpp b/cppe/src/IceE/Connection.cpp index 8dab232b559..ad4b5e89bd3 100755 --- a/cppe/src/IceE/Connection.cpp +++ b/cppe/src/IceE/Connection.cpp @@ -20,9 +20,11 @@ #include <IceE/Protocol.h> #include <IceE/ReferenceFactory.h> // For createProxy(). #include <IceE/ProxyFactory.h> // For createProxy(). +#include <IceE/BasicStream.h> + #ifndef ICEE_PURE_CLIENT -# include <IceE/ObjectAdapter.h> -# include <IceE/Incoming.h> +# include <IceE/ObjectAdapter.h> +# include <IceE/Incoming.h> #endif using namespace std; @@ -170,6 +172,7 @@ Ice::Connection::isFinished() const } #ifndef ICEE_PURE_CLIENT + void Ice::Connection::waitUntilHolding() const { @@ -180,6 +183,7 @@ Ice::Connection::waitUntilHolding() const wait(); } } + #endif void @@ -384,6 +388,7 @@ Ice::Connection::sendRequest(BasicStream* os, Outgoing* out) } #ifdef ICEE_HAS_BATCH + void Ice::Connection::prepareBatchRequest(BasicStream* os) { @@ -564,9 +569,11 @@ Ice::Connection::flushBatchRequests() notifyAll(); } } + #endif #ifndef ICEE_PURE_CLIENT + void Ice::Connection::sendResponse(BasicStream* os) { @@ -649,6 +656,7 @@ Ice::Connection::sendNoResponse() setState(StateClosed, ex); } } + #endif EndpointPtr @@ -657,6 +665,61 @@ Ice::Connection::endpoint() const return _endpoint; // No mutex protection necessary, _endpoint is immutable. } +#ifndef ICEE_PURE_CLIENT + +void +Ice::Connection::setAdapter(const ObjectAdapterPtr& adapter) +{ + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + + if(_exception.get()) + { + _exception->ice_throw(); + } + + assert(_state < StateClosing); + + // + // Before we set an adapter (or reset it) we wait until the + // dispatch count with any old adapter is zero. + // + // A deadlock can occur if we wait while an operation is + // outstanding on this adapter that holds a lock while + // calling this function (e.g., __getDelegate). + // + // In order to avoid such a deadlock, we only wait if the new + // adapter is different than the current one. + // + // TODO: Verify that this fix solves all cases. + // + if(_adapter.get() != adapter.get()) + { + while(_dispatchCount > 0) + { + wait(); + } + + _adapter = adapter; + if(_adapter) + { + _servantManager = _adapter->getServantManager(); + } + else + { + _servantManager = 0; + } + } +} + +ObjectAdapterPtr +Ice::Connection::getAdapter() const +{ + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); + return _adapter; +} + +#endif + ObjectPrx Ice::Connection::createProxy(const Identity& ident) const { @@ -952,23 +1015,23 @@ Ice::Connection::validate() _exception->ice_throw(); } -#ifndef ICEE_PURE_CLIENT +#ifdef ICEE_PURE_CLIENT { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); // - // We start out in holding state. + // We start out in active state. // - setState(StateHolding); + setState(StateActive); } #else { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); // - // We start out in active state. + // We start out in holding state. // - setState(StateActive); + setState(StateHolding); } #endif } @@ -1052,13 +1115,13 @@ Ice::Connection::setState(State state) // Can only switch from holding or not validated to // active. // -#ifndef ICEE_PURE_CLIENT - if(_state != StateHolding && _state != StateNotValidated) +#ifdef ICEE_PURE_CLIENT + if(_state != StateNotValidated) { return; } #else - if(_state != StateNotValidated) + if(_state != StateHolding && _state != StateNotValidated) { return; } @@ -1553,7 +1616,6 @@ Ice::Connection::run() wait(); } #endif - if(_state != StateClosed) { #ifndef ICEE_PURE_CLIENT @@ -1610,7 +1672,6 @@ Ice::Connection::run() #ifndef ICEE_PURE_CLIENT invokeAll(stream, invokeNum, requestId, servantManager, adapter); #endif - for(map<Int, Outgoing*>::iterator p = requests.begin(); p != requests.end(); ++p) { p->second->finished(*_exception.get()); // The exception is immutable at this point. @@ -1654,58 +1715,3 @@ Ice::Connection::ThreadPerConnection::run() _connection = 0; // Resolve cyclic dependency. } - -#ifndef ICEE_PURE_CLIENT - -void -Ice::Connection::setAdapter(const ObjectAdapterPtr& adapter) -{ - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - - if(_exception.get()) - { - _exception->ice_throw(); - } - - assert(_state < StateClosing); - - // - // Before we set an adapter (or reset it) we wait until the - // dispatch count with any old adapter is zero. - // - // A deadlock can occur if we wait while an operation is - // outstanding on this adapter that holds a lock while - // calling this function (e.g., __getDelegate). - // - // In order to avoid such a deadlock, we only wait if the new - // adapter is different than the current one. - // - // TODO: Verify that this fix solves all cases. - // - if(_adapter.get() != adapter.get()) - { - while(_dispatchCount > 0) - { - wait(); - } - - _adapter = adapter; - if(_adapter) - { - _servantManager = _adapter->getServantManager(); - } - else - { - _servantManager = 0; - } - } -} - -ObjectAdapterPtr -Ice::Connection::getAdapter() const -{ - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - return _adapter; -} -#endif - diff --git a/cppe/src/IceE/Connector.h b/cppe/src/IceE/Connector.h index 8848f065059..c3afb78098e 100755 --- a/cppe/src/IceE/Connector.h +++ b/cppe/src/IceE/Connector.h @@ -14,11 +14,11 @@ #include <IceE/TransceiverF.h> #include <IceE/InstanceF.h> #include <IceE/TraceLevelsF.h> -#include <IceE/LoggerF.h>
+#include <IceE/LoggerF.h> #include <IceE/Shared.h> -
-#ifdef _WIN32
-# include <winsock2.h>
+ +#ifdef _WIN32 +# include <winsock2.h> #else # include <netinet/in.h> // For struct sockaddr_in #endif diff --git a/cppe/src/IceE/Endpoint.h b/cppe/src/IceE/Endpoint.h index 13939d0e990..6615ba9364a 100644 --- a/cppe/src/IceE/Endpoint.h +++ b/cppe/src/IceE/Endpoint.h @@ -15,8 +15,9 @@ #include <IceE/TransceiverF.h> #include <IceE/InstanceF.h> #include <IceE/LoggerF.h> + #ifndef ICEE_PURE_CLIENT -# include <IceE/AcceptorF.h> +# include <IceE/AcceptorF.h> #endif #include <IceE/Shared.h> diff --git a/cppe/src/IceE/Instance.cpp b/cppe/src/IceE/Instance.cpp index 2fb87cfa5e5..3fdb8b17598 100644 --- a/cppe/src/IceE/Instance.cpp +++ b/cppe/src/IceE/Instance.cpp @@ -31,8 +31,6 @@ #include <IceE/StaticMutex.h> -#include <stdio.h> - #ifdef _WIN32 # include <winsock2.h> #else @@ -524,6 +522,7 @@ IceInternal::Instance::finishSetup(int& argc, char* argv[]) } #endif +#ifndef _WIN32_WCE // // Show process id if requested (but only once). // @@ -542,7 +541,6 @@ IceInternal::Instance::finishSetup(int& argc, char* argv[]) printProcessIdDone = true; } -#ifndef _WIN32_WCE if(printProcessId) { #ifdef _WIN32 diff --git a/cppe/src/IceE/Instance.h b/cppe/src/IceE/Instance.h index eda19d843a0..7826e8d6819 100644 --- a/cppe/src/IceE/Instance.h +++ b/cppe/src/IceE/Instance.h @@ -23,18 +23,11 @@ #include <IceE/OutgoingConnectionFactoryF.h> #include <IceE/EndpointFactoryF.h> #ifndef ICEE_PURE_CLIENT -# include <IceE/ObjectAdapterFactoryF.h> +# include <IceE/ObjectAdapterFactoryF.h> #endif #include <IceE/Shared.h> #include <IceE/RecMutex.h> -namespace Ice -{ - -class CommunicatorI; - -} - namespace IceInternal { @@ -70,16 +63,17 @@ public: #ifndef ICEE_PURE_CLIENT ObjectAdapterFactoryPtr objectAdapterFactory() const; #endif - + private: Instance(const Ice::CommunicatorPtr&, const Ice::PropertiesPtr&); virtual ~Instance(); + void finishSetup(int&, char*[]); void destroy(); friend class Ice::Communicator; - Ice::Communicator* _communicator; // Not a Ptr, to avoid having Instance and CommunicatorI point at each other. + Ice::Communicator* _communicator; // Not a Ptr, to avoid having Instance and Communicator point at each other. bool _destroyed; const Ice::PropertiesPtr _properties; // Immutable, not reset by destroy(). Ice::LoggerPtr _logger; // Not reset by destroy(). diff --git a/cppe/src/IceE/LocatorInfo.h b/cppe/src/IceE/LocatorInfo.h index 4a2c74c6d73..b5c94c66991 100644 --- a/cppe/src/IceE/LocatorInfo.h +++ b/cppe/src/IceE/LocatorInfo.h @@ -18,6 +18,7 @@ #include <IceE/LocatorF.h> #include <IceE/ProxyF.h> #include <IceE/EndpointF.h> + #include <IceE/Shared.h> #include <IceE/Mutex.h> diff --git a/cppe/src/IceE/Network.cpp b/cppe/src/IceE/Network.cpp index 7c9d8422412..68815363cc0 100644 --- a/cppe/src/IceE/Network.cpp +++ b/cppe/src/IceE/Network.cpp @@ -559,7 +559,6 @@ repeatConnect: } } - void IceInternal::getAddress(const string& host, int port, struct sockaddr_in& addr) { diff --git a/cppe/src/IceE/Network.h b/cppe/src/IceE/Network.h index 845b8dbeea9..efe8320ac72 100644 --- a/cppe/src/IceE/Network.h +++ b/cppe/src/IceE/Network.h @@ -69,49 +69,49 @@ typedef int socklen_t; namespace IceInternal { -ICEE_API bool interrupted(); -ICEE_API bool acceptInterrupted(); -ICEE_API bool noBuffers(); -ICEE_API bool wouldBlock(); -ICEE_API bool connectFailed(); -ICEE_API bool connectionRefused(); -ICEE_API bool connectInProgress(); -ICEE_API bool connectionLost(); -ICEE_API bool notConnected(); - -ICEE_API SOCKET createSocket(); -ICEE_API void closeSocket(SOCKET); -ICEE_API void shutdownSocketWrite(SOCKET); -ICEE_API void shutdownSocketReadWrite(SOCKET); - -ICEE_API void setBlock(SOCKET, bool); -ICEE_API void setTcpNoDelay(SOCKET); -ICEE_API void setKeepAlive(SOCKET); -ICEE_API void setSendBufferSize(SOCKET, int); - -ICEE_API void doBind(SOCKET, struct sockaddr_in&); -ICEE_API void doListen(SOCKET, int); -ICEE_API void doConnect(SOCKET, struct sockaddr_in&, int); -ICEE_API SOCKET doAccept(SOCKET, int); - -ICEE_API void getAddress(const std::string&, int, struct sockaddr_in&); -ICEE_API std::string getLocalHost(bool); -ICEE_API bool compareAddress(const struct sockaddr_in&, const struct sockaddr_in&); - -ICEE_API std::string errorToString(int); -ICEE_API std::string errorToStringDNS(int); -ICEE_API std::string lastErrorToString(); - -ICEE_API std::string fdToString(SOCKET); -ICEE_API std::string addrToString(const struct sockaddr_in&); +bool interrupted(); +bool acceptInterrupted(); +bool noBuffers(); +bool wouldBlock(); +bool connectFailed(); +bool connectionRefused(); +bool connectInProgress(); +bool connectionLost(); +bool notConnected(); + +SOCKET createSocket(); +void closeSocket(SOCKET); +void shutdownSocketWrite(SOCKET); +void shutdownSocketReadWrite(SOCKET); + +void setBlock(SOCKET, bool); +void setTcpNoDelay(SOCKET); +void setKeepAlive(SOCKET); +void setSendBufferSize(SOCKET, int); + +void doBind(SOCKET, struct sockaddr_in&); +void doListen(SOCKET, int); +void doConnect(SOCKET, struct sockaddr_in&, int); +SOCKET doAccept(SOCKET, int); + +void getAddress(const std::string&, int, struct sockaddr_in&); +std::string getLocalHost(bool); +bool compareAddress(const struct sockaddr_in&, const struct sockaddr_in&); + +std::string errorToString(int); +std::string errorToStringDNS(int); +std::string lastErrorToString(); + +std::string fdToString(SOCKET); +std::string addrToString(const struct sockaddr_in&); #ifdef _WIN32 -ICEE_API std::vector<struct sockaddr_in> getLocalAddresses(); -ICEE_API bool isLocalAddress(const struct sockaddr_in&); -ICEE_API bool isPeerLocal(SOCKET); +std::vector<struct sockaddr_in> getLocalAddresses(); +bool isLocalAddress(const struct sockaddr_in&); +bool isPeerLocal(SOCKET); #endif -ICEE_API int getSocketErrno(); +int getSocketErrno(); } diff --git a/cppe/src/IceE/ObjectAdapter.cpp b/cppe/src/IceE/ObjectAdapter.cpp index 59cd9bf1f14..f40f58b9be5 100644 --- a/cppe/src/IceE/ObjectAdapter.cpp +++ b/cppe/src/IceE/ObjectAdapter.cpp @@ -30,8 +30,6 @@ #endif #include <IceE/LoggerUtil.h> -#include <ctype.h> - using namespace std; using namespace Ice; using namespace IceInternal; @@ -440,11 +438,10 @@ Ice::ObjectAdapter::createReverseProxy(const Identity& ident) const return _instance->proxyFactory()->referenceToProxy(ref); } - +#ifdef ICEE_HAS_ROUTER void Ice::ObjectAdapter::addRouter(const RouterPrx& router) { -#ifdef ICEE_HAS_ROUTER IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); checkForDeactivation(); @@ -476,22 +473,20 @@ Ice::ObjectAdapter::addRouter(const RouterPrx& router) // _instance->outgoingConnectionFactory()->setRouter(routerInfo->getRouter()); } -#endif } +#endif - - +#ifdef ICEE_HAS_LOCATOR void Ice::ObjectAdapter::setLocator(const LocatorPrx& locator) { -#ifdef ICEE_HAS_LOCATOR IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); checkForDeactivation(); _locatorInfo = _instance->locatorManager()->get(locator); -#endif } +#endif bool Ice::ObjectAdapter::isLocal(const ObjectPrx& proxy) const @@ -708,13 +703,14 @@ Ice::ObjectAdapter::newProxy(const Identity& ident, const string& facet) const // // Create a reference with the adapter id. // - ReferencePtr ref = _instance->referenceFactory()->create(ident, Context(), facet, - Reference::ModeTwoway, _id #ifdef ICEE_HAS_ROUTER - , 0 + ReferencePtr ref = _instance->referenceFactory()->create(ident, Context(), facet,Reference::ModeTwoway, + _id, 0, _locatorInfo); + +#else + ReferencePtr ref = _instance->referenceFactory()->create(ident, Context(), facet, Reference::ModeTwoway, + _id, _locatorInfo); #endif - , _locatorInfo - ); // // Return a proxy for the reference. @@ -755,12 +751,13 @@ Ice::ObjectAdapter::newDirectProxy(const Identity& ident, const string& facet) c // // Create a reference and return a proxy for this reference. // - ReferencePtr ref = _instance->referenceFactory()->create(ident, Context(), facet, Reference::ModeTwoway, - endpoints #ifdef ICEE_HAS_ROUTER - , 0 + ReferencePtr ref = _instance->referenceFactory()->create(ident, Context(), facet, Reference::ModeTwoway, + endpoints, 0); +#else + ReferencePtr ref = _instance->referenceFactory()->create(ident, Context(), facet, Reference::ModeTwoway, + endpoints); #endif - ); return _instance->proxyFactory()->referenceToProxy(ref); } diff --git a/cppe/src/IceE/OutgoingConnectionFactory.cpp b/cppe/src/IceE/OutgoingConnectionFactory.cpp index 5b584692ac8..a00d79ec530 100755 --- a/cppe/src/IceE/OutgoingConnectionFactory.cpp +++ b/cppe/src/IceE/OutgoingConnectionFactory.cpp @@ -18,8 +18,8 @@ #include <IceE/RouterInfo.h> #include <IceE/LocalException.h> #include <IceE/Functional.h> -#ifdef ICEE_HAS_ROUTER
-# include <IceE/Reference.h>
+#ifdef ICEE_HAS_ROUTER +# include <IceE/Reference.h> #endif #include <list> diff --git a/cppe/src/IceE/Properties.cpp b/cppe/src/IceE/Properties.cpp index ee17b44b12c..3e628783745 100644 --- a/cppe/src/IceE/Properties.cpp +++ b/cppe/src/IceE/Properties.cpp @@ -7,8 +7,8 @@ // // ********************************************************************** -#include <IceE/StringUtil.h> #include <IceE/Properties.h> +#include <IceE/StringUtil.h> #include <IceE/Initialize.h> #include <IceE/LocalException.h> diff --git a/cppe/src/IceE/Proxy.cpp b/cppe/src/IceE/Proxy.cpp index 49aec674dd3..c10b7718c40 100644 --- a/cppe/src/IceE/Proxy.cpp +++ b/cppe/src/IceE/Proxy.cpp @@ -15,7 +15,7 @@ #include <IceE/BasicStream.h> #include <IceE/LocalException.h> #ifdef ICEE_HAS_ROUTER -# include <IceE/RouterInfo.h> +# include <IceE/RouterInfo.h> #endif using namespace std; diff --git a/cppe/src/IceE/ProxyFactory.cpp b/cppe/src/IceE/ProxyFactory.cpp index 9e80e0b6e09..a55c3b83233 100644 --- a/cppe/src/IceE/ProxyFactory.cpp +++ b/cppe/src/IceE/ProxyFactory.cpp @@ -12,7 +12,7 @@ #include <IceE/Time.h> #include <IceE/Instance.h> #include <IceE/Proxy.h> -#include <IceE/Reference.h>
+#include <IceE/Reference.h> #include <IceE/ReferenceFactory.h> #include <IceE/LocatorInfo.h> #include <IceE/Properties.h> diff --git a/cppe/src/IceE/ProxyFactory.h b/cppe/src/IceE/ProxyFactory.h index dcd5c7835d1..6d953b56227 100644 --- a/cppe/src/IceE/ProxyFactory.h +++ b/cppe/src/IceE/ProxyFactory.h @@ -15,7 +15,13 @@ #include <IceE/ReferenceF.h> #include <IceE/ProxyF.h> #include <IceE/Shared.h> -#include <IceE/Exception.h> + +namespace Ice +{ + +class LocalException; + +} namespace IceInternal { diff --git a/cppe/src/IceE/Reference.cpp b/cppe/src/IceE/Reference.cpp index 9dc3e4eaa8e..7177035c41d 100644 --- a/cppe/src/IceE/Reference.cpp +++ b/cppe/src/IceE/Reference.cpp @@ -14,15 +14,18 @@ #include <IceE/IdentityUtil.h> #include <IceE/Endpoint.h> #include <IceE/BasicStream.h> + #ifdef ICEE_HAS_ROUTER -# include <IceE/RouterInfo.h> -# include <IceE/Router.h> -# include <IceE/Connection.h>
+# include <IceE/RouterInfo.h> +# include <IceE/Router.h> +# include <IceE/Connection.h>
#endif + #ifdef ICEE_HAS_LOCATOR -# include <IceE/LocatorInfo.h> -# include <IceE/Locator.h> +# include <IceE/LocatorInfo.h> +# include <IceE/Locator.h> #endif + #include <IceE/Functional.h> #include <IceE/OutgoingConnectionFactory.h> #include <IceE/LoggerUtil.h> @@ -259,13 +262,12 @@ IceInternal::Reference::toString() const break; } -#ifdef ICEE_HAS_BATCH case ModeBatchOneway: { s += " -O"; break; } -#endif +
default: { // @@ -684,12 +686,13 @@ IceInternal::DirectReference::changeDefault() const if(loc) { LocatorInfoPtr newLocatorInfo = getInstance()->locatorManager()->get(loc); - return getInstance()->referenceFactory()->create(getIdentity(), Context(), "", ModeTwoway, - "" #ifdef ICEE_HAS_ROUTER - , 0 -#endif // ICEE_HAS_ROUTER - , newLocatorInfo); + return getInstance()->referenceFactory()->create(getIdentity(), Context(), "", ModeTwoway, + "", 0, newLocatorInfo); +#else + return getInstance()->referenceFactory()->create(getIdentity(), Context(), "", ModeTwoway, + "", newLocatorInfo); +#endif } else #endif // ICEE_HAS_LOCATOR @@ -706,12 +709,13 @@ IceInternal::DirectReference::changeLocator(const LocatorPrx& newLocator) const if(newLocator) { LocatorInfoPtr newLocatorInfo = getInstance()->locatorManager()->get(newLocator); - return getInstance()->referenceFactory()->create(getIdentity(), getContext(), getFacet(), getMode(), - "" #ifdef ICEE_HAS_ROUTER - , 0 + return getInstance()->referenceFactory()->create(getIdentity(), getContext(), getFacet(), getMode(), + "", 0, newLocatorInfo); +#else + return getInstance()->referenceFactory()->create(getIdentity(), getContext(), getFacet(), getMode(), + "", newLocatorInfo); #endif - , newLocatorInfo); } else { @@ -798,6 +802,7 @@ IceInternal::DirectReference::getConnection() const assert(connection); #if defined(ICEE_HAS_ROUTER) && !defined(ICEE_PURE_CLIENT) + // // If we have a router, set the object adapter for this router // (if any) to the new connection, so that callbacks from the @@ -809,7 +814,6 @@ IceInternal::DirectReference::getConnection() const } #endif - assert(connection); return connection; } @@ -885,8 +889,7 @@ IceInternal::IndirectReference::IndirectReference(const InstancePtr& inst, const #else IceInternal::IndirectReference::IndirectReference(const InstancePtr& inst, const Identity& ident, const Context& ctx, const string& fs, Mode md, - const string& adptid - , const LocatorInfoPtr& locInfo) + const string& adptid, const LocatorInfoPtr& locInfo) : Reference(inst, ident, ctx, fs, md), _adapterId(adptid), _locatorInfo(locInfo) @@ -909,12 +912,13 @@ IceInternal::IndirectReference::changeDefault() const LocatorPrx loc = getInstance()->referenceFactory()->getDefaultLocator(); if(!loc) { - return getInstance()->referenceFactory()->create(getIdentity(), Context(), "", ModeTwoway, - vector<EndpointPtr>() #ifdef ICEE_HAS_ROUTER - , getRouterInfo() + return getInstance()->referenceFactory()->create(getIdentity(), Context(), "", ModeTwoway, + vector<EndpointPtr>(), getRouterInfo()); +#else + return getInstance()->referenceFactory()->create(getIdentity(), Context(), "", ModeTwoway, + vector<EndpointPtr>()); #endif - ); } else { @@ -932,12 +936,13 @@ IceInternal::IndirectReference::changeLocator(const LocatorPrx& newLocator) cons // if(!newLocator) { - return getInstance()->referenceFactory()->create(getIdentity(), getContext(), getFacet(), getMode(), - vector<EndpointPtr>() #ifdef ICEE_HAS_ROUTER - , getRouterInfo() + return getInstance()->referenceFactory()->create(getIdentity(), getContext(), getFacet(), getMode(), + vector<EndpointPtr>(), getRouterInfo()); +#else + return getInstance()->referenceFactory()->create(getIdentity(), getContext(), getFacet(), getMode(), + vector<EndpointPtr>()); #endif - ); } else { diff --git a/cppe/src/IceE/Reference.h b/cppe/src/IceE/Reference.h index 3dc4e5e1b21..e41588fedcf 100644 --- a/cppe/src/IceE/Reference.h +++ b/cppe/src/IceE/Reference.h @@ -13,7 +13,7 @@ #include <IceE/ReferenceF.h> #include <IceE/EndpointF.h> #include <IceE/InstanceF.h> -#include <IceE/CommunicatorF.h>
+#include <IceE/CommunicatorF.h> #ifdef ICEE_HAS_ROUTER # include <IceE/RouterInfoF.h> # include <IceE/RouterF.h> diff --git a/cppe/src/IceE/ReferenceFactory.cpp b/cppe/src/IceE/ReferenceFactory.cpp index f68ad160a1a..f2eac7cae08 100644 --- a/cppe/src/IceE/ReferenceFactory.cpp +++ b/cppe/src/IceE/ReferenceFactory.cpp @@ -13,10 +13,10 @@ #include <IceE/IdentityUtil.h> #include <IceE/EndpointFactory.h> #ifdef ICEE_HAS_ROUTER -# include <IceE/RouterInfo.h> +# include <IceE/RouterInfo.h> #endif #ifdef ICEE_HAS_LOCATOR -# include <IceE/LocatorInfo.h> +# include <IceE/LocatorInfo.h> #endif #include <IceE/BasicStream.h> #include <IceE/StringUtil.h> @@ -75,11 +75,11 @@ IceInternal::ReferenceFactory::create(const Identity& ident, // // Create new reference // - return new DirectReference(_instance, ident, context, facet, mode, endpoints #ifdef ICEE_HAS_ROUTER - , routerInfo + return new DirectReference(_instance, ident, context, facet, mode, endpoints, routerInfo); +#else + return new DirectReference(_instance, ident, context, facet, mode, endpoints); #endif - ); } #ifdef ICEE_HAS_LOCATOR @@ -110,12 +110,11 @@ IceInternal::ReferenceFactory::create(const Identity& ident, // // Create new reference // - return new IndirectReference(_instance, ident, context, facet, mode, - adapterId #ifdef ICEE_HAS_ROUTER - , routerInfo + return new IndirectReference(_instance, ident, context, facet, mode, adapterId, routerInfo, locatorInfo); +#else + return new IndirectReference(_instance, ident, context, facet, mode, adapterId, locatorInfo); #endif - , locatorInfo); } #endif @@ -359,7 +358,6 @@ IceInternal::ReferenceFactory::create(const string& str) break; } -#ifdef ICEE_HAS_BATCH case 'O': { if(!argument.empty()) @@ -371,7 +369,6 @@ IceInternal::ReferenceFactory::create(const string& str) mode = Reference::ModeBatchOneway; break; } -#endif default: { @@ -392,12 +389,11 @@ IceInternal::ReferenceFactory::create(const string& str) if(beg == string::npos) { #ifdef ICEE_HAS_LOCATOR - return create(ident, Context(), facet, mode, "" -#ifdef ICEE_HAS_ROUTER - , routerInfo -#endif - , locatorInfo - ); +# ifdef ICEE_HAS_ROUTER + return create(ident, Context(), facet, mode, "", routerInfo, locatorInfo); +# else + return create(ident, Context(), facet, mode, "", locatorInfo); +# endif #else ProxyParseException ex(__FILE__, __LINE__); ex.str = str; @@ -452,13 +448,14 @@ IceInternal::ReferenceFactory::create(const string& str) } } - return create(ident, Context(), facet, mode, endpoints #ifdef ICEE_HAS_ROUTER - , routerInfo + return create(ident, Context(), facet, mode, endpoints , routerInfo); +#else + return create(ident, Context(), facet, mode, endpoints); #endif - ); break; } + #ifdef ICEE_HAS_LOCATOR case '@': { @@ -496,12 +493,12 @@ IceInternal::ReferenceFactory::create(const string& str) ex.str = str; throw ex; } - return create(ident, Context(), facet, mode, adapter + #ifdef ICEE_HAS_ROUTER - , routerInfo + return create(ident, Context(), facet, mode, adapter, routerInfo, locatorInfo); +#else + return create(ident, Context(), facet, mode, adapter, locatorInfo); #endif - , locatorInfo - ); break; } #endif @@ -556,9 +553,6 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s) #ifdef ICEE_HAS_ROUTER RouterInfoPtr routerInfo = _instance->routerManager()->get(getDefaultRouter()); #endif -#ifdef ICEE_HAS_LOCATOR - LocatorInfoPtr locatorInfo = _instance->locatorManager()->get(getDefaultLocator()); -#endif bool secure; s->read(secure); @@ -574,22 +568,23 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s) EndpointPtr endpoint = _instance->endpointFactory()->read(s); endpoints.push_back(endpoint); } - return create(ident, Context(), facet, mode, endpoints #ifdef ICEE_HAS_ROUTER - , routerInfo + return create(ident, Context(), facet, mode, endpoints, routerInfo); +#else + return create(ident, Context(), facet, mode, endpoints); #endif - ); } else { #ifdef ICEE_HAS_LOCATOR + LocatorInfoPtr locatorInfo = _instance->locatorManager()->get(getDefaultLocator()); s->read(adapterId); - return create(ident, Context(), facet, mode, adapterId -#ifdef ICEE_HAS_ROUTER - , routerInfo -#endif - , locatorInfo - ); +# ifdef ICEE_HAS_ROUTER + return create(ident, Context(), facet, mode, adapterId, routerInfo, locatorInfo); + +# else + return create(ident, Context(), facet, mode, adapterId, locatorInfo); +# endif #else throw ProxyUnmarshalException(__FILE__, __LINE__); #endif diff --git a/cppe/src/IceE/RoutingTable.h b/cppe/src/IceE/RoutingTable.h new file mode 100644 index 00000000000..14d9724491c --- /dev/null +++ b/cppe/src/IceE/RoutingTable.h @@ -0,0 +1,59 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICEE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#ifndef ICEE_ROUTING_TABLE_H +#define ICEE_ROUTING_TABLE_H + +#include <IceE/RoutingTableF.h> +#include <IceE/ProxyF.h> + +#include <IceE/Shared.h> +#include <IceE/Mutex.h> +#include <IceE/Identity.h> + +namespace Ice +{ + +struct Identity; + +} + +namespace IceInternal +{ + +class ICEE_API RoutingTable : public IceUtil::Shared, public IceUtil::Mutex +{ +public: + + RoutingTable(); + + // + // Clear the contents of the routing table. + // + void clear(); + + // + // Returns false if the Proxy exists already. + // + bool add(const Ice::ObjectPrx&); + + // + // Returns null if no Proxy exists for the given identity. + // + Ice::ObjectPrx get(const Ice::Identity&); + +private: + + std::map<Ice::Identity, Ice::ObjectPrx> _table; + std::map<Ice::Identity, Ice::ObjectPrx>::iterator _tableHint; +}; + +} + +#endif diff --git a/cppe/src/IceE/RoutingTableF.h b/cppe/src/IceE/RoutingTableF.h new file mode 100644 index 00000000000..f7a8e466f9e --- /dev/null +++ b/cppe/src/IceE/RoutingTableF.h @@ -0,0 +1,25 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICEE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#ifndef ICEE_ROUTING_TABLE_F_H +#define ICEE_ROUTING_TABLE_F_H + +#include <IceE/Handle.h> + +namespace IceInternal +{ + +class RoutingTable; +ICEE_API void incRef(RoutingTable*); +ICEE_API void decRef(RoutingTable*); +typedef IceInternal::Handle<RoutingTable> RoutingTablePtr; + +} + +#endif diff --git a/cppe/src/IceE/Time.cpp b/cppe/src/IceE/Time.cpp index ca6cc288b3e..15497a1f608 100644 --- a/cppe/src/IceE/Time.cpp +++ b/cppe/src/IceE/Time.cpp @@ -8,14 +8,14 @@ // ********************************************************************** #include <IceE/Time.h> -
+ #ifndef _WIN32_WCE -# if defined(_WIN32) -# include <sys/timeb.h> -# include <time.h> -# else -# include <sys/time.h> -# endif
+# if defined(_WIN32) +# include <sys/timeb.h> +# include <time.h> +# else +# include <sys/time.h> +# endif #endif using namespace IceUtil; @@ -28,7 +28,7 @@ IceUtil::Time::Time() : Time IceUtil::Time::now() { -#if defined(_WIN32_WCE)
+#if defined(_WIN32_WCE) // // Note that GetTickCount returns the number of ms since the // device was started. Time cannot be used to represent an diff --git a/cppe/src/TcpTransport/TcpEndpoint.cpp b/cppe/src/TcpTransport/TcpEndpoint.cpp index 92ddda9ac2c..22461413606 100644 --- a/cppe/src/TcpTransport/TcpEndpoint.cpp +++ b/cppe/src/TcpTransport/TcpEndpoint.cpp @@ -17,7 +17,7 @@ #include <IceE/DefaultsAndOverrides.h> #include <IceE/SafeStdio.h> #ifndef ICEE_PURE_CLIENT -# include <IceE/Acceptor.h> +# include <IceE/Acceptor.h> #endif using namespace std; diff --git a/cppe/src/TcpTransport/Transceiver.cpp b/cppe/src/TcpTransport/Transceiver.cpp index 82f53f36256..5b385b2a751 100644 --- a/cppe/src/TcpTransport/Transceiver.cpp +++ b/cppe/src/TcpTransport/Transceiver.cpp @@ -117,8 +117,8 @@ IceInternal::Transceiver::write(Buffer& buf, int timeout) { #ifdef _WIN32 repeatError: -#endif
- if(interrupted()) +#endif + if(interrupted()) { continue; } @@ -280,7 +280,7 @@ IceInternal::Transceiver::read(Buffer& buf, int timeout) { #ifdef _WIN32 repeatError: -#endif
+#endif if(interrupted()) { continue; @@ -435,10 +435,11 @@ IceInternal::Transceiver::Transceiver(const InstancePtr& instance, SOCKET fd) : _event = WSACreateEvent(); if(_event == 0) { + int error = WSAGetLastError(); closeSocket(_fd); SocketException ex(__FILE__, __LINE__); - ex.error = getSocketErrno(); + ex.error = error; throw ex; } |