summaryrefslogtreecommitdiff
path: root/cpp/src/Ice
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/Ice')
-rw-r--r--cpp/src/Ice/Application.cpp624
-rw-r--r--cpp/src/Ice/BasicStream.cpp1148
-rw-r--r--cpp/src/Ice/Buffer.cpp20
-rw-r--r--cpp/src/Ice/CommunicatorI.cpp146
-rw-r--r--cpp/src/Ice/ConnectionFactory.cpp1436
-rw-r--r--cpp/src/Ice/ConnectionFactory.h18
-rw-r--r--cpp/src/Ice/ConnectionI.cpp3414
-rw-r--r--cpp/src/Ice/ConnectionI.h36
-rw-r--r--cpp/src/Ice/ConnectionMonitor.cpp104
-rwxr-xr-xcpp/src/Ice/DLLMain.cpp2
-rw-r--r--cpp/src/Ice/DefaultsAndOverrides.cpp22
-rw-r--r--cpp/src/Ice/Direct.cpp110
-rw-r--r--cpp/src/Ice/DynamicLibrary.cpp32
-rw-r--r--cpp/src/Ice/EndpointFactoryManager.cpp4
-rwxr-xr-xcpp/src/Ice/EventLoggerI.cpp2
-rw-r--r--cpp/src/Ice/Exception.cpp78
-rw-r--r--cpp/src/Ice/FactoryTableDef.cpp106
-rwxr-xr-xcpp/src/Ice/GC.cpp302
-rw-r--r--cpp/src/Ice/IdentityUtil.cpp4
-rw-r--r--cpp/src/Ice/ImplicitContextI.cpp308
-rw-r--r--cpp/src/Ice/Incoming.cpp610
-rw-r--r--cpp/src/Ice/IncomingAsync.cpp120
-rw-r--r--cpp/src/Ice/Initialize.cpp74
-rw-r--r--cpp/src/Ice/Instance.cpp684
-rw-r--r--cpp/src/Ice/Instance.h8
-rw-r--r--cpp/src/Ice/LocatorInfo.cpp436
-rw-r--r--cpp/src/Ice/LoggerI.cpp6
-rw-r--r--cpp/src/Ice/LoggerUtil.cpp8
-rw-r--r--cpp/src/Ice/Network.cpp1164
-rw-r--r--cpp/src/Ice/Object.cpp110
-rw-r--r--cpp/src/Ice/ObjectAdapterFactory.cpp146
-rw-r--r--cpp/src/Ice/ObjectAdapterI.cpp994
-rw-r--r--cpp/src/Ice/ObjectAdapterI.h6
-rw-r--r--cpp/src/Ice/ObjectFactoryManager.cpp102
-rw-r--r--cpp/src/Ice/Outgoing.cpp714
-rw-r--r--cpp/src/Ice/OutgoingAsync.cpp596
-rw-r--r--cpp/src/Ice/PluginManagerI.cpp198
-rw-r--r--cpp/src/Ice/PropertiesI.cpp142
-rw-r--r--cpp/src/Ice/Protocol.cpp2
-rw-r--r--cpp/src/Ice/Proxy.cpp974
-rw-r--r--cpp/src/Ice/ProxyFactory.cpp190
-rw-r--r--cpp/src/Ice/Reference.cpp904
-rw-r--r--cpp/src/Ice/Reference.h30
-rw-r--r--cpp/src/Ice/ReferenceFactory.cpp656
-rw-r--r--cpp/src/Ice/ReferenceFactory.h10
-rw-r--r--cpp/src/Ice/RouterInfo.cpp164
-rw-r--r--cpp/src/Ice/ServantManager.cpp198
-rwxr-xr-xcpp/src/Ice/Service.cpp366
-rw-r--r--cpp/src/Ice/SharedContext.h4
-rw-r--r--cpp/src/Ice/SliceChecksums.cpp8
-rwxr-xr-xcpp/src/Ice/StringConverter.cpp66
-rw-r--r--cpp/src/Ice/TcpAcceptor.cpp40
-rw-r--r--cpp/src/Ice/TcpConnector.cpp8
-rw-r--r--cpp/src/Ice/TcpEndpointI.cpp352
-rw-r--r--cpp/src/Ice/TcpTransceiver.cpp452
-rw-r--r--cpp/src/Ice/ThreadPool.cpp1192
-rw-r--r--cpp/src/Ice/ThreadPool.h8
-rw-r--r--cpp/src/Ice/TraceUtil.cpp514
-rw-r--r--cpp/src/Ice/UdpEndpointI.cpp602
-rw-r--r--cpp/src/Ice/UdpTransceiver.cpp460
-rw-r--r--cpp/src/Ice/UnknownEndpointI.cpp16
61 files changed, 10625 insertions, 10625 deletions
diff --git a/cpp/src/Ice/Application.cpp b/cpp/src/Ice/Application.cpp
index ae9a1ea7c4e..adcd5ddfb69 100644
--- a/cpp/src/Ice/Application.cpp
+++ b/cpp/src/Ice/Application.cpp
@@ -68,26 +68,26 @@ holdInterruptCallback(int signal)
{
CtrlCHandlerCallback callback = 0;
{
- StaticMutex::Lock lock(_mutex);
- while(!_released)
- {
- _condVar->wait(lock);
- }
-
- if(_destroyed)
- {
- //
- // Being destroyed by main thread
- //
- return;
- }
- assert(_ctrlCHandler != 0);
- callback = _ctrlCHandler->getCallback();
+ StaticMutex::Lock lock(_mutex);
+ while(!_released)
+ {
+ _condVar->wait(lock);
+ }
+
+ if(_destroyed)
+ {
+ //
+ // Being destroyed by main thread
+ //
+ return;
+ }
+ assert(_ctrlCHandler != 0);
+ callback = _ctrlCHandler->getCallback();
}
if(callback != 0)
{
- callback(signal);
+ callback(signal);
}
}
@@ -95,60 +95,60 @@ static void
destroyOnInterruptCallback(int signal)
{
{
- StaticMutex::Lock lock(_mutex);
- if(_destroyed)
- {
- //
- // Being destroyed by main thread
- //
- return;
- }
- if(_nohup && signal == SIGHUP)
- {
- return;
- }
-
- assert(!_callbackInProgress);
- _callbackInProgress = true;
- _interrupted = true;
- _destroyed = true;
- }
-
+ StaticMutex::Lock lock(_mutex);
+ if(_destroyed)
+ {
+ //
+ // Being destroyed by main thread
+ //
+ return;
+ }
+ if(_nohup && signal == SIGHUP)
+ {
+ return;
+ }
+
+ assert(!_callbackInProgress);
+ _callbackInProgress = true;
+ _interrupted = true;
+ _destroyed = true;
+ }
+
assert(_communicator != 0);
try
{
- _communicator->destroy();
+ _communicator->destroy();
}
catch(const IceUtil::Exception& ex)
{
- cerr << _appName << " (while destroying in response to signal " << signal
- << "): " << ex << endl;
+ cerr << _appName << " (while destroying in response to signal " << signal
+ << "): " << ex << endl;
}
catch(const std::exception& ex)
{
- cerr << _appName << " (while destroying in response to signal " << signal
- << "): std::exception: " << ex.what() << endl;
+ cerr << _appName << " (while destroying in response to signal " << signal
+ << "): std::exception: " << ex.what() << endl;
}
catch(const std::string& msg)
{
- cerr << _appName << " (while destroying in response to signal " << signal
- << "): " << msg << endl;
+ cerr << _appName << " (while destroying in response to signal " << signal
+ << "): " << msg << endl;
}
catch(const char * msg)
{
- cerr << _appName << " (while destroying in response to signal " << signal
- << "): " << msg << endl;
+ cerr << _appName << " (while destroying in response to signal " << signal
+ << "): " << msg << endl;
}
catch(...)
{
- cerr << _appName << " (while destroying in response to signal " << signal
- << "): unknown exception" << endl;
+ cerr << _appName << " (while destroying in response to signal " << signal
+ << "): unknown exception" << endl;
}
{
- StaticMutex::Lock lock(_mutex);
- _callbackInProgress = false;
+ StaticMutex::Lock lock(_mutex);
+ _callbackInProgress = false;
}
_condVar->signal();
}
@@ -158,57 +158,57 @@ static void
shutdownOnInterruptCallback(int signal)
{
{
- StaticMutex::Lock lock(_mutex);
- if(_destroyed)
- {
- //
- // Being destroyed by main thread
- //
- return;
- }
- if(_nohup && signal == SIGHUP)
- {
- return;
- }
- assert(!_callbackInProgress);
- _callbackInProgress = true;
- _interrupted = true;
+ StaticMutex::Lock lock(_mutex);
+ if(_destroyed)
+ {
+ //
+ // Being destroyed by main thread
+ //
+ return;
+ }
+ if(_nohup && signal == SIGHUP)
+ {
+ return;
+ }
+ assert(!_callbackInProgress);
+ _callbackInProgress = true;
+ _interrupted = true;
}
assert(_communicator != 0);
try
{
- _communicator->shutdown();
+ _communicator->shutdown();
}
catch(const IceUtil::Exception& ex)
{
- cerr << _appName << " (while shutting down in response to signal " << signal
- << "): " << ex << endl;
+ cerr << _appName << " (while shutting down in response to signal " << signal
+ << "): " << ex << endl;
}
catch(const std::exception& ex)
{
- cerr << _appName << " (while shutting down in response to signal " << signal
- << "): std::exception: " << ex.what() << endl;
+ cerr << _appName << " (while shutting down in response to signal " << signal
+ << "): std::exception: " << ex.what() << endl;
}
catch(const std::string& msg)
{
- cerr << _appName << " (while shutting down in response to signal " << signal
- << "): " << msg << endl;
+ cerr << _appName << " (while shutting down in response to signal " << signal
+ << "): " << msg << endl;
}
catch(const char * msg)
{
- cerr << _appName << " (while shutting down in response to signal " << signal
- << "): " << msg << endl;
+ cerr << _appName << " (while shutting down in response to signal " << signal
+ << "): " << msg << endl;
}
catch(...)
{
- cerr << _appName << " (while shutting down in response to signal " << signal
- << "): unknown exception" << endl;
+ cerr << _appName << " (while shutting down in response to signal " << signal
+ << "): unknown exception" << endl;
}
{
- StaticMutex::Lock lock(_mutex);
- _callbackInProgress = false;
+ StaticMutex::Lock lock(_mutex);
+ _callbackInProgress = false;
}
_condVar->signal();
}
@@ -217,55 +217,55 @@ static void
callbackOnInterruptCallback(int signal)
{
{
- StaticMutex::Lock lock(_mutex);
- if(_destroyed)
- {
- //
- // Being destroyed by main thread
- //
- return;
- }
- // For SIGHUP the user callback is always called. It can
- // decide what to do.
- assert(!_callbackInProgress);
- _callbackInProgress = true;
- _interrupted = true;
+ StaticMutex::Lock lock(_mutex);
+ if(_destroyed)
+ {
+ //
+ // Being destroyed by main thread
+ //
+ return;
+ }
+ // For SIGHUP the user callback is always called. It can
+ // decide what to do.
+ assert(!_callbackInProgress);
+ _callbackInProgress = true;
+ _interrupted = true;
}
assert(_application != 0);
try
{
- _application->interruptCallback(signal);
+ _application->interruptCallback(signal);
}
catch(const IceUtil::Exception& ex)
{
- cerr << _appName << " (while interrupting in response to signal " << signal
- << "): " << ex << endl;
+ cerr << _appName << " (while interrupting in response to signal " << signal
+ << "): " << ex << endl;
}
catch(const std::exception& ex)
{
- cerr << _appName << " (while interrupting in response to signal " << signal
- << "): std::exception: " << ex.what() << endl;
+ cerr << _appName << " (while interrupting in response to signal " << signal
+ << "): std::exception: " << ex.what() << endl;
}
catch(const std::string& msg)
{
- cerr << _appName << " (while interrupting in response to signal " << signal
- << "): " << msg << endl;
+ cerr << _appName << " (while interrupting in response to signal " << signal
+ << "): " << msg << endl;
}
catch(const char * msg)
{
- cerr << _appName << " (while interrupting in response to signal " << signal
- << "): " << msg << endl;
+ cerr << _appName << " (while interrupting in response to signal " << signal
+ << "): " << msg << endl;
}
catch(...)
{
- cerr << _appName << " (while interrupting in response to signal " << signal
- << "): unknown exception" << endl;
+ cerr << _appName << " (while interrupting in response to signal " << signal
+ << "): unknown exception" << endl;
}
{
- StaticMutex::Lock lock(_mutex);
- _callbackInProgress = false;
+ StaticMutex::Lock lock(_mutex);
+ _callbackInProgress = false;
}
_condVar->signal();
}
@@ -295,26 +295,26 @@ Ice::Application::main(int argc, char* argv[], const char* configFile)
InitializationData initData;
if(configFile)
{
- try
- {
- initData.properties = createProperties();
- initData.properties->load(configFile);
- }
- catch(const IceUtil::Exception& ex)
- {
- cerr << argv[0] << ": " << ex << endl;
- return EXIT_FAILURE;
- }
- catch(const std::exception& ex)
- {
- cerr << argv[0] << ": std::exception: " << ex.what() << endl;
- return EXIT_FAILURE;
- }
- catch(...)
- {
- cerr << argv[0] << ": unknown exception" << endl;
- return EXIT_FAILURE;
- }
+ try
+ {
+ initData.properties = createProperties();
+ initData.properties->load(configFile);
+ }
+ catch(const IceUtil::Exception& ex)
+ {
+ cerr << argv[0] << ": " << ex << endl;
+ return EXIT_FAILURE;
+ }
+ catch(const std::exception& ex)
+ {
+ cerr << argv[0] << ": std::exception: " << ex.what() << endl;
+ return EXIT_FAILURE;
+ }
+ catch(...)
+ {
+ cerr << argv[0] << ": unknown exception" << endl;
+ return EXIT_FAILURE;
+ }
}
return main(argc, argv, initData);
}
@@ -326,26 +326,26 @@ Ice::Application::main(int argc, char* argv[], const char* configFile, const Ice
InitializationData initData;
if(configFile)
{
- try
- {
- initData.properties = createProperties();
- initData.properties->load(configFile);
- }
- catch(const IceUtil::Exception& ex)
- {
- cerr << argv[0] << ": " << ex << endl;
- return EXIT_FAILURE;
- }
- catch(const std::exception& ex)
- {
- cerr << argv[0] << ": std::exception: " << ex.what() << endl;
- return EXIT_FAILURE;
- }
- catch(...)
- {
- cerr << argv[0] << ": unknown exception" << endl;
- return EXIT_FAILURE;
- }
+ try
+ {
+ initData.properties = createProperties();
+ initData.properties->load(configFile);
+ }
+ catch(const IceUtil::Exception& ex)
+ {
+ cerr << argv[0] << ": " << ex << endl;
+ return EXIT_FAILURE;
+ }
+ catch(const std::exception& ex)
+ {
+ cerr << argv[0] << ": std::exception: " << ex.what() << endl;
+ return EXIT_FAILURE;
+ }
+ catch(...)
+ {
+ cerr << argv[0] << ": unknown exception" << endl;
+ return EXIT_FAILURE;
+ }
}
initData.logger = logger;
return main(argc, argv, initData);
@@ -356,133 +356,133 @@ Ice::Application::main(int argc, char* argv[], const InitializationData& initDat
{
if(_communicator != 0)
{
- cerr << argv[0] << ": only one instance of the Application class can be used" << endl;
- return EXIT_FAILURE;
+ cerr << argv[0] << ": only one instance of the Application class can be used" << endl;
+ return EXIT_FAILURE;
}
int status;
try
{
- //
- // The ctrlCHandler must be created before starting any thread, in particular
- // before initializing the communicator.
- //
- CtrlCHandler ctrCHandler;
- _ctrlCHandler = &ctrCHandler;
-
- try
- {
- if(_condVar.get() == 0)
- {
- _condVar.reset(new Cond);
- }
-
- _interrupted = false;
- _appName = argv[0];
-
- _application = this;
- _communicator = initialize(argc, argv, initData);
- _destroyed = false;
-
- //
- // Used by destroyOnInterruptCallback and shutdownOnInterruptCallback.
- //
- _nohup = (_communicator->getProperties()->getPropertyAsInt("Ice.Nohup") > 0);
-
- //
- // The default is to destroy when a signal is received.
- //
- destroyOnInterrupt();
- status = run(argc, argv);
- }
- catch(const IceUtil::Exception& ex)
- {
- cerr << _appName << ": " << ex << endl;
- status = EXIT_FAILURE;
- }
- catch(const std::exception& ex)
- {
- cerr << _appName << ": std::exception: " << ex.what() << endl;
- status = EXIT_FAILURE;
- }
- catch(const std::string& msg)
- {
- cerr << _appName << ": " << msg << endl;
- status = EXIT_FAILURE;
- }
- catch(const char* msg)
- {
- cerr << _appName << ": " << msg << endl;
- status = EXIT_FAILURE;
- }
- catch(...)
- {
- cerr << _appName << ": unknown exception" << endl;
- status = EXIT_FAILURE;
- }
-
- //
- // Don't want any new interrupt and at this point (post-run),
- // it would not make sense to release a held signal to run
- // shutdown or destroy.
- //
- ignoreInterrupt();
-
- {
- StaticMutex::Lock lock(_mutex);
- while(_callbackInProgress)
- {
- _condVar->wait(lock);
- }
- if(_destroyed)
- {
- _communicator = 0;
- }
- else
- {
- _destroyed = true;
- //
- // And _communicator != 0, meaning will be destroyed
- // next, _destroyed = true also ensures that any
- // remaining callback won't do anything
- //
- }
- _application = 0;
- }
-
- if(_communicator != 0)
- {
- try
- {
- _communicator->destroy();
- }
- catch(const IceUtil::Exception& ex)
- {
- cerr << _appName << ": " << ex << endl;
- status = EXIT_FAILURE;
- }
- catch(const std::exception& ex)
- {
- cerr << _appName << ": std::exception: " << ex.what() << endl;
- status = EXIT_FAILURE;
- }
- catch(...)
- {
- cerr << _appName << ": unknown exception" << endl;
- status = EXIT_FAILURE;
- }
- _communicator = 0;
- }
-
- //
- // Set _ctrlCHandler to 0 only once communicator->destroy() has completed.
- //
- _ctrlCHandler = 0;
+ //
+ // The ctrlCHandler must be created before starting any thread, in particular
+ // before initializing the communicator.
+ //
+ CtrlCHandler ctrCHandler;
+ _ctrlCHandler = &ctrCHandler;
+
+ try
+ {
+ if(_condVar.get() == 0)
+ {
+ _condVar.reset(new Cond);
+ }
+
+ _interrupted = false;
+ _appName = argv[0];
+
+ _application = this;
+ _communicator = initialize(argc, argv, initData);
+ _destroyed = false;
+
+ //
+ // Used by destroyOnInterruptCallback and shutdownOnInterruptCallback.
+ //
+ _nohup = (_communicator->getProperties()->getPropertyAsInt("Ice.Nohup") > 0);
+
+ //
+ // The default is to destroy when a signal is received.
+ //
+ destroyOnInterrupt();
+ status = run(argc, argv);
+ }
+ catch(const IceUtil::Exception& ex)
+ {
+ cerr << _appName << ": " << ex << endl;
+ status = EXIT_FAILURE;
+ }
+ catch(const std::exception& ex)
+ {
+ cerr << _appName << ": std::exception: " << ex.what() << endl;
+ status = EXIT_FAILURE;
+ }
+ catch(const std::string& msg)
+ {
+ cerr << _appName << ": " << msg << endl;
+ status = EXIT_FAILURE;
+ }
+ catch(const char* msg)
+ {
+ cerr << _appName << ": " << msg << endl;
+ status = EXIT_FAILURE;
+ }
+ catch(...)
+ {
+ cerr << _appName << ": unknown exception" << endl;
+ status = EXIT_FAILURE;
+ }
+
+ //
+ // Don't want any new interrupt and at this point (post-run),
+ // it would not make sense to release a held signal to run
+ // shutdown or destroy.
+ //
+ ignoreInterrupt();
+
+ {
+ StaticMutex::Lock lock(_mutex);
+ while(_callbackInProgress)
+ {
+ _condVar->wait(lock);
+ }
+ if(_destroyed)
+ {
+ _communicator = 0;
+ }
+ else
+ {
+ _destroyed = true;
+ //
+ // And _communicator != 0, meaning will be destroyed
+ // next, _destroyed = true also ensures that any
+ // remaining callback won't do anything
+ //
+ }
+ _application = 0;
+ }
+
+ if(_communicator != 0)
+ {
+ try
+ {
+ _communicator->destroy();
+ }
+ catch(const IceUtil::Exception& ex)
+ {
+ cerr << _appName << ": " << ex << endl;
+ status = EXIT_FAILURE;
+ }
+ catch(const std::exception& ex)
+ {
+ cerr << _appName << ": std::exception: " << ex.what() << endl;
+ status = EXIT_FAILURE;
+ }
+ catch(...)
+ {
+ cerr << _appName << ": unknown exception" << endl;
+ status = EXIT_FAILURE;
+ }
+ _communicator = 0;
+ }
+
+ //
+ // Set _ctrlCHandler to 0 only once communicator->destroy() has completed.
+ //
+ _ctrlCHandler = 0;
}
catch(const CtrlCHandlerException&)
{
- cerr << argv[0] << ": only one instance of the Application class can be used" << endl;
- status = EXIT_FAILURE;
+ cerr << argv[0] << ": only one instance of the Application class can be used" << endl;
+ status = EXIT_FAILURE;
}
return status;
@@ -513,13 +513,13 @@ Ice::Application::destroyOnInterrupt()
//
if(_ctrlCHandler != 0)
{
- StaticMutex::Lock lock(_mutex); // we serialize all the interrupt-setting
- if(_ctrlCHandler->getCallback() == holdInterruptCallback)
- {
- _released = true;
- _condVar->signal();
- }
- _ctrlCHandler->setCallback(destroyOnInterruptCallback);
+ StaticMutex::Lock lock(_mutex); // we serialize all the interrupt-setting
+ if(_ctrlCHandler->getCallback() == holdInterruptCallback)
+ {
+ _released = true;
+ _condVar->signal();
+ }
+ _ctrlCHandler->setCallback(destroyOnInterruptCallback);
}
}
@@ -528,13 +528,13 @@ Ice::Application::shutdownOnInterrupt()
{
if(_ctrlCHandler != 0)
{
- StaticMutex::Lock lock(_mutex); // we serialize all the interrupt-setting
- if(_ctrlCHandler->getCallback() == holdInterruptCallback)
- {
- _released = true;
- _condVar->signal();
- }
- _ctrlCHandler->setCallback(shutdownOnInterruptCallback);
+ StaticMutex::Lock lock(_mutex); // we serialize all the interrupt-setting
+ if(_ctrlCHandler->getCallback() == holdInterruptCallback)
+ {
+ _released = true;
+ _condVar->signal();
+ }
+ _ctrlCHandler->setCallback(shutdownOnInterruptCallback);
}
}
@@ -543,13 +543,13 @@ Ice::Application::ignoreInterrupt()
{
if(_ctrlCHandler != 0)
{
- StaticMutex::Lock lock(_mutex); // we serialize all the interrupt-setting
- if(_ctrlCHandler->getCallback() == holdInterruptCallback)
- {
- _released = true;
- _condVar->signal();
- }
- _ctrlCHandler->setCallback(0);
+ StaticMutex::Lock lock(_mutex); // we serialize all the interrupt-setting
+ if(_ctrlCHandler->getCallback() == holdInterruptCallback)
+ {
+ _released = true;
+ _condVar->signal();
+ }
+ _ctrlCHandler->setCallback(0);
}
}
@@ -558,13 +558,13 @@ Ice::Application::callbackOnInterrupt()
{
if(_ctrlCHandler != 0)
{
- StaticMutex::Lock lock(_mutex); // we serialize all the interrupt-setting
- if(_ctrlCHandler->getCallback() == holdInterruptCallback)
- {
- _released = true;
- _condVar->signal();
- }
- _ctrlCHandler->setCallback(callbackOnInterruptCallback);
+ StaticMutex::Lock lock(_mutex); // we serialize all the interrupt-setting
+ if(_ctrlCHandler->getCallback() == holdInterruptCallback)
+ {
+ _released = true;
+ _condVar->signal();
+ }
+ _ctrlCHandler->setCallback(callbackOnInterruptCallback);
}
}
@@ -573,14 +573,14 @@ Ice::Application::holdInterrupt()
{
if(_ctrlCHandler != 0)
{
- StaticMutex::Lock lock(_mutex); // we serialize all the interrupt-setting
- if(_ctrlCHandler->getCallback() != holdInterruptCallback)
- {
- _previousCallback = _ctrlCHandler->getCallback();
- _released = false;
- _ctrlCHandler->setCallback(holdInterruptCallback);
- }
- // else, we were already holding signals
+ StaticMutex::Lock lock(_mutex); // we serialize all the interrupt-setting
+ if(_ctrlCHandler->getCallback() != holdInterruptCallback)
+ {
+ _previousCallback = _ctrlCHandler->getCallback();
+ _released = false;
+ _ctrlCHandler->setCallback(holdInterruptCallback);
+ }
+ // else, we were already holding signals
}
}
@@ -589,21 +589,21 @@ Ice::Application::releaseInterrupt()
{
if(_ctrlCHandler != 0)
{
- StaticMutex::Lock lock(_mutex); // we serialize all the interrupt-setting
- if(_ctrlCHandler->getCallback() == holdInterruptCallback)
- {
- //
- // Note that it's very possible no signal is held;
- // in this case the callback is just replaced and
- // setting _released to true and signalling _condVar
- // do no harm.
- //
-
- _released = true;
- _ctrlCHandler->setCallback(_previousCallback);
- _condVar->signal();
- }
- // Else nothing to release.
+ StaticMutex::Lock lock(_mutex); // we serialize all the interrupt-setting
+ if(_ctrlCHandler->getCallback() == holdInterruptCallback)
+ {
+ //
+ // Note that it's very possible no signal is held;
+ // in this case the callback is just replaced and
+ // setting _released to true and signalling _condVar
+ // do no harm.
+ //
+
+ _released = true;
+ _ctrlCHandler->setCallback(_previousCallback);
+ _condVar->signal();
+ }
+ // Else nothing to release.
}
}
diff --git a/cpp/src/Ice/BasicStream.cpp b/cpp/src/Ice/BasicStream.cpp
index 67ea3e484a0..2e38c4c12df 100644
--- a/cpp/src/Ice/BasicStream.cpp
+++ b/cpp/src/Ice/BasicStream.cpp
@@ -51,23 +51,23 @@ IceInternal::BasicStream::clear()
{
while(_currentReadEncaps && _currentReadEncaps != &_preAllocatedReadEncaps)
{
- ReadEncaps* oldEncaps = _currentReadEncaps;
- _currentReadEncaps = _currentReadEncaps->previous;
- delete oldEncaps;
+ ReadEncaps* oldEncaps = _currentReadEncaps;
+ _currentReadEncaps = _currentReadEncaps->previous;
+ delete oldEncaps;
}
while(_currentWriteEncaps && _currentWriteEncaps != &_preAllocatedWriteEncaps)
{
- WriteEncaps* oldEncaps = _currentWriteEncaps;
- _currentWriteEncaps = _currentWriteEncaps->previous;
- delete oldEncaps;
+ WriteEncaps* oldEncaps = _currentWriteEncaps;
+ _currentWriteEncaps = _currentWriteEncaps->previous;
+ delete oldEncaps;
}
while(_seqDataStack)
{
- SeqData* oldSeqData = _seqDataStack;
- _seqDataStack = _seqDataStack->previous;
- delete oldSeqData;
+ SeqData* oldSeqData = _seqDataStack;
+ _seqDataStack = _seqDataStack->previous;
+ delete oldSeqData;
}
delete _objectList;
@@ -91,34 +91,34 @@ IceInternal::BasicStream::swap(BasicStream& other)
if(_currentReadEncaps || other._currentReadEncaps)
{
- _preAllocatedReadEncaps.swap(other._preAllocatedReadEncaps);
+ _preAllocatedReadEncaps.swap(other._preAllocatedReadEncaps);
- if(!_currentReadEncaps)
- {
- _currentReadEncaps = &_preAllocatedReadEncaps;
- other._currentReadEncaps = 0;
- }
- else if(!other._currentReadEncaps)
- {
- other._currentReadEncaps = &other._preAllocatedReadEncaps;
- _currentReadEncaps = 0;
- }
+ if(!_currentReadEncaps)
+ {
+ _currentReadEncaps = &_preAllocatedReadEncaps;
+ other._currentReadEncaps = 0;
+ }
+ else if(!other._currentReadEncaps)
+ {
+ other._currentReadEncaps = &other._preAllocatedReadEncaps;
+ _currentReadEncaps = 0;
+ }
}
if(_currentWriteEncaps || other._currentWriteEncaps)
{
- _preAllocatedWriteEncaps.swap(other._preAllocatedWriteEncaps);
+ _preAllocatedWriteEncaps.swap(other._preAllocatedWriteEncaps);
- if(!_currentWriteEncaps)
- {
- _currentWriteEncaps = &_preAllocatedWriteEncaps;
- other._currentWriteEncaps = 0;
- }
- else if(!other._currentWriteEncaps)
- {
- other._currentWriteEncaps = &other._preAllocatedWriteEncaps;
- _currentWriteEncaps = 0;
- }
+ if(!_currentWriteEncaps)
+ {
+ _currentWriteEncaps = &_preAllocatedWriteEncaps;
+ other._currentWriteEncaps = 0;
+ }
+ else if(!other._currentWriteEncaps)
+ {
+ other._currentWriteEncaps = &other._preAllocatedWriteEncaps;
+ _currentWriteEncaps = 0;
+ }
}
std::swap(_seqDataStack, other._seqDataStack);
@@ -179,7 +179,7 @@ IceInternal::BasicStream::startSeq(int numElements, int minSize)
{
if(numElements == 0) // Optimization to avoid pushing a useless stack frame.
{
- return;
+ return;
}
//
@@ -192,17 +192,17 @@ IceInternal::BasicStream::startSeq(int numElements, int minSize)
int bytesLeft = static_cast<int>(b.end() - i);
if(_seqDataStack->previous == 0) // Outermost sequence
{
- //
- // The sequence must fit within the message.
- //
- if(numElements * minSize > bytesLeft)
- {
- throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
- }
+ //
+ // The sequence must fit within the message.
+ //
+ if(numElements * minSize > bytesLeft)
+ {
+ throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
+ }
}
else // Nested sequence
{
- checkSeq(bytesLeft);
+ checkSeq(bytesLeft);
}
}
@@ -212,17 +212,17 @@ IceInternal::BasicStream::checkFixedSeq(int numElements, int elemSize)
int bytesLeft = static_cast<int>(b.end() - i);
if(_seqDataStack == 0) // Outermost sequence
{
- //
- // The sequence must fit within the message.
- //
- if(numElements * elemSize > bytesLeft)
- {
- throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
- }
+ //
+ // The sequence must fit within the message.
+ //
+ if(numElements * elemSize > bytesLeft)
+ {
+ throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
+ }
}
else // Nested sequence
{
- checkSeq(bytesLeft - numElements * elemSize);
+ checkSeq(bytesLeft - numElements * elemSize);
}
}
@@ -231,7 +231,7 @@ IceInternal::BasicStream::endSeq(int sz)
{
if(sz == 0) // Pop only if something was pushed previously.
{
- return;
+ return;
}
//
@@ -300,11 +300,11 @@ IceInternal::BasicStream::skipEncaps()
read(sz);
if(sz < 0)
{
- throw NegativeSizeException(__FILE__, __LINE__);
+ throw NegativeSizeException(__FILE__, __LINE__);
}
if(i - sizeof(Int) + sz > b.end())
{
- throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
+ throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
}
i += sz - sizeof(Int);
}
@@ -343,7 +343,7 @@ IceInternal::BasicStream::startReadSlice()
read(sz);
if(sz < 0)
{
- throw NegativeSizeException(__FILE__, __LINE__);
+ throw NegativeSizeException(__FILE__, __LINE__);
}
_readSlice = i - b.begin();
}
@@ -360,12 +360,12 @@ IceInternal::BasicStream::skipSlice()
read(sz);
if(sz < 0)
{
- throw NegativeSizeException(__FILE__, __LINE__);
+ throw NegativeSizeException(__FILE__, __LINE__);
}
i += sz - sizeof(Int);
if(i > b.end())
{
- throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
+ throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
}
}
@@ -375,14 +375,14 @@ IceInternal::BasicStream::writeTypeId(const string& id)
TypeIdWriteMap::const_iterator k = _currentWriteEncaps->typeIdMap->find(id);
if(k != _currentWriteEncaps->typeIdMap->end())
{
- write(true);
- writeSize(k->second);
+ write(true);
+ writeSize(k->second);
}
else
{
- _currentWriteEncaps->typeIdMap->insert(make_pair(id, ++_currentWriteEncaps->typeIdIndex));
- write(false);
- write(id, false);
+ _currentWriteEncaps->typeIdMap->insert(make_pair(id, ++_currentWriteEncaps->typeIdIndex));
+ write(false);
+ write(id, false);
}
}
@@ -393,19 +393,19 @@ IceInternal::BasicStream::readTypeId(string& id)
read(isIndex);
if(isIndex)
{
- Ice::Int index;
- readSize(index);
- TypeIdReadMap::const_iterator k = _currentReadEncaps->typeIdMap->find(index);
- if(k == _currentReadEncaps->typeIdMap->end())
- {
- throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
- }
- id = k->second;
+ Ice::Int index;
+ readSize(index);
+ TypeIdReadMap::const_iterator k = _currentReadEncaps->typeIdMap->find(index);
+ if(k == _currentReadEncaps->typeIdMap->end())
+ {
+ throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
+ }
+ id = k->second;
}
else
{
- read(id, false);
- _currentReadEncaps->typeIdMap->insert(make_pair(++_currentReadEncaps->typeIdIndex, id));
+ read(id, false);
+ _currentReadEncaps->typeIdMap->insert(make_pair(++_currentReadEncaps->typeIdIndex, id));
}
}
@@ -414,9 +414,9 @@ IceInternal::BasicStream::writeBlob(const vector<Byte>& v)
{
if(!v.empty())
{
- Container::size_type pos = b.size();
- resize(pos + v.size());
- memcpy(&b[pos], &v[0], v.size());
+ Container::size_type pos = b.size();
+ resize(pos + v.size());
+ memcpy(&b[pos], &v[0], v.size());
}
}
@@ -425,16 +425,16 @@ IceInternal::BasicStream::readBlob(vector<Byte>& v, Int sz)
{
if(sz > 0)
{
- if(b.end() - i < sz)
- {
- throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
- }
- vector<Byte>(i, i + sz).swap(v);
- i += sz;
+ if(b.end() - i < sz)
+ {
+ throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
+ }
+ vector<Byte>(i, i + sz).swap(v);
+ i += sz;
}
else
{
- v.clear();
+ v.clear();
}
}
@@ -445,9 +445,9 @@ IceInternal::BasicStream::write(const Byte* begin, const Byte* end)
writeSize(sz);
if(sz > 0)
{
- Container::size_type pos = b.size();
- resize(pos + sz);
- memcpy(&b[pos], begin, sz);
+ Container::size_type pos = b.size();
+ resize(pos + sz);
+ memcpy(&b[pos], begin, sz);
}
}
@@ -476,9 +476,9 @@ IceInternal::BasicStream::write(const vector<bool>& v)
writeSize(sz);
if(sz > 0)
{
- Container::size_type pos = b.size();
- resize(pos + sz);
- copy(v.begin(), v.end(), b.begin() + pos);
+ Container::size_type pos = b.size();
+ resize(pos + sz);
+ copy(v.begin(), v.end(), b.begin() + pos);
}
}
@@ -517,7 +517,7 @@ IceInternal::BasicStream::write(const bool* begin, const bool* end)
{
Container::size_type pos = b.size();
resize(pos + sz);
- BasicStreamWriteBoolHelper<sizeof(bool)>::write(begin, pos, b, sz);
+ BasicStreamWriteBoolHelper<sizeof(bool)>::write(begin, pos, b, sz);
}
}
@@ -550,11 +550,11 @@ struct BasicStreamReadBoolHelper
bool* array = new bool[sz];
for(int idx = 0; idx < sz; ++idx)
{
- array[idx] = static_cast<bool>(*(i + idx));
+ array[idx] = static_cast<bool>(*(i + idx));
}
v.first = array;
v.second = array + sz;
- return array;
+ return array;
}
};
@@ -565,7 +565,7 @@ struct BasicStreamReadBoolHelper<1>
{
v.first = reinterpret_cast<bool*>(i);
v.second = reinterpret_cast<bool*>(i) + sz;
- return 0;
+ return 0;
}
};
@@ -580,7 +580,7 @@ IceInternal::BasicStream::read(pair<const bool*, const bool*>& v)
if(sz > 0)
{
checkFixedSeq(sz, 1);
- result = BasicStreamReadBoolHelper<sizeof(bool)>::read(v, sz, i);
+ result = BasicStreamReadBoolHelper<sizeof(bool)>::read(v, sz, i);
i += sz;
}
else
@@ -614,19 +614,19 @@ IceInternal::BasicStream::write(const Short* begin, const Short* end)
writeSize(sz);
if(sz > 0)
{
- Container::size_type pos = b.size();
- resize(pos + sz * sizeof(Short));
+ Container::size_type pos = b.size();
+ resize(pos + sz * sizeof(Short));
#ifdef ICE_BIG_ENDIAN
- const Byte* src = reinterpret_cast<const Byte*>(begin) + sizeof(Short) - 1;
- Byte* dest = &(*(b.begin() + pos));
- for(int j = 0 ; j < sz ; ++j)
- {
- *dest++ = *src--;
- *dest++ = *src--;
- src += 2 * sizeof(Short);
- }
+ const Byte* src = reinterpret_cast<const Byte*>(begin) + sizeof(Short) - 1;
+ Byte* dest = &(*(b.begin() + pos));
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest++ = *src--;
+ *dest++ = *src--;
+ src += 2 * sizeof(Short);
+ }
#else
- memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), sz * sizeof(Short));
+ memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), sz * sizeof(Short));
#endif
}
}
@@ -636,7 +636,7 @@ IceInternal::BasicStream::read(Short& v)
{
if(b.end() - i < static_cast<int>(sizeof(Short)))
{
- throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
+ throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
}
const Byte* src = &(*i);
i += sizeof(Short);
@@ -658,26 +658,26 @@ IceInternal::BasicStream::read(vector<Short>& v)
readSize(sz);
if(sz > 0)
{
- checkFixedSeq(sz, static_cast<int>(sizeof(Short)));
- Container::iterator begin = i;
- i += sz * static_cast<int>(sizeof(Short));
- v.resize(sz);
+ checkFixedSeq(sz, static_cast<int>(sizeof(Short)));
+ Container::iterator begin = i;
+ i += sz * static_cast<int>(sizeof(Short));
+ v.resize(sz);
#ifdef ICE_BIG_ENDIAN
- const Byte* src = &(*begin);
- Byte* dest = reinterpret_cast<Byte*>(&v[0]) + sizeof(Short) - 1;
- for(int j = 0 ; j < sz ; ++j)
- {
- *dest-- = *src++;
- *dest-- = *src++;
- dest += 2 * sizeof(Short);
- }
+ const Byte* src = &(*begin);
+ Byte* dest = reinterpret_cast<Byte*>(&v[0]) + sizeof(Short) - 1;
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest-- = *src++;
+ *dest-- = *src++;
+ dest += 2 * sizeof(Short);
+ }
#else
- copy(begin, i, reinterpret_cast<Byte*>(&v[0]));
+ copy(begin, i, reinterpret_cast<Byte*>(&v[0]));
#endif
}
else
{
- v.clear();
+ v.clear();
}
}
@@ -689,35 +689,35 @@ IceInternal::BasicStream::read(pair<const Short*, const Short*>& v)
readSize(sz);
if(sz > 0)
{
- checkFixedSeq(sz, static_cast<int>(sizeof(Short)));
+ checkFixedSeq(sz, static_cast<int>(sizeof(Short)));
#if defined(__i386) || defined(_M_IX86)
v.first = reinterpret_cast<Short*>(i);
- i += sz * static_cast<int>(sizeof(Short));
+ i += sz * static_cast<int>(sizeof(Short));
v.second = reinterpret_cast<Short*>(i);
#else
result = new Short[sz];
v.first = result;
v.second = result + sz;
- Container::iterator begin = i;
- i += sz * static_cast<int>(sizeof(Short));
+ Container::iterator begin = i;
+ i += sz * static_cast<int>(sizeof(Short));
# ifdef ICE_BIG_ENDIAN
- const Byte* src = &(*begin);
- Byte* dest = reinterpret_cast<Byte*>(&result[0]) + sizeof(Short) - 1;
- for(int j = 0 ; j < sz ; ++j)
- {
- *dest-- = *src++;
- *dest-- = *src++;
- dest += 2 * sizeof(Short);
- }
+ const Byte* src = &(*begin);
+ Byte* dest = reinterpret_cast<Byte*>(&result[0]) + sizeof(Short) - 1;
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest-- = *src++;
+ *dest-- = *src++;
+ dest += 2 * sizeof(Short);
+ }
# else
- copy(begin, i, reinterpret_cast<Byte*>(&result[0]));
+ copy(begin, i, reinterpret_cast<Byte*>(&result[0]));
# endif
#endif
}
else
{
- v.first = v.second = 0;
+ v.first = v.second = 0;
}
return result;
}
@@ -729,21 +729,21 @@ IceInternal::BasicStream::write(const Int* begin, const Int* end)
writeSize(sz);
if(sz > 0)
{
- Container::size_type pos = b.size();
- resize(pos + sz * sizeof(Int));
+ Container::size_type pos = b.size();
+ resize(pos + sz * sizeof(Int));
#ifdef ICE_BIG_ENDIAN
- const Byte* src = reinterpret_cast<const Byte*>(begin) + sizeof(Int) - 1;
- Byte* dest = &(*(b.begin() + pos));
- for(int j = 0 ; j < sz ; ++j)
- {
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- src += 2 * sizeof(Int);
- }
+ const Byte* src = reinterpret_cast<const Byte*>(begin) + sizeof(Int) - 1;
+ Byte* dest = &(*(b.begin() + pos));
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ src += 2 * sizeof(Int);
+ }
#else
- memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), sz * sizeof(Int));
+ memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), sz * sizeof(Int));
#endif
}
}
@@ -755,28 +755,28 @@ IceInternal::BasicStream::read(vector<Int>& v)
readSize(sz);
if(sz > 0)
{
- checkFixedSeq(sz, static_cast<int>(sizeof(Int)));
- Container::iterator begin = i;
- i += sz * static_cast<int>(sizeof(Int));
- v.resize(sz);
+ checkFixedSeq(sz, static_cast<int>(sizeof(Int)));
+ Container::iterator begin = i;
+ i += sz * static_cast<int>(sizeof(Int));
+ v.resize(sz);
#ifdef ICE_BIG_ENDIAN
- const Byte* src = &(*begin);
- Byte* dest = reinterpret_cast<Byte*>(&v[0]) + sizeof(Int) - 1;
- for(int j = 0 ; j < sz ; ++j)
- {
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- dest += 2 * sizeof(Int);
- }
+ const Byte* src = &(*begin);
+ Byte* dest = reinterpret_cast<Byte*>(&v[0]) + sizeof(Int) - 1;
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ dest += 2 * sizeof(Int);
+ }
#else
- copy(begin, i, reinterpret_cast<Byte*>(&v[0]));
+ copy(begin, i, reinterpret_cast<Byte*>(&v[0]));
#endif
}
else
{
- v.clear();
+ v.clear();
}
}
@@ -788,37 +788,37 @@ IceInternal::BasicStream::read(pair<const Int*, const Int*>& v)
readSize(sz);
if(sz > 0)
{
- checkFixedSeq(sz, static_cast<int>(sizeof(Int)));
+ checkFixedSeq(sz, static_cast<int>(sizeof(Int)));
#if defined(__i386) || defined(_M_IX86)
v.first = reinterpret_cast<Int*>(i);
- i += sz * static_cast<int>(sizeof(Int));
+ i += sz * static_cast<int>(sizeof(Int));
v.second = reinterpret_cast<Int*>(i);
#else
result = new Int[sz];
v.first = result;
v.second = result + sz;
- Container::iterator begin = i;
- i += sz * static_cast<int>(sizeof(Int));
+ Container::iterator begin = i;
+ i += sz * static_cast<int>(sizeof(Int));
# ifdef ICE_BIG_ENDIAN
- const Byte* src = &(*begin);
- Byte* dest = reinterpret_cast<Byte*>(&result[0]) + sizeof(Int) - 1;
- for(int j = 0 ; j < sz ; ++j)
- {
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- dest += 2 * sizeof(Int);
- }
+ const Byte* src = &(*begin);
+ Byte* dest = reinterpret_cast<Byte*>(&result[0]) + sizeof(Int) - 1;
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ dest += 2 * sizeof(Int);
+ }
# else
- copy(begin, i, reinterpret_cast<Byte*>(&result[0]));
+ copy(begin, i, reinterpret_cast<Byte*>(&result[0]));
# endif
#endif
}
else
{
- v.first = v.second = 0;
+ v.first = v.second = 0;
}
return result;
}
@@ -859,25 +859,25 @@ IceInternal::BasicStream::write(const Long* begin, const Long* end)
writeSize(sz);
if(sz > 0)
{
- Container::size_type pos = b.size();
- resize(pos + sz * sizeof(Long));
+ Container::size_type pos = b.size();
+ resize(pos + sz * sizeof(Long));
#ifdef ICE_BIG_ENDIAN
- const Byte* src = reinterpret_cast<const Byte*>(begin) + sizeof(Long) - 1;
- Byte* dest = &(*(b.begin() + pos));
- for(int j = 0 ; j < sz ; ++j)
- {
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- src += 2 * sizeof(Long);
- }
+ const Byte* src = reinterpret_cast<const Byte*>(begin) + sizeof(Long) - 1;
+ Byte* dest = &(*(b.begin() + pos));
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ src += 2 * sizeof(Long);
+ }
#else
- memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), sz * sizeof(Long));
+ memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), sz * sizeof(Long));
#endif
}
}
@@ -887,7 +887,7 @@ IceInternal::BasicStream::read(Long& v)
{
if(b.end() - i < static_cast<int>(sizeof(Long)))
{
- throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
+ throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
}
const Byte* src = &(*i);
i += sizeof(Long);
@@ -921,32 +921,32 @@ IceInternal::BasicStream::read(vector<Long>& v)
readSize(sz);
if(sz > 0)
{
- checkFixedSeq(sz, static_cast<int>(sizeof(Long)));
- Container::iterator begin = i;
- i += sz * static_cast<int>(sizeof(Long));
- v.resize(sz);
+ checkFixedSeq(sz, static_cast<int>(sizeof(Long)));
+ Container::iterator begin = i;
+ i += sz * static_cast<int>(sizeof(Long));
+ v.resize(sz);
#ifdef ICE_BIG_ENDIAN
- const Byte* src = &(*begin);
- Byte* dest = reinterpret_cast<Byte*>(&v[0]) + sizeof(Long) - 1;
- for(int j = 0 ; j < sz ; ++j)
- {
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- dest += 2 * sizeof(Long);
- }
+ const Byte* src = &(*begin);
+ Byte* dest = reinterpret_cast<Byte*>(&v[0]) + sizeof(Long) - 1;
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ dest += 2 * sizeof(Long);
+ }
#else
- copy(begin, i, reinterpret_cast<Byte*>(&v[0]));
+ copy(begin, i, reinterpret_cast<Byte*>(&v[0]));
#endif
}
else
{
- v.clear();
+ v.clear();
}
}
@@ -958,41 +958,41 @@ IceInternal::BasicStream::read(pair<const Long*, const Long*>& v)
readSize(sz);
if(sz > 0)
{
- checkFixedSeq(sz, static_cast<int>(sizeof(Long)));
+ checkFixedSeq(sz, static_cast<int>(sizeof(Long)));
#if defined(__i386) || defined(_M_IX86)
v.first = reinterpret_cast<Long*>(i);
- i += sz * static_cast<int>(sizeof(Long));
+ i += sz * static_cast<int>(sizeof(Long));
v.second = reinterpret_cast<Long*>(i);
#else
result = new Long[sz];
v.first = result;
v.second = result + sz;
- Container::iterator begin = i;
- i += sz * static_cast<int>(sizeof(Long));
+ Container::iterator begin = i;
+ i += sz * static_cast<int>(sizeof(Long));
# ifdef ICE_BIG_ENDIAN
- const Byte* src = &(*begin);
- Byte* dest = reinterpret_cast<Byte*>(&result[0]) + sizeof(Long) - 1;
- for(int j = 0 ; j < sz ; ++j)
- {
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- dest += 2 * sizeof(Long);
- }
+ const Byte* src = &(*begin);
+ Byte* dest = reinterpret_cast<Byte*>(&result[0]) + sizeof(Long) - 1;
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ dest += 2 * sizeof(Long);
+ }
# else
- copy(begin, i, reinterpret_cast<Byte*>(&result[0]));
+ copy(begin, i, reinterpret_cast<Byte*>(&result[0]));
# endif
#endif
}
else
{
- v.first = v.second = 0;
+ v.first = v.second = 0;
}
return result;
}
@@ -1025,21 +1025,21 @@ IceInternal::BasicStream::write(const Float* begin, const Float* end)
writeSize(sz);
if(sz > 0)
{
- Container::size_type pos = b.size();
- resize(pos + sz * sizeof(Float));
+ Container::size_type pos = b.size();
+ resize(pos + sz * sizeof(Float));
#ifdef ICE_BIG_ENDIAN
- const Byte* src = reinterpret_cast<const Byte*>(begin) + sizeof(Float) - 1;
- Byte* dest = &(*(b.begin() + pos));
- for(int j = 0 ; j < sz ; ++j)
- {
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- src += 2 * sizeof(Float);
- }
+ const Byte* src = reinterpret_cast<const Byte*>(begin) + sizeof(Float) - 1;
+ Byte* dest = &(*(b.begin() + pos));
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ src += 2 * sizeof(Float);
+ }
#else
- memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), sz * sizeof(Float));
+ memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), sz * sizeof(Float));
#endif
}
}
@@ -1049,7 +1049,7 @@ IceInternal::BasicStream::read(Float& v)
{
if(b.end() - i < static_cast<int>(sizeof(Float)))
{
- throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
+ throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
}
const Byte* src = &(*i);
i += sizeof(Float);
@@ -1075,28 +1075,28 @@ IceInternal::BasicStream::read(vector<Float>& v)
readSize(sz);
if(sz > 0)
{
- checkFixedSeq(sz, static_cast<int>(sizeof(Float)));
- Container::iterator begin = i;
- i += sz * static_cast<int>(sizeof(Float));
- v.resize(sz);
+ checkFixedSeq(sz, static_cast<int>(sizeof(Float)));
+ Container::iterator begin = i;
+ i += sz * static_cast<int>(sizeof(Float));
+ v.resize(sz);
#ifdef ICE_BIG_ENDIAN
- const Byte* src = &(*begin);
- Byte* dest = reinterpret_cast<Byte*>(&v[0]) + sizeof(Float) - 1;
- for(int j = 0 ; j < sz ; ++j)
- {
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- dest += 2 * sizeof(Float);
- }
+ const Byte* src = &(*begin);
+ Byte* dest = reinterpret_cast<Byte*>(&v[0]) + sizeof(Float) - 1;
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ dest += 2 * sizeof(Float);
+ }
#else
- copy(begin, i, reinterpret_cast<Byte*>(&v[0]));
+ copy(begin, i, reinterpret_cast<Byte*>(&v[0]));
#endif
}
else
{
- v.clear();
+ v.clear();
}
}
@@ -1108,37 +1108,37 @@ IceInternal::BasicStream::read(pair<const Float*, const Float*>& v)
readSize(sz);
if(sz > 0)
{
- checkFixedSeq(sz, static_cast<int>(sizeof(Float)));
+ checkFixedSeq(sz, static_cast<int>(sizeof(Float)));
#if defined(__i386) || defined(_M_IX86)
v.first = reinterpret_cast<Float*>(i);
- i += sz * static_cast<int>(sizeof(Float));
+ i += sz * static_cast<int>(sizeof(Float));
v.second = reinterpret_cast<Float*>(i);
#else
result = new Float[sz];
v.first = result;
v.second = result + sz;
- Container::iterator begin = i;
- i += sz * static_cast<int>(sizeof(Float));
+ Container::iterator begin = i;
+ i += sz * static_cast<int>(sizeof(Float));
# ifdef ICE_BIG_ENDIAN
- const Byte* src = &(*begin);
- Byte* dest = reinterpret_cast<Byte*>(&result[0]) + sizeof(Float) - 1;
- for(int j = 0 ; j < sz ; ++j)
- {
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- dest += 2 * sizeof(Float);
- }
+ const Byte* src = &(*begin);
+ Byte* dest = reinterpret_cast<Byte*>(&result[0]) + sizeof(Float) - 1;
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ dest += 2 * sizeof(Float);
+ }
# else
- copy(begin, i, reinterpret_cast<Byte*>(&result[0]));
+ copy(begin, i, reinterpret_cast<Byte*>(&result[0]));
# endif
#endif
}
else
{
- v.first = v.second = 0;
+ v.first = v.second = 0;
}
return result;
}
@@ -1179,25 +1179,25 @@ IceInternal::BasicStream::write(const Double* begin, const Double* end)
writeSize(sz);
if(sz > 0)
{
- Container::size_type pos = b.size();
- resize(pos + sz * sizeof(Double));
+ Container::size_type pos = b.size();
+ resize(pos + sz * sizeof(Double));
#ifdef ICE_BIG_ENDIAN
- const Byte* src = reinterpret_cast<const Byte*>(begin) + sizeof(Double) - 1;
- Byte* dest = &(*(b.begin() + pos));
- for(int j = 0 ; j < sz ; ++j)
- {
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- src += 2 * sizeof(Double);
- }
+ const Byte* src = reinterpret_cast<const Byte*>(begin) + sizeof(Double) - 1;
+ Byte* dest = &(*(b.begin() + pos));
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ src += 2 * sizeof(Double);
+ }
#else
- memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), sz * sizeof(Double));
+ memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), sz * sizeof(Double));
#endif
}
}
@@ -1207,7 +1207,7 @@ IceInternal::BasicStream::read(Double& v)
{
if(b.end() - i < static_cast<int>(sizeof(Double)))
{
- throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
+ throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
}
const Byte* src = &(*i);
i += sizeof(Double);
@@ -1241,32 +1241,32 @@ IceInternal::BasicStream::read(vector<Double>& v)
readSize(sz);
if(sz > 0)
{
- checkFixedSeq(sz, static_cast<int>(sizeof(Double)));
- Container::iterator begin = i;
- i += sz * static_cast<int>(sizeof(Double));
- v.resize(sz);
+ checkFixedSeq(sz, static_cast<int>(sizeof(Double)));
+ Container::iterator begin = i;
+ i += sz * static_cast<int>(sizeof(Double));
+ v.resize(sz);
#ifdef ICE_BIG_ENDIAN
- const Byte* src = &(*begin);
- Byte* dest = reinterpret_cast<Byte*>(&v[0]) + sizeof(Double) - 1;
- for(int j = 0 ; j < sz ; ++j)
- {
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- dest += 2 * sizeof(Double);
- }
+ const Byte* src = &(*begin);
+ Byte* dest = reinterpret_cast<Byte*>(&v[0]) + sizeof(Double) - 1;
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ dest += 2 * sizeof(Double);
+ }
#else
- copy(begin, i, reinterpret_cast<Byte*>(&v[0]));
+ copy(begin, i, reinterpret_cast<Byte*>(&v[0]));
#endif
}
else
{
- v.clear();
+ v.clear();
}
}
@@ -1278,41 +1278,41 @@ IceInternal::BasicStream::read(pair<const Double*, const Double*>& v)
readSize(sz);
if(sz > 0)
{
- checkFixedSeq(sz, static_cast<int>(sizeof(Double)));
+ checkFixedSeq(sz, static_cast<int>(sizeof(Double)));
#if defined(__i386) || defined(_M_IX86)
v.first = reinterpret_cast<Double*>(i);
- i += sz * static_cast<int>(sizeof(Double));
+ i += sz * static_cast<int>(sizeof(Double));
v.second = reinterpret_cast<Double*>(i);
#else
result = new Double[sz];
v.first = result;
v.second = result + sz;
- Container::iterator begin = i;
- i += sz * static_cast<int>(sizeof(Double));
+ Container::iterator begin = i;
+ i += sz * static_cast<int>(sizeof(Double));
# ifdef ICE_BIG_ENDIAN
- const Byte* src = &(*begin);
- Byte* dest = reinterpret_cast<Byte*>(&result[0]) + sizeof(Double) - 1;
- for(int j = 0 ; j < sz ; ++j)
- {
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- dest += 2 * sizeof(Double);
- }
+ const Byte* src = &(*begin);
+ Byte* dest = reinterpret_cast<Byte*>(&result[0]) + sizeof(Double) - 1;
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ dest += 2 * sizeof(Double);
+ }
# else
- copy(begin, i, reinterpret_cast<Byte*>(&result[0]));
+ copy(begin, i, reinterpret_cast<Byte*>(&result[0]));
# endif
#endif
}
else
{
- v.first = v.second = 0;
+ v.first = v.second = 0;
}
return result;
}
@@ -1339,22 +1339,22 @@ IceInternal::BasicStream::writeConverted(const string& v)
// Impossible to tell, so we guess. If we don't guess correctly,
// we'll have to fix the mistake afterwards
//
-
+
Int guessedSize = static_cast<Int>(v.size());
writeSize(guessedSize); // writeSize() only writes the size; it does not reserve any buffer space.
-
+
size_t firstIndex = b.size();
StreamUTF8BufferI buffer(*this);
-
+
Byte* lastByte = _stringConverter->toUTF8(v.data(), v.data() + v.size(), buffer);
if(lastByte != b.end())
{
b.resize(lastByte - b.begin());
}
size_t lastIndex = b.size();
-
+
Int actualSize = static_cast<Int>(lastIndex - firstIndex);
-
+
//
// Check against the guess
//
@@ -1362,29 +1362,29 @@ IceInternal::BasicStream::writeConverted(const string& v)
{
if(guessedSize <= 254 && actualSize > 254)
{
- //
- // Move the UTF-8 sequence 4 bytes further
- // Use memmove instead of memcpy since the source and destination typically overlap.
- //
- resize(b.size() + 4);
- memmove(b.begin() + firstIndex + 4, b.begin() + firstIndex, actualSize);
+ //
+ // Move the UTF-8 sequence 4 bytes further
+ // Use memmove instead of memcpy since the source and destination typically overlap.
+ //
+ resize(b.size() + 4);
+ memmove(b.begin() + firstIndex + 4, b.begin() + firstIndex, actualSize);
}
else if(guessedSize > 254 && actualSize <= 254)
{
- //
- // Move the UTF-8 sequence 4 bytes back
- //
- memmove(b.begin() + firstIndex - 4, b.begin() + firstIndex, actualSize);
- resize(b.size() - 4);
+ //
+ // Move the UTF-8 sequence 4 bytes back
+ //
+ memmove(b.begin() + firstIndex - 4, b.begin() + firstIndex, actualSize);
+ resize(b.size() - 4);
}
if(guessedSize <= 254)
{
- rewriteSize(actualSize, b.begin() + firstIndex - 1);
+ rewriteSize(actualSize, b.begin() + firstIndex - 1);
}
else
{
- rewriteSize(actualSize, b.begin() + firstIndex - 1 - 4);
+ rewriteSize(actualSize, b.begin() + firstIndex - 1 - 4);
}
}
}
@@ -1396,10 +1396,10 @@ IceInternal::BasicStream::write(const string* begin, const string* end, bool con
writeSize(sz);
if(sz > 0)
{
- for(int i = 0; i < sz; ++i)
- {
- write(begin[i], convert);
- }
+ for(int i = 0; i < sz; ++i)
+ {
+ write(begin[i], convert);
+ }
}
}
@@ -1410,15 +1410,15 @@ IceInternal::BasicStream::read(vector<string>& v, bool convert)
readSize(sz);
if(sz > 0)
{
- startSeq(sz, 1);
- v.resize(sz);
- for(int j = 0; j < sz; ++j)
- {
- read(v[j], convert);
- checkSeq();
- endElement();
- }
- endSeq(sz);
+ startSeq(sz, 1);
+ v.resize(sz);
+ for(int j = 0; j < sz; ++j)
+ {
+ read(v[j], convert);
+ checkSeq();
+ endElement();
+ }
+ endSeq(sz);
}
else
{
@@ -1432,7 +1432,7 @@ IceInternal::BasicStream::write(const wstring& v)
if(v.empty())
{
writeSize(0);
- return;
+ return;
}
//
@@ -1440,22 +1440,22 @@ IceInternal::BasicStream::write(const wstring& v)
// Impossible to tell, so we guess. If we don't guess correctly,
// we'll have to fix the mistake afterwards
//
-
+
Int guessedSize = static_cast<Int>(v.size());
writeSize(guessedSize); // writeSize() only writes the size; it does not reserve any buffer space.
-
+
size_t firstIndex = b.size();
StreamUTF8BufferI buffer(*this);
-
+
Byte* lastByte = _wstringConverter->toUTF8(v.data(), v.data() + v.size(), buffer);
if(lastByte != b.end())
{
b.resize(lastByte - b.begin());
}
size_t lastIndex = b.size();
-
+
Int actualSize = static_cast<Int>(lastIndex - firstIndex);
-
+
//
// Check against the guess
//
@@ -1463,29 +1463,29 @@ IceInternal::BasicStream::write(const wstring& v)
{
if(guessedSize <= 254 && actualSize > 254)
{
- //
- // Move the UTF-8 sequence 4 bytes further
- // Use memmove instead of memcpy since the source and destination typically overlap.
- //
- resize(b.size() + 4);
- memmove(b.begin() + firstIndex + 4, b.begin() + firstIndex, actualSize);
+ //
+ // Move the UTF-8 sequence 4 bytes further
+ // Use memmove instead of memcpy since the source and destination typically overlap.
+ //
+ resize(b.size() + 4);
+ memmove(b.begin() + firstIndex + 4, b.begin() + firstIndex, actualSize);
}
else if(guessedSize > 254 && actualSize <= 254)
{
- //
- // Move the UTF-8 sequence 4 bytes back
- //
- memmove(b.begin() + firstIndex - 4, b.begin() + firstIndex, actualSize);
- resize(b.size() - 4);
+ //
+ // Move the UTF-8 sequence 4 bytes back
+ //
+ memmove(b.begin() + firstIndex - 4, b.begin() + firstIndex, actualSize);
+ resize(b.size() - 4);
}
if(guessedSize <= 254)
{
- rewriteSize(actualSize, b.begin() + firstIndex - 1);
+ rewriteSize(actualSize, b.begin() + firstIndex - 1);
}
else
{
- rewriteSize(actualSize, b.begin() + firstIndex - 1 - 4);
+ rewriteSize(actualSize, b.begin() + firstIndex - 1 - 4);
}
}
}
@@ -1497,10 +1497,10 @@ IceInternal::BasicStream::write(const wstring* begin, const wstring* end)
writeSize(sz);
if(sz > 0)
{
- for(int i = 0; i < sz; ++i)
- {
- write(begin[i]);
- }
+ for(int i = 0; i < sz; ++i)
+ {
+ write(begin[i]);
+ }
}
}
@@ -1511,15 +1511,15 @@ IceInternal::BasicStream::read(vector<wstring>& v)
readSize(sz);
if(sz > 0)
{
- startSeq(sz, 1);
- v.resize(sz);
- for(int j = 0; j < sz; ++j)
- {
- read(v[j]);
- checkSeq();
- endElement();
- }
- endSeq(sz);
+ startSeq(sz, 1);
+ v.resize(sz);
+ for(int j = 0; j < sz; ++j)
+ {
+ read(v[j]);
+ checkSeq();
+ endElement();
+ }
+ endSeq(sz);
}
else
{
@@ -1544,50 +1544,50 @@ IceInternal::BasicStream::write(const ObjectPtr& v)
{
if(!_currentWriteEncaps) // Lazy initialization.
{
- _currentWriteEncaps = &_preAllocatedWriteEncaps;
- _currentWriteEncaps->start = b.size();
+ _currentWriteEncaps = &_preAllocatedWriteEncaps;
+ _currentWriteEncaps->start = b.size();
}
if(!_currentWriteEncaps->toBeMarshaledMap) // Lazy initialization.
{
- _currentWriteEncaps->toBeMarshaledMap = new PtrToIndexMap;
- _currentWriteEncaps->marshaledMap = new PtrToIndexMap;
- _currentWriteEncaps->typeIdMap = new TypeIdWriteMap;
+ _currentWriteEncaps->toBeMarshaledMap = new PtrToIndexMap;
+ _currentWriteEncaps->marshaledMap = new PtrToIndexMap;
+ _currentWriteEncaps->typeIdMap = new TypeIdWriteMap;
}
if(v)
{
- //
- // Look for this instance in the to-be-marshaled map.
- //
- PtrToIndexMap::iterator p = _currentWriteEncaps->toBeMarshaledMap->find(v);
- if(p == _currentWriteEncaps->toBeMarshaledMap->end())
- {
- //
- // Didn't find it, try the marshaled map next.
- //
- PtrToIndexMap::iterator q = _currentWriteEncaps->marshaledMap->find(v);
- if(q == _currentWriteEncaps->marshaledMap->end())
- {
- //
- // We haven't seen this instance previously, create a
- // new index, and insert it into the to-be-marshaled
- // map.
- //
- q = _currentWriteEncaps->toBeMarshaledMap->insert(
- _currentWriteEncaps->toBeMarshaledMap->end(),
- pair<const ObjectPtr, Int>(v, ++_currentWriteEncaps->writeIndex));
- }
- p = q;
- }
- //
- // Write the index for the instance.
- //
- write(-(p->second));
+ //
+ // Look for this instance in the to-be-marshaled map.
+ //
+ PtrToIndexMap::iterator p = _currentWriteEncaps->toBeMarshaledMap->find(v);
+ if(p == _currentWriteEncaps->toBeMarshaledMap->end())
+ {
+ //
+ // Didn't find it, try the marshaled map next.
+ //
+ PtrToIndexMap::iterator q = _currentWriteEncaps->marshaledMap->find(v);
+ if(q == _currentWriteEncaps->marshaledMap->end())
+ {
+ //
+ // We haven't seen this instance previously, create a
+ // new index, and insert it into the to-be-marshaled
+ // map.
+ //
+ q = _currentWriteEncaps->toBeMarshaledMap->insert(
+ _currentWriteEncaps->toBeMarshaledMap->end(),
+ pair<const ObjectPtr, Int>(v, ++_currentWriteEncaps->writeIndex));
+ }
+ p = q;
+ }
+ //
+ // Write the index for the instance.
+ //
+ write(-(p->second));
}
else
{
- write(0); // Write null pointer.
+ write(0); // Write null pointer.
}
}
@@ -1596,14 +1596,14 @@ IceInternal::BasicStream::read(PatchFunc patchFunc, void* patchAddr)
{
if(!_currentReadEncaps) // Lazy initialization.
{
- _currentReadEncaps = &_preAllocatedReadEncaps;
+ _currentReadEncaps = &_preAllocatedReadEncaps;
}
if(!_currentReadEncaps->patchMap) // Lazy initialization.
{
- _currentReadEncaps->patchMap = new PatchMap;
- _currentReadEncaps->unmarshaledMap = new IndexToPtrMap;
- _currentReadEncaps->typeIdMap = new TypeIdReadMap;
+ _currentReadEncaps->patchMap = new PatchMap;
+ _currentReadEncaps->unmarshaledMap = new IndexToPtrMap;
+ _currentReadEncaps->typeIdMap = new TypeIdReadMap;
}
ObjectPtr v;
@@ -1613,30 +1613,30 @@ IceInternal::BasicStream::read(PatchFunc patchFunc, void* patchAddr)
if(index == 0)
{
- patchFunc(patchAddr, v); // Null Ptr.
- return;
+ patchFunc(patchAddr, v); // Null Ptr.
+ return;
}
if(index < 0 && patchAddr)
{
- PatchMap::iterator p = _currentReadEncaps->patchMap->find(-index);
- if(p == _currentReadEncaps->patchMap->end())
- {
- //
- // We have no outstanding instances to be patched for this
- // index, so make a new entry in the patch map.
- //
- p = _currentReadEncaps->patchMap->insert(make_pair(-index, PatchList())).first;
- }
- //
- // Append a patch entry for this instance.
- //
- PatchEntry e;
- e.patchFunc = patchFunc;
- e.patchAddr = patchAddr;
- p->second.push_back(e);
- patchPointers(-index, _currentReadEncaps->unmarshaledMap->end(), p);
- return;
+ PatchMap::iterator p = _currentReadEncaps->patchMap->find(-index);
+ if(p == _currentReadEncaps->patchMap->end())
+ {
+ //
+ // We have no outstanding instances to be patched for this
+ // index, so make a new entry in the patch map.
+ //
+ p = _currentReadEncaps->patchMap->insert(make_pair(-index, PatchList())).first;
+ }
+ //
+ // Append a patch entry for this instance.
+ //
+ PatchEntry e;
+ e.patchFunc = patchFunc;
+ e.patchAddr = patchAddr;
+ p->second.push_back(e);
+ patchPointers(-index, _currentReadEncaps->unmarshaledMap->end(), p);
+ return;
}
assert(index > 0);
@@ -1645,16 +1645,16 @@ IceInternal::BasicStream::read(PatchFunc patchFunc, void* patchAddr)
string id = mostDerivedId;
while(true)
{
- //
- // If we slice all the way down to Ice::Object, we throw
- // because Ice::Object is abstract.
- //
+ //
+ // If we slice all the way down to Ice::Object, we throw
+ // because Ice::Object is abstract.
+ //
if(id == Ice::Object::ice_staticId())
- {
- throw NoObjectFactoryException(__FILE__, __LINE__,
- "class sliced to ::Ice::Object, which is abstract",
- mostDerivedId);
- }
+ {
+ throw NoObjectFactoryException(__FILE__, __LINE__,
+ "class sliced to ::Ice::Object, which is abstract",
+ mostDerivedId);
+ }
//
// Try to find a factory registered for the specific type.
@@ -1709,7 +1709,7 @@ IceInternal::BasicStream::read(PatchFunc patchFunc, void* patchAddr)
traceSlicing("class", id, _slicingCat, _instance->initializationData().logger);
}
skipSlice(); // Slice off this derived part -- we don't understand it.
- readTypeId(id); // Read next id for next iteration.
+ readTypeId(id); // Read next id for next iteration.
continue;
}
else
@@ -1720,8 +1720,8 @@ IceInternal::BasicStream::read(PatchFunc patchFunc, void* patchAddr)
}
}
- IndexToPtrMap::const_iterator unmarshaledPos =
- _currentReadEncaps->unmarshaledMap->insert(make_pair(index, v)).first;
+ IndexToPtrMap::const_iterator unmarshaledPos =
+ _currentReadEncaps->unmarshaledMap->insert(make_pair(index, v)).first;
//
// Record each object instance so that readPendingObjects can
@@ -1734,9 +1734,9 @@ IceInternal::BasicStream::read(PatchFunc patchFunc, void* patchAddr)
}
_objectList->push_back(v);
- v->__read(this, false);
- patchPointers(index, unmarshaledPos, _currentReadEncaps->patchMap->end());
- return;
+ v->__read(this, false);
+ patchPointers(index, unmarshaledPos, _currentReadEncaps->patchMap->end());
+ return;
}
//
@@ -1754,7 +1754,7 @@ IceInternal::BasicStream::write(const UserException& v)
v.__write(this);
if(v.__usesClasses())
{
- writePendingObjects();
+ writePendingObjects();
}
}
@@ -1768,49 +1768,49 @@ IceInternal::BasicStream::throwException()
read(id, false);
for(;;)
{
- //
- // Look for a factory for this ID.
- //
- UserExceptionFactoryPtr factory = factoryTable->getExceptionFactory(id);
- if(factory)
- {
- //
- // Got factory -- get the factory to instantiate the
- // exception, initialize the exception members, and throw
- // the exception.
- //
- try
- {
- factory->createAndThrow();
- }
- catch(UserException& ex)
- {
- ex.__read(this, false);
- if(usesClasses)
- {
- readPendingObjects();
- }
- ex.ice_throw();
- }
- }
- else
- {
- //
- // Performance sensitive, so we use lazy initialization
- // for tracing.
- //
- if(_traceSlicing == -1)
- {
- _traceSlicing = _instance->traceLevels()->slicing;
- _slicingCat = _instance->traceLevels()->slicingCat;
- }
- if(_traceSlicing > 0)
- {
- traceSlicing("exception", id, _slicingCat, _instance->initializationData().logger);
- }
- skipSlice(); // Slice off what we don't understand.
- read(id, false); // Read type id for next slice.
- }
+ //
+ // Look for a factory for this ID.
+ //
+ UserExceptionFactoryPtr factory = factoryTable->getExceptionFactory(id);
+ if(factory)
+ {
+ //
+ // Got factory -- get the factory to instantiate the
+ // exception, initialize the exception members, and throw
+ // the exception.
+ //
+ try
+ {
+ factory->createAndThrow();
+ }
+ catch(UserException& ex)
+ {
+ ex.__read(this, false);
+ if(usesClasses)
+ {
+ readPendingObjects();
+ }
+ ex.ice_throw();
+ }
+ }
+ else
+ {
+ //
+ // Performance sensitive, so we use lazy initialization
+ // for tracing.
+ //
+ if(_traceSlicing == -1)
+ {
+ _traceSlicing = _instance->traceLevels()->slicing;
+ _slicingCat = _instance->traceLevels()->slicingCat;
+ }
+ if(_traceSlicing > 0)
+ {
+ traceSlicing("exception", id, _slicingCat, _instance->initializationData().logger);
+ }
+ skipSlice(); // Slice off what we don't understand.
+ read(id, false); // Read type id for next slice.
+ }
}
//
@@ -1827,35 +1827,35 @@ IceInternal::BasicStream::writePendingObjects()
{
if(_currentWriteEncaps && _currentWriteEncaps->toBeMarshaledMap)
{
- while(_currentWriteEncaps->toBeMarshaledMap->size())
- {
- PtrToIndexMap savedMap = *_currentWriteEncaps->toBeMarshaledMap;
- writeSize(static_cast<Int>(savedMap.size()));
- for(PtrToIndexMap::iterator p = savedMap.begin(); p != savedMap.end(); ++p)
- {
- //
- // Add an instance from the old to-be-marshaled map to
- // the marshaled map and then ask the instance to
- // marshal itself. Any new class instances that are
- // triggered by the classes marshaled are added to
- // toBeMarshaledMap.
- //
- _currentWriteEncaps->marshaledMap->insert(*p);
- writeInstance(p->first, p->second);
- }
-
- //
- // We have marshaled all the instances for this pass,
- // substract what we have marshaled from the
- // toBeMarshaledMap.
- //
- PtrToIndexMap newMap;
- set_difference(_currentWriteEncaps->toBeMarshaledMap->begin(),
- _currentWriteEncaps->toBeMarshaledMap->end(),
- savedMap.begin(), savedMap.end(),
- insert_iterator<PtrToIndexMap>(newMap, newMap.begin()));
- *_currentWriteEncaps->toBeMarshaledMap = newMap;
- }
+ while(_currentWriteEncaps->toBeMarshaledMap->size())
+ {
+ PtrToIndexMap savedMap = *_currentWriteEncaps->toBeMarshaledMap;
+ writeSize(static_cast<Int>(savedMap.size()));
+ for(PtrToIndexMap::iterator p = savedMap.begin(); p != savedMap.end(); ++p)
+ {
+ //
+ // Add an instance from the old to-be-marshaled map to
+ // the marshaled map and then ask the instance to
+ // marshal itself. Any new class instances that are
+ // triggered by the classes marshaled are added to
+ // toBeMarshaledMap.
+ //
+ _currentWriteEncaps->marshaledMap->insert(*p);
+ writeInstance(p->first, p->second);
+ }
+
+ //
+ // We have marshaled all the instances for this pass,
+ // substract what we have marshaled from the
+ // toBeMarshaledMap.
+ //
+ PtrToIndexMap newMap;
+ set_difference(_currentWriteEncaps->toBeMarshaledMap->begin(),
+ _currentWriteEncaps->toBeMarshaledMap->end(),
+ savedMap.begin(), savedMap.end(),
+ insert_iterator<PtrToIndexMap>(newMap, newMap.begin()));
+ *_currentWriteEncaps->toBeMarshaledMap = newMap;
+ }
}
writeSize(0); // Zero marker indicates end of sequence of sequences of instances.
}
@@ -1866,11 +1866,11 @@ IceInternal::BasicStream::readPendingObjects()
Int num;
do
{
- readSize(num);
- for(Int k = num; k > 0; --k)
- {
- read(0, 0);
- }
+ readSize(num);
+ for(Int k = num; k > 0; --k)
+ {
+ read(0, 0);
+ }
}
while(num);
@@ -1970,7 +1970,7 @@ IceInternal::BasicStream::writeInstance(const ObjectPtr& v, Int index)
void
IceInternal::BasicStream::patchPointers(Int index, IndexToPtrMap::const_iterator unmarshaledPos,
- PatchMap::iterator patchPos)
+ PatchMap::iterator patchPos)
{
//
// Called whenever we have unmarshaled a new instance. The index
@@ -1981,34 +1981,34 @@ IceInternal::BasicStream::patchPointers(Int index, IndexToPtrMap::const_iterator
// with the new address.
//
assert( (unmarshaledPos != _currentReadEncaps->unmarshaledMap->end()
- && patchPos == _currentReadEncaps->patchMap->end())
- || (unmarshaledPos == _currentReadEncaps->unmarshaledMap->end()
- && patchPos != _currentReadEncaps->patchMap->end())
- );
+ && patchPos == _currentReadEncaps->patchMap->end())
+ || (unmarshaledPos == _currentReadEncaps->unmarshaledMap->end()
+ && patchPos != _currentReadEncaps->patchMap->end())
+ );
if(unmarshaledPos != _currentReadEncaps->unmarshaledMap->end())
{
- //
- // We have just unmarshaled an instance -- check if something
- // needs patching for that instance.
- //
- patchPos = _currentReadEncaps->patchMap->find(index);
- if(patchPos == _currentReadEncaps->patchMap->end())
- {
- return; // We don't have anything to patch for the instance just unmarshaled.
- }
+ //
+ // We have just unmarshaled an instance -- check if something
+ // needs patching for that instance.
+ //
+ patchPos = _currentReadEncaps->patchMap->find(index);
+ if(patchPos == _currentReadEncaps->patchMap->end())
+ {
+ return; // We don't have anything to patch for the instance just unmarshaled.
+ }
}
else
{
- //
- // We have just unmarshaled an index -- check if we have
- // unmarshaled the instance for that index yet.
- //
- unmarshaledPos = _currentReadEncaps->unmarshaledMap->find(index);
- if(unmarshaledPos == _currentReadEncaps->unmarshaledMap->end())
- {
- return; // We haven't unmarshaled the instance yet.
- }
+ //
+ // We have just unmarshaled an index -- check if we have
+ // unmarshaled the instance for that index yet.
+ //
+ unmarshaledPos = _currentReadEncaps->unmarshaledMap->find(index);
+ if(unmarshaledPos == _currentReadEncaps->unmarshaledMap->end())
+ {
+ return; // We haven't unmarshaled the instance yet.
+ }
}
assert(patchPos->second.size() > 0);
@@ -2020,7 +2020,7 @@ IceInternal::BasicStream::patchPointers(Int index, IndexToPtrMap::const_iterator
//
for(PatchList::iterator k = patchPos->second.begin(); k != patchPos->second.end(); ++k)
{
- (*k->patchFunc)(k->patchAddr, v);
+ (*k->patchFunc)(k->patchAddr, v);
}
//
diff --git a/cpp/src/Ice/Buffer.cpp b/cpp/src/Ice/Buffer.cpp
index b0b4ffecdd7..ba09f6f3cfb 100644
--- a/cpp/src/Ice/Buffer.cpp
+++ b/cpp/src/Ice/Buffer.cpp
@@ -58,31 +58,31 @@ IceInternal::Buffer::Container::reserve(size_type n)
{
if(n > _capacity)
{
- _capacity = std::max<size_type>(n, std::min(2 * _capacity, _maxCapacity));
- _capacity = std::max<size_type>(static_cast<size_type>(240), _capacity);
+ _capacity = std::max<size_type>(n, std::min(2 * _capacity, _maxCapacity));
+ _capacity = std::max<size_type>(static_cast<size_type>(240), _capacity);
}
else if(n < _capacity)
{
- _capacity = n;
+ _capacity = n;
}
else
{
- return;
+ return;
}
if(_buf)
{
- _buf = reinterpret_cast<pointer>(::realloc(_buf, _capacity));
+ _buf = reinterpret_cast<pointer>(::realloc(_buf, _capacity));
}
else
{
- _buf = reinterpret_cast<pointer>(::malloc(_capacity));
+ _buf = reinterpret_cast<pointer>(::malloc(_capacity));
}
-
+
if(!_buf)
{
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
}
}
diff --git a/cpp/src/Ice/CommunicatorI.cpp b/cpp/src/Ice/CommunicatorI.cpp
index ec72da06d01..c7ca49ea899 100644
--- a/cpp/src/Ice/CommunicatorI.cpp
+++ b/cpp/src/Ice/CommunicatorI.cpp
@@ -35,7 +35,7 @@ IceUtil::Handle<IceInternal::GC> theCollector = 0;
struct GarbageCollectorStats
{
GarbageCollectorStats() :
- runs(0), examined(0), collected(0)
+ runs(0), examined(0), collected(0)
{
}
int runs;
@@ -56,15 +56,15 @@ printGCStats(const IceInternal::GCStats& stats)
{
if(gcTraceLevel)
{
- if(gcTraceLevel > 1)
- {
- Trace out(getProcessLogger(), gcTraceCat);
- out << stats.collected << "/" << stats.examined << ", " << stats.time * 1000 << "ms";
- }
- ++gcStats.runs;
- gcStats.examined += stats.examined;
- gcStats.collected += stats.collected;
- gcStats.time += stats.time;
+ if(gcTraceLevel > 1)
+ {
+ Trace out(getProcessLogger(), gcTraceCat);
+ out << stats.collected << "/" << stats.examined << ", " << stats.time * 1000 << "ms";
+ }
+ ++gcStats.runs;
+ gcStats.examined += stats.examined;
+ gcStats.collected += stats.collected;
+ gcStats.time += stats.time;
}
}
@@ -73,37 +73,37 @@ Ice::CommunicatorI::destroy()
{
if(_instance->destroy())
{
- IceUtil::StaticMutex::Lock sync(gcMutex);
-
- //
- // Wait for the collector thread to stop if this is the last communicator
- // to be destroyed.
- //
- bool last = (--communicatorCount == 0);
- if(last && gcInterval > 0 && theCollector)
- {
- theCollector->stop();
- }
-
- if(theCollector)
+ IceUtil::StaticMutex::Lock sync(gcMutex);
+
+ //
+ // Wait for the collector thread to stop if this is the last communicator
+ // to be destroyed.
+ //
+ bool last = (--communicatorCount == 0);
+ if(last && gcInterval > 0 && theCollector)
+ {
+ theCollector->stop();
+ }
+
+ if(theCollector)
{
- theCollector->collectGarbage(); // Collect whenever a communicator is destroyed.
- }
-
- if(last)
- {
- if(gcTraceLevel)
- {
- Trace out(getProcessLogger(), gcTraceCat);
- out << "totals: " << gcStats.collected << "/" << gcStats.examined << ", "
- << gcStats.time * 1000 << "ms" << ", " << gcStats.runs << " run";
- if(gcStats.runs != 1)
- {
- out << "s";
- }
- }
- theCollector = 0; // Force destruction of the collector.
- }
+ theCollector->collectGarbage(); // Collect whenever a communicator is destroyed.
+ }
+
+ if(last)
+ {
+ if(gcTraceLevel)
+ {
+ Trace out(getProcessLogger(), gcTraceCat);
+ out << "totals: " << gcStats.collected << "/" << gcStats.examined << ", "
+ << gcStats.time * 1000 << "ms" << ", " << gcStats.runs << " run";
+ if(gcStats.runs != 1)
+ {
+ out << "s";
+ }
+ }
+ theCollector = 0; // Force destruction of the collector.
+ }
}
}
@@ -263,47 +263,47 @@ Ice::CommunicatorI::CommunicatorI(const InitializationData& initData)
__setNoDelete(true);
try
{
- const_cast<InstancePtr&>(_instance) = new Instance(this, initData);
+ const_cast<InstancePtr&>(_instance) = new Instance(this, initData);
//
// Keep a reference to the dynamic library list to ensure
// the libraries are not unloaded until this Communicator's
// destructor is invoked.
//
- const_cast<DynamicLibraryListPtr&>(_dynamicLibraryList) = _instance->dynamicLibraryList();
+ const_cast<DynamicLibraryListPtr&>(_dynamicLibraryList) = _instance->dynamicLibraryList();
}
catch(...)
{
- __setNoDelete(false);
- throw;
+ __setNoDelete(false);
+ throw;
}
__setNoDelete(false);
{
- //
- // If this is the first communicator that is created, use that communicator's
- // property settings to determine whether to start the garbage collector.
- // We remember that communicator's trace and logger settings so the garbage
- // collector can continue to log messages even if the first communicator that
- // is created isn't the last communicator to be destroyed.
- //
- IceUtil::StaticMutex::Lock sync(gcMutex);
- static bool gcOnce = true;
- if(gcOnce)
- {
- gcTraceLevel = _instance->traceLevels()->gc;
- gcTraceCat = _instance->traceLevels()->gcCat;
- gcInterval = _instance->initializationData().properties->getPropertyAsInt("Ice.GC.Interval");
- gcOnce = false;
- }
- if(++communicatorCount == 1)
- {
- theCollector = new IceInternal::GC(gcInterval, printGCStats);
- if(gcInterval > 0)
- {
- theCollector->start();
- }
- }
+ //
+ // If this is the first communicator that is created, use that communicator's
+ // property settings to determine whether to start the garbage collector.
+ // We remember that communicator's trace and logger settings so the garbage
+ // collector can continue to log messages even if the first communicator that
+ // is created isn't the last communicator to be destroyed.
+ //
+ IceUtil::StaticMutex::Lock sync(gcMutex);
+ static bool gcOnce = true;
+ if(gcOnce)
+ {
+ gcTraceLevel = _instance->traceLevels()->gc;
+ gcTraceCat = _instance->traceLevels()->gcCat;
+ gcInterval = _instance->initializationData().properties->getPropertyAsInt("Ice.GC.Interval");
+ gcOnce = false;
+ }
+ if(++communicatorCount == 1)
+ {
+ theCollector = new IceInternal::GC(gcInterval, printGCStats);
+ if(gcInterval > 0)
+ {
+ theCollector->start();
+ }
+ }
}
}
@@ -311,8 +311,8 @@ Ice::CommunicatorI::~CommunicatorI()
{
if(!_instance->destroyed())
{
- Warning out(_instance->initializationData().logger);
- out << "Ice::Communicator::destroy() has not been called";
+ Warning out(_instance->initializationData().logger);
+ out << "Ice::Communicator::destroy() has not been called";
}
}
@@ -321,11 +321,11 @@ Ice::CommunicatorI::finishSetup(int& argc, char* argv[])
{
try
{
- _instance->finishSetup(argc, argv);
+ _instance->finishSetup(argc, argv);
}
catch(...)
{
- _instance->destroy();
- throw;
+ _instance->destroy();
+ throw;
}
}
diff --git a/cpp/src/Ice/ConnectionFactory.cpp b/cpp/src/Ice/ConnectionFactory.cpp
index 5b33b528d5a..3008dfaa485 100644
--- a/cpp/src/Ice/ConnectionFactory.cpp
+++ b/cpp/src/Ice/ConnectionFactory.cpp
@@ -45,18 +45,18 @@ IceInternal::OutgoingConnectionFactory::destroy()
if(_destroyed)
{
- return;
+ return;
}
#ifdef _STLP_BEGIN_NAMESPACE
// voidbind2nd is an STLport extension for broken compilers in IceUtil/Functional.h
for_each(_connections.begin(), _connections.end(),
- voidbind2nd(Ice::secondVoidMemFun1<EndpointIPtr, ConnectionI, ConnectionI::DestructionReason>
- (&ConnectionI::destroy), ConnectionI::CommunicatorDestroyed));
+ voidbind2nd(Ice::secondVoidMemFun1<EndpointIPtr, ConnectionI, ConnectionI::DestructionReason>
+ (&ConnectionI::destroy), ConnectionI::CommunicatorDestroyed));
#else
for_each(_connections.begin(), _connections.end(),
- bind2nd(Ice::secondVoidMemFun1<const EndpointIPtr, ConnectionI, ConnectionI::DestructionReason>
- (&ConnectionI::destroy), ConnectionI::CommunicatorDestroyed));
+ bind2nd(Ice::secondVoidMemFun1<const EndpointIPtr, ConnectionI, ConnectionI::DestructionReason>
+ (&ConnectionI::destroy), ConnectionI::CommunicatorDestroyed));
#endif
_destroyed = true;
@@ -69,27 +69,27 @@ IceInternal::OutgoingConnectionFactory::waitUntilFinished()
multimap<EndpointIPtr, ConnectionIPtr> connections;
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- //
- // First we wait until the factory is destroyed. We also wait
- // until there are no pending connections anymore. Only then
- // we can be sure the _connections contains all connections.
- //
- while(!_destroyed || !_pending.empty())
- {
- wait();
- }
-
- //
- // We want to wait until all connections are finished outside the
- // thread synchronization.
- //
- connections.swap(_connections);
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ //
+ // First we wait until the factory is destroyed. We also wait
+ // until there are no pending connections anymore. Only then
+ // we can be sure the _connections contains all connections.
+ //
+ while(!_destroyed || !_pending.empty())
+ {
+ wait();
+ }
+
+ //
+ // We want to wait until all connections are finished outside the
+ // thread synchronization.
+ //
+ connections.swap(_connections);
}
for_each(connections.begin(), connections.end(),
- Ice::secondVoidMemFun<const EndpointIPtr, ConnectionI>(&ConnectionI::waitUntilFinished));
+ Ice::secondVoidMemFun<const EndpointIPtr, ConnectionI>(&ConnectionI::waitUntilFinished));
}
ConnectionIPtr
@@ -100,131 +100,131 @@ IceInternal::OutgoingConnectionFactory::create(const vector<EndpointIPtr>& endpt
vector<EndpointIPtr> endpoints = endpts;
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- if(_destroyed)
- {
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
- }
-
- //
- // Reap connections for which destruction has completed.
- //
- std::multimap<EndpointIPtr, ConnectionIPtr>::iterator p = _connections.begin();
- while(p != _connections.end())
- {
- if(p->second->isFinished())
- {
- _connections.erase(p++);
- }
- else
- {
- ++p;
- }
- }
-
- //
- // Modify endpoints with overrides.
- //
- vector<EndpointIPtr>::iterator q;
- for(q = endpoints.begin(); q != endpoints.end(); ++q)
- {
- if(_instance->defaultsAndOverrides()->overrideTimeout)
- {
- *q = (*q)->timeout(_instance->defaultsAndOverrides()->overrideTimeoutValue);
- }
-
- //
- // The Connection object does not take the compression flag of
- // endpoints into account, but instead gets the information
- // about whether messages should be compressed or not from
- // other sources. In order to allow connection sharing for
- // endpoints that differ in the value of the compression flag
- // only, we always set the compression flag to false here in
- // this connection factory.
- //
- *q = (*q)->compress(false);
- }
-
- //
- // Search for existing connections.
- //
- vector<EndpointIPtr>::const_iterator r;
- for(q = endpoints.begin(), r = endpts.begin(); q != endpoints.end(); ++q, ++r)
- {
- pair<multimap<EndpointIPtr, ConnectionIPtr>::iterator,
- multimap<EndpointIPtr, ConnectionIPtr>::iterator> pr = _connections.equal_range(*q);
-
- while(pr.first != pr.second)
- {
- //
- // Don't return connections for which destruction has
- // been initiated. The connection must also match the
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ if(_destroyed)
+ {
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ }
+
+ //
+ // Reap connections for which destruction has completed.
+ //
+ std::multimap<EndpointIPtr, ConnectionIPtr>::iterator p = _connections.begin();
+ while(p != _connections.end())
+ {
+ if(p->second->isFinished())
+ {
+ _connections.erase(p++);
+ }
+ else
+ {
+ ++p;
+ }
+ }
+
+ //
+ // Modify endpoints with overrides.
+ //
+ vector<EndpointIPtr>::iterator q;
+ for(q = endpoints.begin(); q != endpoints.end(); ++q)
+ {
+ if(_instance->defaultsAndOverrides()->overrideTimeout)
+ {
+ *q = (*q)->timeout(_instance->defaultsAndOverrides()->overrideTimeoutValue);
+ }
+
+ //
+ // The Connection object does not take the compression flag of
+ // endpoints into account, but instead gets the information
+ // about whether messages should be compressed or not from
+ // other sources. In order to allow connection sharing for
+ // endpoints that differ in the value of the compression flag
+ // only, we always set the compression flag to false here in
+ // this connection factory.
+ //
+ *q = (*q)->compress(false);
+ }
+
+ //
+ // Search for existing connections.
+ //
+ vector<EndpointIPtr>::const_iterator r;
+ for(q = endpoints.begin(), r = endpts.begin(); q != endpoints.end(); ++q, ++r)
+ {
+ pair<multimap<EndpointIPtr, ConnectionIPtr>::iterator,
+ multimap<EndpointIPtr, ConnectionIPtr>::iterator> pr = _connections.equal_range(*q);
+
+ while(pr.first != pr.second)
+ {
+ //
+ // Don't return connections for which destruction has
+ // been initiated. The connection must also match the
// requested thread-per-connection setting.
- //
- if(!pr.first->second->isDestroyed() &&
+ //
+ if(!pr.first->second->isDestroyed() &&
pr.first->second->threadPerConnection() == threadPerConnection)
- {
- if(_instance->defaultsAndOverrides()->overrideCompress)
- {
- compress = _instance->defaultsAndOverrides()->overrideCompressValue;
- }
- else
- {
- compress = (*r)->compress();
- }
-
- return pr.first->second;
- }
-
- ++pr.first;
- }
- }
-
- //
- // If some other thread is currently trying to establish a
- // connection to any of our endpoints, we wait until this
- // thread is finished.
- //
- bool searchAgain = false;
- while(!_destroyed)
- {
- for(q = endpoints.begin(); q != endpoints.end(); ++q)
- {
- if(_pending.find(*q) != _pending.end())
- {
- break;
- }
- }
-
- if(q == endpoints.end())
- {
- break;
- }
-
- searchAgain = true;
-
- wait();
- }
-
- if(_destroyed)
- {
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
- }
-
- //
- // Search for existing connections again if we waited above,
- // as new connections might have been added in the meantime.
- //
- if(searchAgain)
- {
- for(q = endpoints.begin(), r = endpts.begin(); q != endpoints.end(); ++q, ++r)
- {
- pair<multimap<EndpointIPtr, ConnectionIPtr>::iterator,
- multimap<EndpointIPtr, ConnectionIPtr>::iterator> pr = _connections.equal_range(*q);
-
- while(pr.first != pr.second)
- {
+ {
+ if(_instance->defaultsAndOverrides()->overrideCompress)
+ {
+ compress = _instance->defaultsAndOverrides()->overrideCompressValue;
+ }
+ else
+ {
+ compress = (*r)->compress();
+ }
+
+ return pr.first->second;
+ }
+
+ ++pr.first;
+ }
+ }
+
+ //
+ // If some other thread is currently trying to establish a
+ // connection to any of our endpoints, we wait until this
+ // thread is finished.
+ //
+ bool searchAgain = false;
+ while(!_destroyed)
+ {
+ for(q = endpoints.begin(); q != endpoints.end(); ++q)
+ {
+ if(_pending.find(*q) != _pending.end())
+ {
+ break;
+ }
+ }
+
+ if(q == endpoints.end())
+ {
+ break;
+ }
+
+ searchAgain = true;
+
+ wait();
+ }
+
+ if(_destroyed)
+ {
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ }
+
+ //
+ // Search for existing connections again if we waited above,
+ // as new connections might have been added in the meantime.
+ //
+ if(searchAgain)
+ {
+ for(q = endpoints.begin(), r = endpts.begin(); q != endpoints.end(); ++q, ++r)
+ {
+ pair<multimap<EndpointIPtr, ConnectionIPtr>::iterator,
+ multimap<EndpointIPtr, ConnectionIPtr>::iterator> pr = _connections.equal_range(*q);
+
+ while(pr.first != pr.second)
+ {
//
// Don't return connections for which destruction has
// been initiated. The connection must also match the
@@ -232,31 +232,31 @@ IceInternal::OutgoingConnectionFactory::create(const vector<EndpointIPtr>& endpt
//
if(!pr.first->second->isDestroyed() &&
pr.first->second->threadPerConnection() == threadPerConnection)
- {
- if(_instance->defaultsAndOverrides()->overrideCompress)
- {
- compress = _instance->defaultsAndOverrides()->overrideCompressValue;
- }
- else
- {
- compress = (*r)->compress();
- }
-
- return pr.first->second;
- }
-
- ++pr.first;
- }
- }
- }
-
- //
- // No connection to any of our endpoints exists yet, so we
- // will try to create one. To avoid that other threads try to
- // create connections to the same endpoints, we add our
- // endpoints to _pending.
- //
- _pending.insert(endpoints.begin(), endpoints.end());
+ {
+ if(_instance->defaultsAndOverrides()->overrideCompress)
+ {
+ compress = _instance->defaultsAndOverrides()->overrideCompressValue;
+ }
+ else
+ {
+ compress = (*r)->compress();
+ }
+
+ return pr.first->second;
+ }
+
+ ++pr.first;
+ }
+ }
+ }
+
+ //
+ // No connection to any of our endpoints exists yet, so we
+ // will try to create one. To avoid that other threads try to
+ // create connections to the same endpoints, we add our
+ // endpoints to _pending.
+ //
+ _pending.insert(endpoints.begin(), endpoints.end());
}
ConnectionIPtr connection;
@@ -266,112 +266,112 @@ IceInternal::OutgoingConnectionFactory::create(const vector<EndpointIPtr>& endpt
vector<EndpointIPtr>::const_iterator r;
for(q = endpoints.begin(), r = endpts.begin(); q != endpoints.end(); ++q, ++r)
{
- EndpointIPtr endpoint = *q;
-
- try
- {
- TransceiverPtr transceiver = endpoint->clientTransceiver();
- if(!transceiver)
- {
- ConnectorPtr connector = endpoint->connector();
- assert(connector);
-
- Int timeout;
- if(_instance->defaultsAndOverrides()->overrideConnectTimeout)
- {
- timeout = _instance->defaultsAndOverrides()->overrideConnectTimeoutValue;
- }
- // It is not necessary to check for overrideTimeout,
- // the endpoint has already been modified with this
- // override, if set.
- else
- {
- timeout = endpoint->timeout();
- }
-
- transceiver = connector->connect(timeout);
- assert(transceiver);
- }
- connection = new ConnectionI(_instance, transceiver, endpoint, 0, threadPerConnection,
+ EndpointIPtr endpoint = *q;
+
+ try
+ {
+ TransceiverPtr transceiver = endpoint->clientTransceiver();
+ if(!transceiver)
+ {
+ ConnectorPtr connector = endpoint->connector();
+ assert(connector);
+
+ Int timeout;
+ if(_instance->defaultsAndOverrides()->overrideConnectTimeout)
+ {
+ timeout = _instance->defaultsAndOverrides()->overrideConnectTimeoutValue;
+ }
+ // It is not necessary to check for overrideTimeout,
+ // the endpoint has already been modified with this
+ // override, if set.
+ else
+ {
+ timeout = endpoint->timeout();
+ }
+
+ transceiver = connector->connect(timeout);
+ assert(transceiver);
+ }
+ connection = new ConnectionI(_instance, transceiver, endpoint, 0, threadPerConnection,
_instance->threadPerConnectionStackSize());
- connection->validate();
-
- if(_instance->defaultsAndOverrides()->overrideCompress)
- {
- compress = _instance->defaultsAndOverrides()->overrideCompressValue;
- }
- else
- {
- compress = (*r)->compress();
- }
- break;
- }
- catch(const LocalException& ex)
- {
- exception.reset(dynamic_cast<LocalException*>(ex.ice_clone()));
-
- //
- // If a connection object was constructed, then validate()
- // must have raised the exception.
- //
- if(connection)
- {
- connection->waitUntilFinished(); // We must call waitUntilFinished() for cleanup.
- connection = 0;
- }
- }
-
- TraceLevelsPtr traceLevels = _instance->traceLevels();
- if(traceLevels->retry >= 2)
- {
- Trace out(_instance->initializationData().logger, traceLevels->retryCat);
-
- out << "connection to endpoint failed";
- if(moreEndpts || q + 1 != endpoints.end())
- {
- out << ", trying next endpoint\n";
- }
- else
- {
- out << " and no more endpoints to try\n";
- }
- out << *exception.get();
- }
+ connection->validate();
+
+ if(_instance->defaultsAndOverrides()->overrideCompress)
+ {
+ compress = _instance->defaultsAndOverrides()->overrideCompressValue;
+ }
+ else
+ {
+ compress = (*r)->compress();
+ }
+ break;
+ }
+ catch(const LocalException& ex)
+ {
+ exception.reset(dynamic_cast<LocalException*>(ex.ice_clone()));
+
+ //
+ // If a connection object was constructed, then validate()
+ // must have raised the exception.
+ //
+ if(connection)
+ {
+ connection->waitUntilFinished(); // We must call waitUntilFinished() for cleanup.
+ connection = 0;
+ }
+ }
+
+ TraceLevelsPtr traceLevels = _instance->traceLevels();
+ if(traceLevels->retry >= 2)
+ {
+ Trace out(_instance->initializationData().logger, traceLevels->retryCat);
+
+ out << "connection to endpoint failed";
+ if(moreEndpts || q + 1 != endpoints.end())
+ {
+ out << ", trying next endpoint\n";
+ }
+ else
+ {
+ out << " and no more endpoints to try\n";
+ }
+ out << *exception.get();
+ }
}
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- //
- // Signal other threads that we are done with trying to
- // establish connections to our endpoints.
- //
- for(q = endpoints.begin(); q != endpoints.end(); ++q)
- {
- _pending.erase(*q);
- }
- notifyAll();
-
- if(!connection)
- {
- assert(exception.get());
- exception->ice_throw();
- }
- else
- {
- _connections.insert(_connections.end(),
- pair<const EndpointIPtr, ConnectionIPtr>(connection->endpoint(), connection));
-
- if(_destroyed)
- {
- connection->destroy(ConnectionI::CommunicatorDestroyed);
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
- }
- else
- {
- connection->activate();
- }
- }
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ //
+ // Signal other threads that we are done with trying to
+ // establish connections to our endpoints.
+ //
+ for(q = endpoints.begin(); q != endpoints.end(); ++q)
+ {
+ _pending.erase(*q);
+ }
+ notifyAll();
+
+ if(!connection)
+ {
+ assert(exception.get());
+ exception->ice_throw();
+ }
+ else
+ {
+ _connections.insert(_connections.end(),
+ pair<const EndpointIPtr, ConnectionIPtr>(connection->endpoint(), connection));
+
+ if(_destroyed)
+ {
+ connection->destroy(ConnectionI::CommunicatorDestroyed);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ }
+ else
+ {
+ connection->activate();
+ }
+ }
}
assert(connection);
@@ -385,7 +385,7 @@ IceInternal::OutgoingConnectionFactory::setRouterInfo(const RouterInfoPtr& route
if(_destroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
assert(routerInfo);
@@ -401,44 +401,44 @@ IceInternal::OutgoingConnectionFactory::setRouterInfo(const RouterInfoPtr& route
vector<EndpointIPtr>::const_iterator p;
for(p = endpoints.begin(); p != endpoints.end(); ++p)
{
- EndpointIPtr endpoint = *p;
-
- //
- // Modify endpoints with overrides.
- //
- if(_instance->defaultsAndOverrides()->overrideTimeout)
- {
- endpoint = endpoint->timeout(_instance->defaultsAndOverrides()->overrideTimeoutValue);
- }
-
- //
- // The Connection object does not take the compression flag of
- // endpoints into account, but instead gets the information
- // about whether messages should be compressed or not from
- // other sources. In order to allow connection sharing for
- // endpoints that differ in the value of the compression flag
- // only, we always set the compression flag to false here in
- // this connection factory.
- //
- endpoint = endpoint->compress(false);
-
- pair<multimap<EndpointIPtr, ConnectionIPtr>::iterator,
- multimap<EndpointIPtr, ConnectionIPtr>::iterator> pr = _connections.equal_range(endpoint);
-
- while(pr.first != pr.second)
- {
- try
- {
- pr.first->second->setAdapter(adapter);
- }
- catch(const Ice::LocalException&)
- {
- //
- // Ignore, the connection is being closed or closed.
- //
- }
- ++pr.first;
- }
+ EndpointIPtr endpoint = *p;
+
+ //
+ // Modify endpoints with overrides.
+ //
+ if(_instance->defaultsAndOverrides()->overrideTimeout)
+ {
+ endpoint = endpoint->timeout(_instance->defaultsAndOverrides()->overrideTimeoutValue);
+ }
+
+ //
+ // The Connection object does not take the compression flag of
+ // endpoints into account, but instead gets the information
+ // about whether messages should be compressed or not from
+ // other sources. In order to allow connection sharing for
+ // endpoints that differ in the value of the compression flag
+ // only, we always set the compression flag to false here in
+ // this connection factory.
+ //
+ endpoint = endpoint->compress(false);
+
+ pair<multimap<EndpointIPtr, ConnectionIPtr>::iterator,
+ multimap<EndpointIPtr, ConnectionIPtr>::iterator> pr = _connections.equal_range(endpoint);
+
+ while(pr.first != pr.second)
+ {
+ try
+ {
+ pr.first->second->setAdapter(adapter);
+ }
+ catch(const Ice::LocalException&)
+ {
+ //
+ // Ignore, the connection is being closed or closed.
+ //
+ }
+ ++pr.first;
+ }
}
}
@@ -449,24 +449,24 @@ IceInternal::OutgoingConnectionFactory::removeAdapter(const ObjectAdapterPtr& ad
if(_destroyed)
{
- return;
+ return;
}
for(multimap<EndpointIPtr, ConnectionIPtr>::const_iterator p = _connections.begin(); p != _connections.end(); ++p)
{
- if(p->second->getAdapter() == adapter)
- {
- try
- {
- p->second->setAdapter(0);
- }
- catch(const Ice::LocalException&)
- {
- //
- // Ignore, the connection is being closed or closed.
- //
- }
- }
+ if(p->second->getAdapter() == adapter)
+ {
+ try
+ {
+ p->second->setAdapter(0);
+ }
+ catch(const Ice::LocalException&)
+ {
+ //
+ // Ignore, the connection is being closed or closed.
+ //
+ }
+ }
}
}
@@ -476,26 +476,26 @@ IceInternal::OutgoingConnectionFactory::flushBatchRequests()
list<ConnectionIPtr> c;
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- for(std::multimap<EndpointIPtr, ConnectionIPtr>::const_iterator p = _connections.begin();
- p != _connections.end();
- ++p)
- {
- c.push_back(p->second);
- }
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ for(std::multimap<EndpointIPtr, ConnectionIPtr>::const_iterator p = _connections.begin();
+ p != _connections.end();
+ ++p)
+ {
+ c.push_back(p->second);
+ }
}
for(list<ConnectionIPtr>::const_iterator p = c.begin(); p != c.end(); ++p)
{
- try
- {
- (*p)->flushBatchRequests();
- }
- catch(const LocalException&)
- {
- // Ignore.
- }
+ try
+ {
+ (*p)->flushBatchRequests();
+ }
+ catch(const LocalException&)
+ {
+ // Ignore.
+ }
}
}
@@ -538,22 +538,22 @@ IceInternal::IncomingConnectionFactory::waitUntilHolding() const
list<ConnectionIPtr> connections;
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- //
- // First we wait until the connection factory itself is in holding
- // state.
- //
- while(_state < StateHolding)
- {
- wait();
- }
-
- //
- // We want to wait until all connections are in holding state
- // outside the thread synchronization.
- //
- connections = _connections;
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ //
+ // First we wait until the connection factory itself is in holding
+ // state.
+ //
+ while(_state < StateHolding)
+ {
+ wait();
+ }
+
+ //
+ // We want to wait until all connections are in holding state
+ // outside the thread synchronization.
+ //
+ connections = _connections;
}
//
@@ -569,35 +569,35 @@ IceInternal::IncomingConnectionFactory::waitUntilFinished()
list<ConnectionIPtr> connections;
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- //
- // First we wait until the factory is destroyed. If we are using
- // an acceptor, we also wait for it to be closed.
- //
- while(_state != StateClosed || _acceptor)
- {
- wait();
- }
-
- threadPerIncomingConnectionFactory = _threadPerIncomingConnectionFactory;
- _threadPerIncomingConnectionFactory = 0;
-
- //
- // Clear the OA. See bug 1673 for the details of why this is necessary.
- //
- _adapter = 0;
-
- //
- // We want to wait until all connections are finished outside the
- // thread synchronization.
- //
- connections.swap(_connections);
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ //
+ // First we wait until the factory is destroyed. If we are using
+ // an acceptor, we also wait for it to be closed.
+ //
+ while(_state != StateClosed || _acceptor)
+ {
+ wait();
+ }
+
+ threadPerIncomingConnectionFactory = _threadPerIncomingConnectionFactory;
+ _threadPerIncomingConnectionFactory = 0;
+
+ //
+ // Clear the OA. See bug 1673 for the details of why this is necessary.
+ //
+ _adapter = 0;
+
+ //
+ // We want to wait until all connections are finished outside the
+ // thread synchronization.
+ //
+ connections.swap(_connections);
}
if(threadPerIncomingConnectionFactory)
{
- threadPerIncomingConnectionFactory->getThreadControl().join();
+ threadPerIncomingConnectionFactory->getThreadControl().join();
}
for_each(connections.begin(), connections.end(), Ice::voidMemFun(&ConnectionI::waitUntilFinished));
@@ -615,7 +615,7 @@ IceInternal::IncomingConnectionFactory::equivalent(const EndpointIPtr& endp) con
{
if(_transceiver)
{
- return endp->equivalent(_transceiver);
+ return endp->equivalent(_transceiver);
}
assert(_acceptor);
@@ -633,7 +633,7 @@ IceInternal::IncomingConnectionFactory::connections() const
// Only copy connections which have not been destroyed.
//
remove_copy_if(_connections.begin(), _connections.end(), back_inserter(result),
- Ice::constMemFun(&ConnectionI::isDestroyed));
+ Ice::constMemFun(&ConnectionI::isDestroyed));
return result;
}
@@ -645,14 +645,14 @@ IceInternal::IncomingConnectionFactory::flushBatchRequests()
for(list<ConnectionIPtr>::const_iterator p = c.begin(); p != c.end(); ++p)
{
- try
- {
- (*p)->flushBatchRequests();
- }
- catch(const LocalException&)
- {
- // Ignore.
- }
+ try
+ {
+ (*p)->flushBatchRequests();
+ }
+ catch(const LocalException&)
+ {
+ // Ignore.
+ }
}
}
@@ -682,13 +682,13 @@ class PromoteFollower
public:
PromoteFollower(const ThreadPoolPtr& threadPool) :
- _threadPool(threadPool)
+ _threadPool(threadPool)
{
}
~PromoteFollower()
{
- _threadPool->promoteFollower();
+ _threadPool->promoteFollower();
}
private:
@@ -704,73 +704,73 @@ IceInternal::IncomingConnectionFactory::message(BasicStream&, const ThreadPoolPt
ConnectionIPtr connection;
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- //
- // This makes sure that we promote a follower before we leave
- // the scope of the mutex above, but after we call accept()
- // (if we call it).
- //
- // If _threadPool is null, then this class doesn't do
- // anything.
- //
- PromoteFollower promote(threadPool);
-
- if(_state != StateActive)
- {
- IceUtil::ThreadControl::yield();
- return;
- }
-
- //
- // Reap connections for which destruction has completed.
- //
- _connections.erase(remove_if(_connections.begin(), _connections.end(),
- Ice::constMemFun(&ConnectionI::isFinished)),
- _connections.end());
-
- //
- // Now accept a new connection.
- //
- TransceiverPtr transceiver;
- try
- {
- transceiver = _acceptor->accept(0);
- }
- catch(const SocketException&)
- {
- // Ignore socket exceptions.
- return;
- }
- catch(const TimeoutException&)
- {
- // Ignore timeouts.
- return;
- }
- catch(const LocalException& ex)
- {
- // Warn about other Ice local exceptions.
- if(_warn)
- {
- Warning out(_instance->initializationData().logger);
- out << "connection exception:\n" << ex << '\n' << _acceptor->toString();
- }
- return;
- }
-
- assert(transceiver);
-
- try
- {
- connection = new ConnectionI(_instance, transceiver, _endpoint, _adapter, _threadPerConnection,
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ //
+ // This makes sure that we promote a follower before we leave
+ // the scope of the mutex above, but after we call accept()
+ // (if we call it).
+ //
+ // If _threadPool is null, then this class doesn't do
+ // anything.
+ //
+ PromoteFollower promote(threadPool);
+
+ if(_state != StateActive)
+ {
+ IceUtil::ThreadControl::yield();
+ return;
+ }
+
+ //
+ // Reap connections for which destruction has completed.
+ //
+ _connections.erase(remove_if(_connections.begin(), _connections.end(),
+ Ice::constMemFun(&ConnectionI::isFinished)),
+ _connections.end());
+
+ //
+ // Now accept a new connection.
+ //
+ TransceiverPtr transceiver;
+ try
+ {
+ transceiver = _acceptor->accept(0);
+ }
+ catch(const SocketException&)
+ {
+ // Ignore socket exceptions.
+ return;
+ }
+ catch(const TimeoutException&)
+ {
+ // Ignore timeouts.
+ return;
+ }
+ catch(const LocalException& ex)
+ {
+ // Warn about other Ice local exceptions.
+ if(_warn)
+ {
+ Warning out(_instance->initializationData().logger);
+ out << "connection exception:\n" << ex << '\n' << _acceptor->toString();
+ }
+ return;
+ }
+
+ assert(transceiver);
+
+ try
+ {
+ connection = new ConnectionI(_instance, transceiver, _endpoint, _adapter, _threadPerConnection,
_threadPerConnectionStackSize);
- }
- catch(const LocalException&)
- {
- return;
- }
+ }
+ catch(const LocalException&)
+ {
+ return;
+ }
- _connections.push_back(connection);
+ _connections.push_back(connection);
}
assert(connection);
@@ -781,14 +781,14 @@ IceInternal::IncomingConnectionFactory::message(BasicStream&, const ThreadPoolPt
//
try
{
- connection->validate();
+ connection->validate();
}
catch(const LocalException&)
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- connection->waitUntilFinished(); // We must call waitUntilFinished() for cleanup.
- _connections.remove(connection);
- return;
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ connection->waitUntilFinished(); // We must call waitUntilFinished() for cleanup.
+ _connections.remove(connection);
+ return;
}
connection->activate();
@@ -808,10 +808,10 @@ IceInternal::IncomingConnectionFactory::finished(const ThreadPoolPtr& threadPool
if(_finishedCount == 0 && _state == StateClosed)
{
- dynamic_cast<ObjectAdapterI*>(_adapter.get())->getThreadPool()->decFdsInUse();
- _acceptor->close();
- _acceptor = 0;
- notifyAll();
+ dynamic_cast<ObjectAdapterI*>(_adapter.get())->getThreadPool()->decFdsInUse();
+ _acceptor->close();
+ _acceptor = 0;
+ notifyAll();
}
}
@@ -828,7 +828,7 @@ IceInternal::IncomingConnectionFactory::toString() const
if(_transceiver)
{
- return _transceiver->toString();
+ return _transceiver->toString();
}
assert(_acceptor);
@@ -836,9 +836,9 @@ IceInternal::IncomingConnectionFactory::toString() const
}
IceInternal::IncomingConnectionFactory::IncomingConnectionFactory(const InstancePtr& instance,
- const EndpointIPtr& endpoint,
- const ObjectAdapterPtr& adapter,
- const string& adapterName) :
+ const EndpointIPtr& endpoint,
+ const ObjectAdapterPtr& adapter,
+ const string& adapterName) :
EventHandler(instance),
_endpoint(endpoint),
_adapter(adapter),
@@ -849,14 +849,14 @@ IceInternal::IncomingConnectionFactory::IncomingConnectionFactory(const Instance
{
if(_instance->defaultsAndOverrides()->overrideTimeout)
{
- const_cast<EndpointIPtr&>(_endpoint) =
- _endpoint->timeout(_instance->defaultsAndOverrides()->overrideTimeoutValue);
+ const_cast<EndpointIPtr&>(_endpoint) =
+ _endpoint->timeout(_instance->defaultsAndOverrides()->overrideTimeoutValue);
}
if(_instance->defaultsAndOverrides()->overrideCompress)
{
- const_cast<EndpointIPtr&>(_endpoint) =
- _endpoint->compress(_instance->defaultsAndOverrides()->overrideCompressValue);
+ const_cast<EndpointIPtr&>(_endpoint) =
+ _endpoint->compress(_instance->defaultsAndOverrides()->overrideCompressValue);
}
ObjectAdapterI* adapterImpl = dynamic_cast<ObjectAdapterI*>(_adapter.get());
@@ -866,75 +866,75 @@ IceInternal::IncomingConnectionFactory::IncomingConnectionFactory(const Instance
const_cast<TransceiverPtr&>(_transceiver) = _endpoint->serverTransceiver(const_cast<EndpointIPtr&>(_endpoint));
if(_transceiver)
{
- ConnectionIPtr connection;
+ ConnectionIPtr connection;
- try
- {
- connection = new ConnectionI(_instance, _transceiver, _endpoint, _adapter, _threadPerConnection,
+ try
+ {
+ connection = new ConnectionI(_instance, _transceiver, _endpoint, _adapter, _threadPerConnection,
_threadPerConnectionStackSize);
- connection->validate();
- }
- catch(const LocalException&)
- {
- //
- // If a connection object was constructed, then validate()
- // must have raised the exception.
- //
- if(connection)
- {
- connection->waitUntilFinished(); // We must call waitUntilFinished() for cleanup.
- }
-
- return;
- }
-
- _connections.push_back(connection);
+ connection->validate();
+ }
+ catch(const LocalException&)
+ {
+ //
+ // If a connection object was constructed, then validate()
+ // must have raised the exception.
+ //
+ if(connection)
+ {
+ connection->waitUntilFinished(); // We must call waitUntilFinished() for cleanup.
+ }
+
+ return;
+ }
+
+ _connections.push_back(connection);
}
else
{
- _acceptor = _endpoint->acceptor(const_cast<EndpointIPtr&>(_endpoint), adapterName);
- assert(_acceptor);
- _acceptor->listen();
-
- __setNoDelete(true);
- try
- {
- if(_threadPerConnection)
- {
- //
- // If we are in thread per connection mode, we also use
- // one thread per incoming connection factory, that
- // accepts new connections on this endpoint.
- //
- _threadPerIncomingConnectionFactory = new ThreadPerIncomingConnectionFactory(this);
- _threadPerIncomingConnectionFactory->start(_threadPerConnectionStackSize);
- }
- else
- {
- adapterImpl->getThreadPool()->incFdsInUse();
- }
- }
- catch(const IceUtil::Exception& ex)
- {
- if(_threadPerConnection)
- {
- Error out(_instance->initializationData().logger);
- out << "cannot create thread for incoming connection factory:\n" << ex;
- }
-
- try
- {
- _acceptor->close();
- }
- catch(const LocalException&)
- {
- // Here we ignore any exceptions in close().
- }
-
- __setNoDelete(false);
- ex.ice_throw();
- }
- __setNoDelete(false);
+ _acceptor = _endpoint->acceptor(const_cast<EndpointIPtr&>(_endpoint), adapterName);
+ assert(_acceptor);
+ _acceptor->listen();
+
+ __setNoDelete(true);
+ try
+ {
+ if(_threadPerConnection)
+ {
+ //
+ // If we are in thread per connection mode, we also use
+ // one thread per incoming connection factory, that
+ // accepts new connections on this endpoint.
+ //
+ _threadPerIncomingConnectionFactory = new ThreadPerIncomingConnectionFactory(this);
+ _threadPerIncomingConnectionFactory->start(_threadPerConnectionStackSize);
+ }
+ else
+ {
+ adapterImpl->getThreadPool()->incFdsInUse();
+ }
+ }
+ catch(const IceUtil::Exception& ex)
+ {
+ if(_threadPerConnection)
+ {
+ Error out(_instance->initializationData().logger);
+ out << "cannot create thread for incoming connection factory:\n" << ex;
+ }
+
+ try
+ {
+ _acceptor->close();
+ }
+ catch(const LocalException&)
+ {
+ // Here we ignore any exceptions in close().
+ }
+
+ __setNoDelete(false);
+ ex.ice_throw();
+ }
+ __setNoDelete(false);
}
}
@@ -951,74 +951,74 @@ IceInternal::IncomingConnectionFactory::setState(State state)
{
if(_state == state) // Don't switch twice.
{
- return;
+ return;
}
switch(state)
{
- case StateActive:
- {
- if(_state != StateHolding) // Can only switch from holding to active.
- {
- return;
- }
- if(!_threadPerConnection && _acceptor)
- {
- registerWithPool();
- }
- for_each(_connections.begin(), _connections.end(), Ice::voidMemFun(&ConnectionI::activate));
- break;
- }
-
- case StateHolding:
- {
- if(_state != StateActive) // Can only switch from active to holding.
- {
- return;
- }
- if(!_threadPerConnection && _acceptor)
- {
- unregisterWithPool();
- }
- for_each(_connections.begin(), _connections.end(), Ice::voidMemFun(&ConnectionI::hold));
- break;
- }
-
- case StateClosed:
- {
- if(_acceptor)
- {
- if(_threadPerConnection)
- {
- //
- // If we are in thread per connection mode, we connect
- // to our own acceptor, which unblocks our thread per
- // incoming connection factory stuck in accept().
- //
- _acceptor->connectToSelf();
- }
- else
- {
- //
- // Otherwise we first must make sure that we are
- // registered, then we unregister, and let finished()
- // do the close.
- //
- registerWithPool();
- unregisterWithPool();
- }
- }
+ case StateActive:
+ {
+ if(_state != StateHolding) // Can only switch from holding to active.
+ {
+ return;
+ }
+ if(!_threadPerConnection && _acceptor)
+ {
+ registerWithPool();
+ }
+ for_each(_connections.begin(), _connections.end(), Ice::voidMemFun(&ConnectionI::activate));
+ break;
+ }
+
+ case StateHolding:
+ {
+ if(_state != StateActive) // Can only switch from active to holding.
+ {
+ return;
+ }
+ if(!_threadPerConnection && _acceptor)
+ {
+ unregisterWithPool();
+ }
+ for_each(_connections.begin(), _connections.end(), Ice::voidMemFun(&ConnectionI::hold));
+ break;
+ }
+
+ case StateClosed:
+ {
+ if(_acceptor)
+ {
+ if(_threadPerConnection)
+ {
+ //
+ // If we are in thread per connection mode, we connect
+ // to our own acceptor, which unblocks our thread per
+ // incoming connection factory stuck in accept().
+ //
+ _acceptor->connectToSelf();
+ }
+ else
+ {
+ //
+ // Otherwise we first must make sure that we are
+ // registered, then we unregister, and let finished()
+ // do the close.
+ //
+ registerWithPool();
+ unregisterWithPool();
+ }
+ }
#ifdef _STLP_BEGIN_NAMESPACE
- // voidbind2nd is an STLport extension for broken compilers in IceUtil/Functional.h
- for_each(_connections.begin(), _connections.end(),
- voidbind2nd(Ice::voidMemFun1(&ConnectionI::destroy), ConnectionI::ObjectAdapterDeactivated));
+ // voidbind2nd is an STLport extension for broken compilers in IceUtil/Functional.h
+ for_each(_connections.begin(), _connections.end(),
+ voidbind2nd(Ice::voidMemFun1(&ConnectionI::destroy), ConnectionI::ObjectAdapterDeactivated));
#else
- for_each(_connections.begin(), _connections.end(),
- bind2nd(Ice::voidMemFun1(&ConnectionI::destroy), ConnectionI::ObjectAdapterDeactivated));
+ for_each(_connections.begin(), _connections.end(),
+ bind2nd(Ice::voidMemFun1(&ConnectionI::destroy), ConnectionI::ObjectAdapterDeactivated));
#endif
- break;
- }
+ break;
+ }
}
_state = state;
@@ -1033,8 +1033,8 @@ IceInternal::IncomingConnectionFactory::registerWithPool()
if(!_registeredWithPool)
{
- dynamic_cast<ObjectAdapterI*>(_adapter.get())->getThreadPool()->_register(_acceptor->fd(), this);
- _registeredWithPool = true;
+ dynamic_cast<ObjectAdapterI*>(_adapter.get())->getThreadPool()->_register(_acceptor->fd(), this);
+ _registeredWithPool = true;
}
}
@@ -1046,9 +1046,9 @@ IceInternal::IncomingConnectionFactory::unregisterWithPool()
if(_registeredWithPool)
{
- dynamic_cast<ObjectAdapterI*>(_adapter.get())->getThreadPool()->unregister(_acceptor->fd());
- _registeredWithPool = false;
- ++_finishedCount; // For each unregistration, finished() is called once.
+ dynamic_cast<ObjectAdapterI*>(_adapter.get())->getThreadPool()->unregister(_acceptor->fd());
+ _registeredWithPool = false;
+ ++_finishedCount; // For each unregistration, finished() is called once.
}
}
@@ -1059,111 +1059,111 @@ IceInternal::IncomingConnectionFactory::run()
while(true)
{
- //
- // We must accept new connections outside the thread
- // synchronization, because we use blocking accept.
- //
- TransceiverPtr transceiver;
- try
- {
- transceiver = _acceptor->accept(-1);
- }
- catch(const SocketException&)
- {
- // Ignore socket exceptions.
- }
- catch(const TimeoutException&)
- {
- // Ignore timeouts.
- }
- catch(const LocalException& ex)
- {
- // Warn about other Ice local exceptions.
- if(_warn)
- {
- Warning out(_instance->initializationData().logger);
- out << "connection exception:\n" << ex << '\n' << _acceptor->toString();
- }
- }
-
- ConnectionIPtr connection;
-
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- while(_state == StateHolding)
- {
- wait();
- }
-
- if(_state == StateClosed)
- {
- if(transceiver)
- {
- try
- {
- transceiver->close();
- }
- catch(const LocalException&)
- {
- // Here we ignore any exceptions in close().
- }
- }
-
- try
- {
- _acceptor->close();
- }
- catch(const LocalException& ex)
- {
- _acceptor = 0;
- notifyAll();
- ex.ice_throw();
- }
-
- _acceptor = 0;
- notifyAll();
- return;
- }
-
- assert(_state == StateActive);
-
- //
- // Reap connections for which destruction has completed.
- //
- _connections.erase(remove_if(_connections.begin(), _connections.end(),
- Ice::constMemFun(&ConnectionI::isFinished)),
- _connections.end());
-
- //
- // Create a connection object for the connection.
- //
- if(transceiver)
- {
- try
- {
- connection = new ConnectionI(_instance, transceiver, _endpoint, _adapter, _threadPerConnection,
+ //
+ // We must accept new connections outside the thread
+ // synchronization, because we use blocking accept.
+ //
+ TransceiverPtr transceiver;
+ try
+ {
+ transceiver = _acceptor->accept(-1);
+ }
+ catch(const SocketException&)
+ {
+ // Ignore socket exceptions.
+ }
+ catch(const TimeoutException&)
+ {
+ // Ignore timeouts.
+ }
+ catch(const LocalException& ex)
+ {
+ // Warn about other Ice local exceptions.
+ if(_warn)
+ {
+ Warning out(_instance->initializationData().logger);
+ out << "connection exception:\n" << ex << '\n' << _acceptor->toString();
+ }
+ }
+
+ ConnectionIPtr connection;
+
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ while(_state == StateHolding)
+ {
+ wait();
+ }
+
+ if(_state == StateClosed)
+ {
+ if(transceiver)
+ {
+ try
+ {
+ transceiver->close();
+ }
+ catch(const LocalException&)
+ {
+ // Here we ignore any exceptions in close().
+ }
+ }
+
+ try
+ {
+ _acceptor->close();
+ }
+ catch(const LocalException& ex)
+ {
+ _acceptor = 0;
+ notifyAll();
+ ex.ice_throw();
+ }
+
+ _acceptor = 0;
+ notifyAll();
+ return;
+ }
+
+ assert(_state == StateActive);
+
+ //
+ // Reap connections for which destruction has completed.
+ //
+ _connections.erase(remove_if(_connections.begin(), _connections.end(),
+ Ice::constMemFun(&ConnectionI::isFinished)),
+ _connections.end());
+
+ //
+ // Create a connection object for the connection.
+ //
+ if(transceiver)
+ {
+ try
+ {
+ connection = new ConnectionI(_instance, transceiver, _endpoint, _adapter, _threadPerConnection,
_threadPerConnectionStackSize);
- }
- catch(const LocalException&)
- {
- return;
- }
-
- _connections.push_back(connection);
- }
- }
-
- //
- // In thread per connection mode, the connection's thread will
- // take care of connection validation and activation (for
- // non-datagram connections). We don't want to block this
- // thread waiting until validation is complete, because in
- // contrast to thread pool mode, it is the only thread that
- // can accept connections with this factory's
- // acceptor. Therefore we don't call validate() and activate()
- // from the connection factory in thread per connection mode.
- //
+ }
+ catch(const LocalException&)
+ {
+ return;
+ }
+
+ _connections.push_back(connection);
+ }
+ }
+
+ //
+ // In thread per connection mode, the connection's thread will
+ // take care of connection validation and activation (for
+ // non-datagram connections). We don't want to block this
+ // thread waiting until validation is complete, because in
+ // contrast to thread pool mode, it is the only thread that
+ // can accept connections with this factory's
+ // acceptor. Therefore we don't call validate() and activate()
+ // from the connection factory in thread per connection mode.
+ //
}
}
@@ -1178,22 +1178,22 @@ IceInternal::IncomingConnectionFactory::ThreadPerIncomingConnectionFactory::run(
{
try
{
- _factory->run();
+ _factory->run();
}
catch(const Exception& ex)
- {
- Error out(_factory->_instance->initializationData().logger);
- out << "exception in thread per incoming connection factory:\n" << _factory->toString() << ex;
+ {
+ Error out(_factory->_instance->initializationData().logger);
+ out << "exception in thread per incoming connection factory:\n" << _factory->toString() << ex;
}
catch(const std::exception& ex)
{
- Error out(_factory->_instance->initializationData().logger);
- out << "std::exception in thread per incoming connection factory:\n" << _factory->toString() << ex.what();
+ Error out(_factory->_instance->initializationData().logger);
+ out << "std::exception in thread per incoming connection factory:\n" << _factory->toString() << ex.what();
}
catch(...)
{
- Error out(_factory->_instance->initializationData().logger);
- out << "unknown exception in thread per incoming connection factory:\n" << _factory->toString();
+ Error out(_factory->_instance->initializationData().logger);
+ out << "unknown exception in thread per incoming connection factory:\n" << _factory->toString();
}
_factory = 0; // Resolve cyclic dependency.
diff --git a/cpp/src/Ice/ConnectionFactory.h b/cpp/src/Ice/ConnectionFactory.h
index d7e58df05f5..7758e675b8d 100644
--- a/cpp/src/Ice/ConnectionFactory.h
+++ b/cpp/src/Ice/ConnectionFactory.h
@@ -91,15 +91,15 @@ public:
private:
IncomingConnectionFactory(const InstancePtr&, const EndpointIPtr&, const Ice::ObjectAdapterPtr&,
- const std::string&);
+ const std::string&);
virtual ~IncomingConnectionFactory();
friend class Ice::ObjectAdapterI;
enum State
{
- StateActive,
- StateHolding,
- StateClosed
+ StateActive,
+ StateHolding,
+ StateClosed
};
void setState(State);
@@ -111,13 +111,13 @@ private:
class ThreadPerIncomingConnectionFactory : public IceUtil::Thread
{
public:
-
- ThreadPerIncomingConnectionFactory(const IncomingConnectionFactoryPtr&);
- virtual void run();
+
+ ThreadPerIncomingConnectionFactory(const IncomingConnectionFactoryPtr&);
+ virtual void run();
private:
-
- IncomingConnectionFactoryPtr _factory;
+
+ IncomingConnectionFactoryPtr _factory;
};
friend class ThreadPerIncomingConnectionFactory;
IceUtil::ThreadPtr _threadPerIncomingConnectionFactory;
diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp
index d832f87a886..22b4c28cf23 100644
--- a/cpp/src/Ice/ConnectionI.cpp
+++ b/cpp/src/Ice/ConnectionI.cpp
@@ -41,189 +41,189 @@ Ice::ConnectionI::validate()
if(!_endpoint->datagram()) // Datagram connections are always implicitly validated.
{
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- if(_thread && _thread->getThreadControl() != IceUtil::ThreadControl())
- {
- //
- // In thread per connection mode, this connection's thread
- // will take care of connection validation. Therefore all we
- // have to do here is to wait until this thread has completed
- // validation.
- //
- while(_state == StateNotValidated)
- {
- wait();
- }
-
- if(_state >= StateClosing)
- {
- assert(_exception.get());
- _exception->ice_throw();
- }
-
- return;
- }
-
- //
- // The connection might already be closed (e.g.: the communicator
- // was destroyed or object adapter deactivated.)
- //
- assert(_state == StateNotValidated || _state == StateClosed);
- if(_state == StateClosed)
- {
- assert(_exception.get());
- _exception->ice_throw();
- }
-
- if(_adapter)
- {
- active = true; // The server side has the active role for connection validation.
- }
- else
- {
- active = false; // The client side has the passive role for connection validation.
- }
- }
-
- try
- {
- Int timeout;
- if(_instance->defaultsAndOverrides()->overrideConnectTimeout)
- {
- timeout = _instance->defaultsAndOverrides()->overrideConnectTimeoutValue;
- }
- else
- {
- timeout = _endpoint->timeout();
- }
-
- if(active)
- {
- IceUtil::Mutex::Lock sendSync(_sendMutex);
-
- if(!_transceiver) // Has the transceiver already been closed?
- {
- assert(_exception.get());
- _exception->ice_throw(); // The exception is immutable at this point.
- }
-
- BasicStream os(_instance.get());
- os.write(magic[0]);
- os.write(magic[1]);
- os.write(magic[2]);
- os.write(magic[3]);
- os.write(protocolMajor);
- os.write(protocolMinor);
- os.write(encodingMajor);
- os.write(encodingMinor);
- os.write(validateConnectionMsg);
- os.write(static_cast<Byte>(0)); // Compression status (always zero for validate connection).
- os.write(headerSize); // Message size.
- os.i = os.b.begin();
- traceHeader("sending validate connection", os, _logger, _traceLevels);
- try
- {
- _transceiver->initialize(timeout);
- _transceiver->write(os, timeout);
- }
- catch(const TimeoutException&)
- {
- throw ConnectTimeoutException(__FILE__, __LINE__);
- }
- }
- else
- {
- BasicStream is(_instance.get());
- is.b.resize(headerSize);
- is.i = is.b.begin();
- try
- {
- _transceiver->initialize(timeout);
- _transceiver->read(is, timeout);
- }
- catch(const TimeoutException&)
- {
- throw ConnectTimeoutException(__FILE__, __LINE__);
- }
- assert(is.i == is.b.end());
- is.i = is.b.begin();
- Byte m[4];
- is.read(m[0]);
- is.read(m[1]);
- is.read(m[2]);
- is.read(m[3]);
- if(m[0] != magic[0] || m[1] != magic[1] || m[2] != magic[2] || m[3] != magic[3])
- {
- BadMagicException ex(__FILE__, __LINE__);
- ex.badMagic = Ice::ByteSeq(&m[0], &m[0] + sizeof(magic));
- throw ex;
- }
- Byte pMajor;
- Byte pMinor;
- is.read(pMajor);
- is.read(pMinor);
- if(pMajor != protocolMajor)
- {
- UnsupportedProtocolException ex(__FILE__, __LINE__);
- ex.badMajor = static_cast<unsigned char>(pMajor);
- ex.badMinor = static_cast<unsigned char>(pMinor);
- ex.major = static_cast<unsigned char>(protocolMajor);
- ex.minor = static_cast<unsigned char>(protocolMinor);
- throw ex;
- }
- Byte eMajor;
- Byte eMinor;
- is.read(eMajor);
- is.read(eMinor);
- if(eMajor != encodingMajor)
- {
- UnsupportedEncodingException ex(__FILE__, __LINE__);
- ex.badMajor = static_cast<unsigned char>(eMajor);
- ex.badMinor = static_cast<unsigned char>(eMinor);
- ex.major = static_cast<unsigned char>(encodingMajor);
- ex.minor = static_cast<unsigned char>(encodingMinor);
- throw ex;
- }
- Byte messageType;
- is.read(messageType);
- if(messageType != validateConnectionMsg)
- {
- throw ConnectionNotValidatedException(__FILE__, __LINE__);
- }
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ if(_thread && _thread->getThreadControl() != IceUtil::ThreadControl())
+ {
+ //
+ // In thread per connection mode, this connection's thread
+ // will take care of connection validation. Therefore all we
+ // have to do here is to wait until this thread has completed
+ // validation.
+ //
+ while(_state == StateNotValidated)
+ {
+ wait();
+ }
+
+ if(_state >= StateClosing)
+ {
+ assert(_exception.get());
+ _exception->ice_throw();
+ }
+
+ return;
+ }
+
+ //
+ // The connection might already be closed (e.g.: the communicator
+ // was destroyed or object adapter deactivated.)
+ //
+ assert(_state == StateNotValidated || _state == StateClosed);
+ if(_state == StateClosed)
+ {
+ assert(_exception.get());
+ _exception->ice_throw();
+ }
+
+ if(_adapter)
+ {
+ active = true; // The server side has the active role for connection validation.
+ }
+ else
+ {
+ active = false; // The client side has the passive role for connection validation.
+ }
+ }
+
+ try
+ {
+ Int timeout;
+ if(_instance->defaultsAndOverrides()->overrideConnectTimeout)
+ {
+ timeout = _instance->defaultsAndOverrides()->overrideConnectTimeoutValue;
+ }
+ else
+ {
+ timeout = _endpoint->timeout();
+ }
+
+ if(active)
+ {
+ IceUtil::Mutex::Lock sendSync(_sendMutex);
+
+ if(!_transceiver) // Has the transceiver already been closed?
+ {
+ assert(_exception.get());
+ _exception->ice_throw(); // The exception is immutable at this point.
+ }
+
+ BasicStream os(_instance.get());
+ os.write(magic[0]);
+ os.write(magic[1]);
+ os.write(magic[2]);
+ os.write(magic[3]);
+ os.write(protocolMajor);
+ os.write(protocolMinor);
+ os.write(encodingMajor);
+ os.write(encodingMinor);
+ os.write(validateConnectionMsg);
+ os.write(static_cast<Byte>(0)); // Compression status (always zero for validate connection).
+ os.write(headerSize); // Message size.
+ os.i = os.b.begin();
+ traceHeader("sending validate connection", os, _logger, _traceLevels);
+ try
+ {
+ _transceiver->initialize(timeout);
+ _transceiver->write(os, timeout);
+ }
+ catch(const TimeoutException&)
+ {
+ throw ConnectTimeoutException(__FILE__, __LINE__);
+ }
+ }
+ else
+ {
+ BasicStream is(_instance.get());
+ is.b.resize(headerSize);
+ is.i = is.b.begin();
+ try
+ {
+ _transceiver->initialize(timeout);
+ _transceiver->read(is, timeout);
+ }
+ catch(const TimeoutException&)
+ {
+ throw ConnectTimeoutException(__FILE__, __LINE__);
+ }
+ assert(is.i == is.b.end());
+ is.i = is.b.begin();
+ Byte m[4];
+ is.read(m[0]);
+ is.read(m[1]);
+ is.read(m[2]);
+ is.read(m[3]);
+ if(m[0] != magic[0] || m[1] != magic[1] || m[2] != magic[2] || m[3] != magic[3])
+ {
+ BadMagicException ex(__FILE__, __LINE__);
+ ex.badMagic = Ice::ByteSeq(&m[0], &m[0] + sizeof(magic));
+ throw ex;
+ }
+ Byte pMajor;
+ Byte pMinor;
+ is.read(pMajor);
+ is.read(pMinor);
+ if(pMajor != protocolMajor)
+ {
+ UnsupportedProtocolException ex(__FILE__, __LINE__);
+ ex.badMajor = static_cast<unsigned char>(pMajor);
+ ex.badMinor = static_cast<unsigned char>(pMinor);
+ ex.major = static_cast<unsigned char>(protocolMajor);
+ ex.minor = static_cast<unsigned char>(protocolMinor);
+ throw ex;
+ }
+ Byte eMajor;
+ Byte eMinor;
+ is.read(eMajor);
+ is.read(eMinor);
+ if(eMajor != encodingMajor)
+ {
+ UnsupportedEncodingException ex(__FILE__, __LINE__);
+ ex.badMajor = static_cast<unsigned char>(eMajor);
+ ex.badMinor = static_cast<unsigned char>(eMinor);
+ ex.major = static_cast<unsigned char>(encodingMajor);
+ ex.minor = static_cast<unsigned char>(encodingMinor);
+ throw ex;
+ }
+ Byte messageType;
+ is.read(messageType);
+ if(messageType != validateConnectionMsg)
+ {
+ throw ConnectionNotValidatedException(__FILE__, __LINE__);
+ }
Byte compress;
is.read(compress); // Ignore compression status for validate connection.
- Int size;
- is.read(size);
- if(size != headerSize)
- {
- throw IllegalMessageSizeException(__FILE__, __LINE__);
- }
- traceHeader("received validate connection", is, _logger, _traceLevels);
- }
- }
- catch(const LocalException& ex)
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- setState(StateClosed, ex);
- assert(_exception.get());
- _exception->ice_throw();
- }
- }
-
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- if(_acmTimeout > 0)
- {
- _acmAbsoluteTimeout = IceUtil::Time::now() + IceUtil::Time::seconds(_acmTimeout);
- }
-
- //
- // We start out in holding state.
- //
- setState(StateHolding);
+ Int size;
+ is.read(size);
+ if(size != headerSize)
+ {
+ throw IllegalMessageSizeException(__FILE__, __LINE__);
+ }
+ traceHeader("received validate connection", is, _logger, _traceLevels);
+ }
+ }
+ catch(const LocalException& ex)
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ setState(StateClosed, ex);
+ assert(_exception.get());
+ _exception->ice_throw();
+ }
+ }
+
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ if(_acmTimeout > 0)
+ {
+ _acmAbsoluteTimeout = IceUtil::Time::now() + IceUtil::Time::seconds(_acmTimeout);
+ }
+
+ //
+ // We start out in holding state.
+ //
+ setState(StateHolding);
}
}
@@ -234,7 +234,7 @@ Ice::ConnectionI::activate()
while(_state == StateNotValidated)
{
- wait();
+ wait();
}
setState(StateActive);
@@ -247,7 +247,7 @@ Ice::ConnectionI::hold()
while(_state == StateNotValidated)
{
- wait();
+ wait();
}
setState(StateHolding);
@@ -260,17 +260,17 @@ Ice::ConnectionI::destroy(DestructionReason reason)
switch(reason)
{
- case ObjectAdapterDeactivated:
- {
- setState(StateClosing, ObjectAdapterDeactivatedException(__FILE__, __LINE__));
- break;
- }
+ case ObjectAdapterDeactivated:
+ {
+ setState(StateClosing, ObjectAdapterDeactivatedException(__FILE__, __LINE__));
+ break;
+ }
- case CommunicatorDestroyed:
- {
- setState(StateClosing, CommunicatorDestroyedException(__FILE__, __LINE__));
- break;
- }
+ case CommunicatorDestroyed:
+ {
+ setState(StateClosing, CommunicatorDestroyedException(__FILE__, __LINE__));
+ break;
+ }
}
}
@@ -281,23 +281,23 @@ Ice::ConnectionI::close(bool force)
if(force)
{
- setState(StateClosed, ForcedCloseConnectionException(__FILE__, __LINE__));
+ setState(StateClosed, ForcedCloseConnectionException(__FILE__, __LINE__));
}
else
{
- //
- // If we do a graceful shutdown, then we wait until all
- // outstanding requests have been completed. Otherwise, the
- // CloseConnectionException will cause all outstanding
- // requests to be retried, regardless of whether the server
- // has processed them or not.
- //
- while(!_requests.empty() || !_asyncRequests.empty())
- {
- wait();
- }
-
- setState(StateClosing, CloseConnectionException(__FILE__, __LINE__));
+ //
+ // If we do a graceful shutdown, then we wait until all
+ // outstanding requests have been completed. Otherwise, the
+ // CloseConnectionException will cause all outstanding
+ // requests to be retried, regardless of whether the server
+ // has processed them or not.
+ //
+ while(!_requests.empty() || !_asyncRequests.empty())
+ {
+ wait();
+ }
+
+ setState(StateClosing, CloseConnectionException(__FILE__, __LINE__));
}
}
@@ -320,37 +320,37 @@ Ice::ConnectionI::isFinished() const
IceUtil::ThreadPtr threadPerConnection;
{
- //
- // We can use trylock here, because as long as there are still
- // threads operating in this connection object, connection
- // destruction is considered as not yet finished.
- //
- IceUtil::Monitor<IceUtil::Mutex>::TryLock sync(*this);
-
- if(!sync.acquired())
- {
- return false;
- }
+ //
+ // We can use trylock here, because as long as there are still
+ // threads operating in this connection object, connection
+ // destruction is considered as not yet finished.
+ //
+ IceUtil::Monitor<IceUtil::Mutex>::TryLock sync(*this);
+
+ if(!sync.acquired())
+ {
+ return false;
+ }
- if(_transceiver || _dispatchCount != 0)
- {
- return false;
- }
+ if(_transceiver || _dispatchCount != 0)
+ {
+ return false;
+ }
- if(_thread && _thread->isAlive())
- {
- return false;
- }
+ if(_thread && _thread->isAlive())
+ {
+ return false;
+ }
- assert(_state == StateClosed);
+ assert(_state == StateClosed);
- threadPerConnection = _thread;
- _thread = 0;
+ threadPerConnection = _thread;
+ _thread = 0;
}
if(threadPerConnection)
{
- threadPerConnection->getThreadControl().join();
+ threadPerConnection->getThreadControl().join();
}
return true;
@@ -363,8 +363,8 @@ Ice::ConnectionI::throwException() const
if(_exception.get())
{
- assert(_state >= StateClosing);
- _exception->ice_throw();
+ assert(_state >= StateClosing);
+ _exception->ice_throw();
}
}
@@ -375,7 +375,7 @@ Ice::ConnectionI::waitUntilHolding() const
while(_state < StateHolding || _dispatchCount > 0)
{
- wait();
+ wait();
}
}
@@ -385,76 +385,76 @@ Ice::ConnectionI::waitUntilFinished()
IceUtil::ThreadPtr threadPerConnection;
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- //
- // We wait indefinitely until connection closing has been
- // initiated. We also wait indefinitely until all outstanding
- // requests are completed. Otherwise we couldn't guarantee
- // that there are no outstanding calls when deactivate() is
- // called on the servant locators.
- //
- while(_state < StateClosing || _dispatchCount > 0)
- {
- wait();
- }
-
- //
- // Now we must wait until close() has been called on the
- // transceiver.
- //
- while(_transceiver)
- {
- if(_state != StateClosed && _endpoint->timeout() >= 0)
- {
- IceUtil::Time timeout = IceUtil::Time::milliSeconds(_endpoint->timeout());
- IceUtil::Time waitTime = _stateTime + timeout - IceUtil::Time::now();
-
- if(waitTime > IceUtil::Time())
- {
- //
- // We must wait a bit longer until we close this
- // connection.
- //
- if(!timedWait(waitTime))
- {
- setState(StateClosed, CloseTimeoutException(__FILE__, __LINE__));
- }
- }
- else
- {
- //
- // We already waited long enough, so let's close this
- // connection!
- //
- setState(StateClosed, CloseTimeoutException(__FILE__, __LINE__));
- }
-
- //
- // No return here, we must still wait until close() is
- // called on the _transceiver.
- //
- }
- else
- {
- wait();
- }
- }
-
- assert(_state == StateClosed);
-
- threadPerConnection = _thread;
- _thread = 0;
-
- //
- // Clear the OA. See bug 1673 for the details of why this is necessary.
- //
- _adapter = 0;
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ //
+ // We wait indefinitely until connection closing has been
+ // initiated. We also wait indefinitely until all outstanding
+ // requests are completed. Otherwise we couldn't guarantee
+ // that there are no outstanding calls when deactivate() is
+ // called on the servant locators.
+ //
+ while(_state < StateClosing || _dispatchCount > 0)
+ {
+ wait();
+ }
+
+ //
+ // Now we must wait until close() has been called on the
+ // transceiver.
+ //
+ while(_transceiver)
+ {
+ if(_state != StateClosed && _endpoint->timeout() >= 0)
+ {
+ IceUtil::Time timeout = IceUtil::Time::milliSeconds(_endpoint->timeout());
+ IceUtil::Time waitTime = _stateTime + timeout - IceUtil::Time::now();
+
+ if(waitTime > IceUtil::Time())
+ {
+ //
+ // We must wait a bit longer until we close this
+ // connection.
+ //
+ if(!timedWait(waitTime))
+ {
+ setState(StateClosed, CloseTimeoutException(__FILE__, __LINE__));
+ }
+ }
+ else
+ {
+ //
+ // We already waited long enough, so let's close this
+ // connection!
+ //
+ setState(StateClosed, CloseTimeoutException(__FILE__, __LINE__));
+ }
+
+ //
+ // No return here, we must still wait until close() is
+ // called on the _transceiver.
+ //
+ }
+ else
+ {
+ wait();
+ }
+ }
+
+ assert(_state == StateClosed);
+
+ threadPerConnection = _thread;
+ _thread = 0;
+
+ //
+ // Clear the OA. See bug 1673 for the details of why this is necessary.
+ //
+ _adapter = 0;
}
if(threadPerConnection)
{
- threadPerConnection->getThreadControl().join();
+ threadPerConnection->getThreadControl().join();
}
}
@@ -465,12 +465,12 @@ Ice::ConnectionI::monitor()
if(!sync.acquired())
{
- return;
+ return;
}
if(_state != StateActive)
{
- return;
+ return;
}
//
@@ -478,11 +478,11 @@ Ice::ConnectionI::monitor()
//
for(map<Int, AsyncRequest>::iterator p = _asyncRequests.begin(); p != _asyncRequests.end(); ++p)
{
- if(p->second.t > IceUtil::Time() && p->second.t <= IceUtil::Time::now())
- {
- setState(StateClosed, TimeoutException(__FILE__, __LINE__));
- return;
- }
+ if(p->second.t > IceUtil::Time() && p->second.t <= IceUtil::Time::now())
+ {
+ setState(StateClosed, TimeoutException(__FILE__, __LINE__));
+ return;
+ }
}
//
@@ -493,11 +493,11 @@ Ice::ConnectionI::monitor()
!_batchStreamInUse && _batchStream.b.empty() &&
_dispatchCount == 0)
{
- if(IceUtil::Time::now() >= _acmAbsoluteTimeout)
- {
- setState(StateClosing, ConnectionTimeoutException(__FILE__, __LINE__));
- return;
- }
+ if(IceUtil::Time::now() >= _acmAbsoluteTimeout)
+ {
+ setState(StateClosing, ConnectionTimeoutException(__FILE__, __LINE__));
+ return;
+ }
}
}
@@ -507,162 +507,162 @@ Ice::ConnectionI::sendRequest(BasicStream* os, Outgoing* out, bool compress)
Int requestId;
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- assert(!(out && _endpoint->datagram())); // Twoway requests cannot be datagrams.
-
- if(_exception.get())
- {
- //
- // If the connection is closed before we even have a chance
- // to send our request, we always try to send the request
- // again.
- //
- throw LocalExceptionWrapper(*_exception.get(), true);
- }
-
- assert(_state > StateNotValidated);
- assert(_state < StateClosing);
-
- //
- // Only add to the request map if this is a twoway call.
- //
- if(out)
- {
- //
- // Create a new unique request ID.
- //
- requestId = _nextRequestId++;
- if(requestId <= 0)
- {
- _nextRequestId = 1;
- requestId = _nextRequestId++;
- }
-
- //
- // Fill in the request ID.
- //
- const Byte* p = reinterpret_cast<const Byte*>(&requestId);
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ assert(!(out && _endpoint->datagram())); // Twoway requests cannot be datagrams.
+
+ if(_exception.get())
+ {
+ //
+ // If the connection is closed before we even have a chance
+ // to send our request, we always try to send the request
+ // again.
+ //
+ throw LocalExceptionWrapper(*_exception.get(), true);
+ }
+
+ assert(_state > StateNotValidated);
+ assert(_state < StateClosing);
+
+ //
+ // Only add to the request map if this is a twoway call.
+ //
+ if(out)
+ {
+ //
+ // Create a new unique request ID.
+ //
+ requestId = _nextRequestId++;
+ if(requestId <= 0)
+ {
+ _nextRequestId = 1;
+ requestId = _nextRequestId++;
+ }
+
+ //
+ // Fill in the request ID.
+ //
+ const Byte* p = reinterpret_cast<const Byte*>(&requestId);
#ifdef ICE_BIG_ENDIAN
- reverse_copy(p, p + sizeof(Int), os->b.begin() + headerSize);
+ reverse_copy(p, p + sizeof(Int), os->b.begin() + headerSize);
#else
- copy(p, p + sizeof(Int), os->b.begin() + headerSize);
+ copy(p, p + sizeof(Int), os->b.begin() + headerSize);
#endif
- //
- // Add to the requests map.
- //
- _requestsHint = _requests.insert(_requests.end(), pair<const Int, Outgoing*>(requestId, out));
- }
-
- if(_acmTimeout > 0)
- {
- _acmAbsoluteTimeout = IceUtil::Time::now() + IceUtil::Time::seconds(_acmTimeout);
- }
+ //
+ // Add to the requests map.
+ //
+ _requestsHint = _requests.insert(_requests.end(), pair<const Int, Outgoing*>(requestId, out));
+ }
+
+ if(_acmTimeout > 0)
+ {
+ _acmAbsoluteTimeout = IceUtil::Time::now() + IceUtil::Time::seconds(_acmTimeout);
+ }
}
try
{
- IceUtil::Mutex::Lock sendSync(_sendMutex);
-
- if(!_transceiver) // Has the transceiver already been closed?
- {
- assert(_exception.get());
- _exception->ice_throw(); // The exception is immutable at this point.
- }
-
- if(compress && os->b.size() >= 100) // Only compress messages larger than 100 bytes.
- {
- //
- // Message compressed. Request compressed response, if any.
- //
- os->b[9] = 2;
-
- //
- // Do compression.
- //
- BasicStream cstream(_instance.get());
- doCompress(*os, cstream);
-
- //
- // Send the request.
- //
- os->i = os->b.begin();
- traceRequest("sending request", *os, _logger, _traceLevels);
- cstream.i = cstream.b.begin();
- _transceiver->write(cstream, _endpoint->timeout());
- }
- else
- {
- if(compress)
- {
- //
- // Message not compressed. Request compressed response, if any.
- //
- os->b[9] = 1;
- }
-
- //
- // No compression, just fill in the message size.
- //
- Int sz = static_cast<Int>(os->b.size());
- const Byte* p = reinterpret_cast<const Byte*>(&sz);
+ IceUtil::Mutex::Lock sendSync(_sendMutex);
+
+ if(!_transceiver) // Has the transceiver already been closed?
+ {
+ assert(_exception.get());
+ _exception->ice_throw(); // The exception is immutable at this point.
+ }
+
+ if(compress && os->b.size() >= 100) // Only compress messages larger than 100 bytes.
+ {
+ //
+ // Message compressed. Request compressed response, if any.
+ //
+ os->b[9] = 2;
+
+ //
+ // Do compression.
+ //
+ BasicStream cstream(_instance.get());
+ doCompress(*os, cstream);
+
+ //
+ // Send the request.
+ //
+ os->i = os->b.begin();
+ traceRequest("sending request", *os, _logger, _traceLevels);
+ cstream.i = cstream.b.begin();
+ _transceiver->write(cstream, _endpoint->timeout());
+ }
+ else
+ {
+ if(compress)
+ {
+ //
+ // Message not compressed. Request compressed response, if any.
+ //
+ os->b[9] = 1;
+ }
+
+ //
+ // No compression, just fill in the message size.
+ //
+ Int sz = static_cast<Int>(os->b.size());
+ const Byte* p = reinterpret_cast<const Byte*>(&sz);
#ifdef ICE_BIG_ENDIAN
- reverse_copy(p, p + sizeof(Int), os->b.begin() + 10);
+ reverse_copy(p, p + sizeof(Int), os->b.begin() + 10);
#else
- copy(p, p + sizeof(Int), os->b.begin() + 10);
+ copy(p, p + sizeof(Int), os->b.begin() + 10);
#endif
-
- //
- // Send the request.
- //
- os->i = os->b.begin();
- traceRequest("sending request", *os, _logger, _traceLevels);
- _transceiver->write(*os, _endpoint->timeout());
- }
+
+ //
+ // Send the request.
+ //
+ os->i = os->b.begin();
+ traceRequest("sending request", *os, _logger, _traceLevels);
+ _transceiver->write(*os, _endpoint->timeout());
+ }
}
catch(const LocalException& ex)
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- setState(StateClosed, ex);
- assert(_exception.get());
-
- if(out)
- {
- //
- // If the request has already been removed from the
- // request map, we are out of luck. It would mean that
- // finished() has been called already, and therefore the
- // exception has been set using the Outgoing::finished()
- // callback. In this case, we cannot throw the exception
- // here, because we must not both raise an exception and
- // have Outgoing::finished() called with an
- // exception. This means that in some rare cases, a
- // request will not be retried even though it could. But I
- // honestly don't know how I could avoid this, without a
- // very elaborate and complex design, which would be bad
- // for performance.
- //
- map<Int, Outgoing*>::iterator p = _requests.find(requestId);
- if(p != _requests.end())
- {
- if(p == _requestsHint)
- {
- _requests.erase(p++);
- _requestsHint = p;
- }
- else
- {
- _requests.erase(p);
- }
-
- _exception->ice_throw();
- }
- }
- else
- {
- _exception->ice_throw();
- }
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ setState(StateClosed, ex);
+ assert(_exception.get());
+
+ if(out)
+ {
+ //
+ // If the request has already been removed from the
+ // request map, we are out of luck. It would mean that
+ // finished() has been called already, and therefore the
+ // exception has been set using the Outgoing::finished()
+ // callback. In this case, we cannot throw the exception
+ // here, because we must not both raise an exception and
+ // have Outgoing::finished() called with an
+ // exception. This means that in some rare cases, a
+ // request will not be retried even though it could. But I
+ // honestly don't know how I could avoid this, without a
+ // very elaborate and complex design, which would be bad
+ // for performance.
+ //
+ map<Int, Outgoing*>::iterator p = _requests.find(requestId);
+ if(p != _requests.end())
+ {
+ if(p == _requestsHint)
+ {
+ _requests.erase(p++);
+ _requestsHint = p;
+ }
+ else
+ {
+ _requests.erase(p);
+ }
+
+ _exception->ice_throw();
+ }
+ }
+ else
+ {
+ _exception->ice_throw();
+ }
}
}
@@ -672,156 +672,156 @@ Ice::ConnectionI::sendAsyncRequest(BasicStream* os, const OutgoingAsyncPtr& out,
Int requestId;
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- assert(!_endpoint->datagram()); // Twoway requests cannot be datagrams, and async implies twoway.
-
- if(_exception.get())
- {
- //
- // If the exception is closed before we even have a chance
- // to send our request, we always try to send the request
- // again.
- //
- throw LocalExceptionWrapper(*_exception.get(), true);
- }
-
- assert(_state > StateNotValidated);
- assert(_state < StateClosing);
-
- //
- // Create a new unique request ID.
- //
- requestId = _nextRequestId++;
- if(requestId <= 0)
- {
- _nextRequestId = 1;
- requestId = _nextRequestId++;
- }
-
- //
- // Fill in the request ID.
- //
- const Byte* p = reinterpret_cast<const Byte*>(&requestId);
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ assert(!_endpoint->datagram()); // Twoway requests cannot be datagrams, and async implies twoway.
+
+ if(_exception.get())
+ {
+ //
+ // If the exception is closed before we even have a chance
+ // to send our request, we always try to send the request
+ // again.
+ //
+ throw LocalExceptionWrapper(*_exception.get(), true);
+ }
+
+ assert(_state > StateNotValidated);
+ assert(_state < StateClosing);
+
+ //
+ // Create a new unique request ID.
+ //
+ requestId = _nextRequestId++;
+ if(requestId <= 0)
+ {
+ _nextRequestId = 1;
+ requestId = _nextRequestId++;
+ }
+
+ //
+ // Fill in the request ID.
+ //
+ const Byte* p = reinterpret_cast<const Byte*>(&requestId);
#ifdef ICE_BIG_ENDIAN
- reverse_copy(p, p + sizeof(Int), os->b.begin() + headerSize);
+ reverse_copy(p, p + sizeof(Int), os->b.begin() + headerSize);
#else
- copy(p, p + sizeof(Int), os->b.begin() + headerSize);
+ copy(p, p + sizeof(Int), os->b.begin() + headerSize);
#endif
-
- //
- // Add to the async requests map.
- //
- struct AsyncRequest asyncRequest;
- asyncRequest.p = out;
- if(_endpoint->timeout() > 0)
- {
- asyncRequest.t = IceUtil::Time::now() + IceUtil::Time::milliSeconds(_endpoint->timeout());
- }
- _asyncRequestsHint = _asyncRequests.insert(_asyncRequests.end(),
- pair<const Int, AsyncRequest>(requestId, asyncRequest));
-
- if(_acmTimeout > 0)
- {
- _acmAbsoluteTimeout = IceUtil::Time::now() + IceUtil::Time::seconds(_acmTimeout);
- }
+
+ //
+ // Add to the async requests map.
+ //
+ struct AsyncRequest asyncRequest;
+ asyncRequest.p = out;
+ if(_endpoint->timeout() > 0)
+ {
+ asyncRequest.t = IceUtil::Time::now() + IceUtil::Time::milliSeconds(_endpoint->timeout());
+ }
+ _asyncRequestsHint = _asyncRequests.insert(_asyncRequests.end(),
+ pair<const Int, AsyncRequest>(requestId, asyncRequest));
+
+ if(_acmTimeout > 0)
+ {
+ _acmAbsoluteTimeout = IceUtil::Time::now() + IceUtil::Time::seconds(_acmTimeout);
+ }
}
try
{
- IceUtil::Mutex::Lock sendSync(_sendMutex);
-
- if(!_transceiver) // Has the transceiver already been closed?
- {
- assert(_exception.get());
- _exception->ice_throw(); // The exception is immutable at this point.
- }
-
- if(compress && os->b.size() >= 100) // Only compress messages larger than 100 bytes.
- {
- //
- // Message compressed. Request compressed response, if any.
- //
- os->b[9] = 2;
-
- //
- // Do compression.
- //
- BasicStream cstream(_instance.get());
- doCompress(*os, cstream);
-
- //
- // Send the request.
- //
- os->i = os->b.begin();
- traceRequest("sending asynchronous request", *os, _logger, _traceLevels);
- cstream.i = cstream.b.begin();
- _transceiver->write(cstream, _endpoint->timeout());
- }
- else
- {
- if(compress)
- {
- //
- // Message not compressed. Request compressed response, if any.
- //
- os->b[9] = 1;
- }
-
- //
- // No compression, just fill in the message size.
- //
- Int sz = static_cast<Int>(os->b.size());
- const Byte* p = reinterpret_cast<const Byte*>(&sz);
+ IceUtil::Mutex::Lock sendSync(_sendMutex);
+
+ if(!_transceiver) // Has the transceiver already been closed?
+ {
+ assert(_exception.get());
+ _exception->ice_throw(); // The exception is immutable at this point.
+ }
+
+ if(compress && os->b.size() >= 100) // Only compress messages larger than 100 bytes.
+ {
+ //
+ // Message compressed. Request compressed response, if any.
+ //
+ os->b[9] = 2;
+
+ //
+ // Do compression.
+ //
+ BasicStream cstream(_instance.get());
+ doCompress(*os, cstream);
+
+ //
+ // Send the request.
+ //
+ os->i = os->b.begin();
+ traceRequest("sending asynchronous request", *os, _logger, _traceLevels);
+ cstream.i = cstream.b.begin();
+ _transceiver->write(cstream, _endpoint->timeout());
+ }
+ else
+ {
+ if(compress)
+ {
+ //
+ // Message not compressed. Request compressed response, if any.
+ //
+ os->b[9] = 1;
+ }
+
+ //
+ // No compression, just fill in the message size.
+ //
+ Int sz = static_cast<Int>(os->b.size());
+ const Byte* p = reinterpret_cast<const Byte*>(&sz);
#ifdef ICE_BIG_ENDIAN
- reverse_copy(p, p + sizeof(Int), os->b.begin() + 10);
+ reverse_copy(p, p + sizeof(Int), os->b.begin() + 10);
#else
- copy(p, p + sizeof(Int), os->b.begin() + 10);
+ copy(p, p + sizeof(Int), os->b.begin() + 10);
#endif
- //
- // Send the request.
- //
- os->i = os->b.begin();
- traceRequest("sending asynchronous request", *os, _logger, _traceLevels);
- _transceiver->write(*os, _endpoint->timeout());
- }
+ //
+ // Send the request.
+ //
+ os->i = os->b.begin();
+ traceRequest("sending asynchronous request", *os, _logger, _traceLevels);
+ _transceiver->write(*os, _endpoint->timeout());
+ }
}
catch(const LocalException& ex)
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- setState(StateClosed, ex);
- assert(_exception.get());
-
- //
- // If the request has already been removed from the async
- // request map, we are out of luck. It would mean that
- // finished() has been called already, and therefore the
- // exception has been set using the
- // OutgoingAsync::__finished() callback. In this case, we
- // cannot throw the exception here, because we must not both
- // raise an exception and have OutgoingAsync::__finished()
- // called with an exception. This means that in some rare
- // cases, a request will not be retried even though it
- // could. But I honestly don't know how I could avoid this,
- // without a very elaborate and complex design, which would be
- // bad for performance.
- //
- map<Int, AsyncRequest>::iterator p = _asyncRequests.find(requestId);
- if(p != _asyncRequests.end())
- {
- if(p == _asyncRequestsHint)
- {
- _asyncRequests.erase(p++);
- _asyncRequestsHint = p;
- }
- else
- {
- _asyncRequests.erase(p);
- }
-
- _exception->ice_throw();
- }
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ setState(StateClosed, ex);
+ assert(_exception.get());
+
+ //
+ // If the request has already been removed from the async
+ // request map, we are out of luck. It would mean that
+ // finished() has been called already, and therefore the
+ // exception has been set using the
+ // OutgoingAsync::__finished() callback. In this case, we
+ // cannot throw the exception here, because we must not both
+ // raise an exception and have OutgoingAsync::__finished()
+ // called with an exception. This means that in some rare
+ // cases, a request will not be retried even though it
+ // could. But I honestly don't know how I could avoid this,
+ // without a very elaborate and complex design, which would be
+ // bad for performance.
+ //
+ map<Int, AsyncRequest>::iterator p = _asyncRequests.find(requestId);
+ if(p != _asyncRequests.end())
+ {
+ if(p == _asyncRequestsHint)
+ {
+ _asyncRequests.erase(p++);
+ _asyncRequestsHint = p;
+ }
+ else
+ {
+ _asyncRequests.erase(p);
+ }
+
+ _exception->ice_throw();
+ }
}
}
@@ -835,12 +835,12 @@ Ice::ConnectionI::prepareBatchRequest(BasicStream* os)
//
while(_batchStreamInUse && !_exception.get())
{
- wait();
+ wait();
}
if(_exception.get())
{
- _exception->ice_throw();
+ _exception->ice_throw();
}
assert(_state > StateNotValidated);
@@ -848,15 +848,15 @@ Ice::ConnectionI::prepareBatchRequest(BasicStream* os)
if(_batchStream.b.empty())
{
- try
- {
- _batchStream.writeBlob(requestBatchHdr, sizeof(requestBatchHdr));
- }
- catch(const LocalException& ex)
- {
- setState(StateClosed, ex);
- ex.ice_throw();
- }
+ try
+ {
+ _batchStream.writeBlob(requestBatchHdr, sizeof(requestBatchHdr));
+ }
+ catch(const LocalException& ex)
+ {
+ setState(StateClosed, ex);
+ ex.ice_throw();
+ }
}
_batchStreamInUse = true;
@@ -884,41 +884,41 @@ Ice::ConnectionI::finishBatchRequest(BasicStream* os, bool compress)
_batchStream.swap(*os);
if(_batchAutoFlush)
- {
- IceUtil::Mutex::Lock sendSync(_sendMutex);
- if(!_transceiver)
- {
- assert(_exception.get());
- _exception->ice_throw(); // The exception is immutable at this point.
- }
-
- //
- // Throw memory limit exception if the first message added causes us to
- // go over limit. Otherwise put aside the marshalled message that caused
- // limit to be exceeded and rollback stream to the marker.
- //
- try
- {
- _transceiver->checkSendSize(_batchStream, _instance->messageSizeMax());
- }
- catch(const Ice::Exception&)
- {
- if(_batchRequestNum == 0)
- {
- resetBatch(true);
- throw;
- }
- vector<Ice::Byte>(_batchStream.b.begin() + _batchMarker, _batchStream.b.end()).swap(lastRequest);
- _batchStream.b.resize(_batchMarker);
- autoflush = true;
- }
- }
-
- if(!autoflush)
- {
- //
- // Increment the number of requests in the batch.
- //
+ {
+ IceUtil::Mutex::Lock sendSync(_sendMutex);
+ if(!_transceiver)
+ {
+ assert(_exception.get());
+ _exception->ice_throw(); // The exception is immutable at this point.
+ }
+
+ //
+ // Throw memory limit exception if the first message added causes us to
+ // go over limit. Otherwise put aside the marshalled message that caused
+ // limit to be exceeded and rollback stream to the marker.
+ //
+ try
+ {
+ _transceiver->checkSendSize(_batchStream, _instance->messageSizeMax());
+ }
+ catch(const Ice::Exception&)
+ {
+ if(_batchRequestNum == 0)
+ {
+ resetBatch(true);
+ throw;
+ }
+ vector<Ice::Byte>(_batchStream.b.begin() + _batchMarker, _batchStream.b.end()).swap(lastRequest);
+ _batchStream.b.resize(_batchMarker);
+ autoflush = true;
+ }
+ }
+
+ if(!autoflush)
+ {
+ //
+ // Increment the number of requests in the batch.
+ //
++_batchRequestNum;
//
@@ -927,7 +927,7 @@ Ice::ConnectionI::finishBatchRequest(BasicStream* os, bool compress)
//
if(compress)
{
- _batchRequestCompress = true;
+ _batchRequestCompress = true;
}
//
@@ -942,41 +942,41 @@ Ice::ConnectionI::finishBatchRequest(BasicStream* os, bool compress)
if(autoflush)
{
//
- // We have to keep _batchStreamInUse set until after we insert the
- // saved marshalled data into a new stream.
- //
+ // We have to keep _batchStreamInUse set until after we insert the
+ // saved marshalled data into a new stream.
+ //
flushBatchRequestsInternal(true);
IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- //
- // Throw memory limit exception if the message that caused us to go over
- // limit causes us to exceed the limit by itself.
- //
+ //
+ // Throw memory limit exception if the message that caused us to go over
+ // limit causes us to exceed the limit by itself.
+ //
if(sizeof(requestBatchHdr) + lastRequest.size() > _instance->messageSizeMax())
- {
- resetBatch(true);
- throw MemoryLimitException(__FILE__, __LINE__);
- }
-
- //
- // Start a new batch with the last message that caused us to
- // go over the limit.
- //
- try
- {
- _batchStream.writeBlob(requestBatchHdr, sizeof(requestBatchHdr));
- _batchStream.writeBlob(&lastRequest[0], lastRequest.size());
- }
- catch(const LocalException& ex)
- {
- setState(StateClosed, ex);
- ex.ice_throw();
- }
+ {
+ resetBatch(true);
+ throw MemoryLimitException(__FILE__, __LINE__);
+ }
+
+ //
+ // Start a new batch with the last message that caused us to
+ // go over the limit.
+ //
+ try
+ {
+ _batchStream.writeBlob(requestBatchHdr, sizeof(requestBatchHdr));
+ _batchStream.writeBlob(&lastRequest[0], lastRequest.size());
+ }
+ catch(const LocalException& ex)
+ {
+ setState(StateClosed, ex);
+ ex.ice_throw();
+ }
if(compress)
{
- _batchRequestCompress = true;
+ _batchRequestCompress = true;
}
//
@@ -984,7 +984,7 @@ Ice::ConnectionI::finishBatchRequest(BasicStream* os, bool compress)
//
++_batchRequestNum;
_batchStreamInUse = false;
- notifyAll();
+ notifyAll();
}
}
@@ -1011,133 +1011,133 @@ void
Ice::ConnectionI::flushBatchRequestsInternal(bool ignoreInUse)
{
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- if(!ignoreInUse)
- {
- while(_batchStreamInUse && !_exception.get())
- {
- wait();
- }
- }
-
- if(_exception.get())
- {
- _exception->ice_throw();
- }
-
- if(_batchStream.b.empty())
- {
- return; // Nothing to do.
- }
-
- assert(_state > StateNotValidated);
- assert(_state < StateClosing);
-
- _batchStream.i = _batchStream.b.begin();
-
- if(_acmTimeout > 0)
- {
- _acmAbsoluteTimeout = IceUtil::Time::now() + IceUtil::Time::seconds(_acmTimeout);
- }
-
- //
- // Prevent that new batch requests are added while we are
- // flushing.
- //
- _batchStreamInUse = true;
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ if(!ignoreInUse)
+ {
+ while(_batchStreamInUse && !_exception.get())
+ {
+ wait();
+ }
+ }
+
+ if(_exception.get())
+ {
+ _exception->ice_throw();
+ }
+
+ if(_batchStream.b.empty())
+ {
+ return; // Nothing to do.
+ }
+
+ assert(_state > StateNotValidated);
+ assert(_state < StateClosing);
+
+ _batchStream.i = _batchStream.b.begin();
+
+ if(_acmTimeout > 0)
+ {
+ _acmAbsoluteTimeout = IceUtil::Time::now() + IceUtil::Time::seconds(_acmTimeout);
+ }
+
+ //
+ // Prevent that new batch requests are added while we are
+ // flushing.
+ //
+ _batchStreamInUse = true;
}
try
{
- IceUtil::Mutex::Lock sendSync(_sendMutex);
+ IceUtil::Mutex::Lock sendSync(_sendMutex);
- if(!_transceiver) // Has the transceiver already been closed?
- {
- assert(_exception.get());
- _exception->ice_throw(); // The exception is immutable at this point.
- }
+ if(!_transceiver) // Has the transceiver already been closed?
+ {
+ assert(_exception.get());
+ _exception->ice_throw(); // The exception is immutable at this point.
+ }
- //
- // Fill in the number of requests in the batch.
- //
- const Byte* p = reinterpret_cast<const Byte*>(&_batchRequestNum);
+ //
+ // Fill in the number of requests in the batch.
+ //
+ const Byte* p = reinterpret_cast<const Byte*>(&_batchRequestNum);
#ifdef ICE_BIG_ENDIAN
- reverse_copy(p, p + sizeof(Int), _batchStream.b.begin() + headerSize);
+ reverse_copy(p, p + sizeof(Int), _batchStream.b.begin() + headerSize);
#else
- copy(p, p + sizeof(Int), _batchStream.b.begin() + headerSize);
+ copy(p, p + sizeof(Int), _batchStream.b.begin() + headerSize);
#endif
-
- if(_batchRequestCompress && _batchStream.b.size() >= 100) // Only compress messages larger than 100 bytes.
- {
- //
- // Message compressed. Request compressed response, if any.
- //
- _batchStream.b[9] = 2;
-
- //
- // Do compression.
- //
- BasicStream cstream(_instance.get());
- doCompress(_batchStream, cstream);
-
- //
- // Send the batch request.
- //
- _batchStream.i = _batchStream.b.begin();
- traceBatchRequest("sending batch request", _batchStream, _logger, _traceLevels);
- cstream.i = cstream.b.begin();
- _transceiver->write(cstream, _endpoint->timeout());
- }
- else
- {
- if(_batchRequestCompress)
- {
- //
- // Message not compressed. Request compressed response, if any.
- //
- _batchStream.b[9] = 1;
- }
-
- //
- // No compression, just fill in the message size.
- //
- Int sz = static_cast<Int>(_batchStream.b.size());
- const Byte* q = reinterpret_cast<const Byte*>(&sz);
+
+ if(_batchRequestCompress && _batchStream.b.size() >= 100) // Only compress messages larger than 100 bytes.
+ {
+ //
+ // Message compressed. Request compressed response, if any.
+ //
+ _batchStream.b[9] = 2;
+
+ //
+ // Do compression.
+ //
+ BasicStream cstream(_instance.get());
+ doCompress(_batchStream, cstream);
+
+ //
+ // Send the batch request.
+ //
+ _batchStream.i = _batchStream.b.begin();
+ traceBatchRequest("sending batch request", _batchStream, _logger, _traceLevels);
+ cstream.i = cstream.b.begin();
+ _transceiver->write(cstream, _endpoint->timeout());
+ }
+ else
+ {
+ if(_batchRequestCompress)
+ {
+ //
+ // Message not compressed. Request compressed response, if any.
+ //
+ _batchStream.b[9] = 1;
+ }
+
+ //
+ // No compression, just fill in the message size.
+ //
+ Int sz = static_cast<Int>(_batchStream.b.size());
+ const Byte* q = reinterpret_cast<const Byte*>(&sz);
#ifdef ICE_BIG_ENDIAN
- reverse_copy(q, q + sizeof(Int), _batchStream.b.begin() + 10);
+ reverse_copy(q, q + sizeof(Int), _batchStream.b.begin() + 10);
#else
- copy(q, q + sizeof(Int), _batchStream.b.begin() + 10);
+ copy(q, q + sizeof(Int), _batchStream.b.begin() + 10);
#endif
-
- //
- // Send the batch request.
- //
- _batchStream.i = _batchStream.b.begin();
- traceBatchRequest("sending batch request", _batchStream, _logger, _traceLevels);
- _transceiver->write(_batchStream, _endpoint->timeout());
- }
+
+ //
+ // Send the batch request.
+ //
+ _batchStream.i = _batchStream.b.begin();
+ traceBatchRequest("sending batch request", _batchStream, _logger, _traceLevels);
+ _transceiver->write(_batchStream, _endpoint->timeout());
+ }
}
catch(const LocalException& ex)
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- setState(StateClosed, ex);
- assert(_exception.get());
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ setState(StateClosed, ex);
+ assert(_exception.get());
- //
- // Since batch requests are all oneways (or datagrams), we
- // must report the exception to the caller.
- //
- _exception->ice_throw();
+ //
+ // Since batch requests are all oneways (or datagrams), we
+ // must report the exception to the caller.
+ //
+ _exception->ice_throw();
}
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- //
- // Reset the batch stream, and notify that flushing is over.
- //
- resetBatch(!ignoreInUse);
+ //
+ // Reset the batch stream, and notify that flushing is over.
+ //
+ resetBatch(!ignoreInUse);
}
}
@@ -1167,100 +1167,100 @@ Ice::ConnectionI::sendResponse(BasicStream* os, Byte compressFlag)
{
try
{
- IceUtil::Mutex::Lock sendSync(_sendMutex);
-
- if(!_transceiver) // Has the transceiver already been closed?
- {
- assert(_exception.get());
- _exception->ice_throw(); // The exception is immutable at this point.
- }
-
- //
- // Only compress if compression was requested by the client,
- // and if the message is larger than 100 bytes.
- //
- if(compressFlag > 0 && os->b.size() >= 100)
- {
- //
- // Message compressed. Request compressed response, if any.
- //
- os->b[9] = 2;
-
- //
- // Do compression.
- //
- BasicStream cstream(_instance.get());
- doCompress(*os, cstream);
-
- //
- // Send the reply.
- //
- os->i = os->b.begin();
- traceReply("sending reply", *os, _logger, _traceLevels);
- cstream.i = cstream.b.begin();
- _transceiver->write(cstream, _endpoint->timeout());
- }
- else
- {
- if(compressFlag > 0)
- {
- //
- // Message not compressed. Request compressed response, if any.
- //
- os->b[9] = 1;
- }
-
- //
- // No compression, just fill in the message size.
- //
- Int sz = static_cast<Int>(os->b.size());
- const Byte* p = reinterpret_cast<const Byte*>(&sz);
+ IceUtil::Mutex::Lock sendSync(_sendMutex);
+
+ if(!_transceiver) // Has the transceiver already been closed?
+ {
+ assert(_exception.get());
+ _exception->ice_throw(); // The exception is immutable at this point.
+ }
+
+ //
+ // Only compress if compression was requested by the client,
+ // and if the message is larger than 100 bytes.
+ //
+ if(compressFlag > 0 && os->b.size() >= 100)
+ {
+ //
+ // Message compressed. Request compressed response, if any.
+ //
+ os->b[9] = 2;
+
+ //
+ // Do compression.
+ //
+ BasicStream cstream(_instance.get());
+ doCompress(*os, cstream);
+
+ //
+ // Send the reply.
+ //
+ os->i = os->b.begin();
+ traceReply("sending reply", *os, _logger, _traceLevels);
+ cstream.i = cstream.b.begin();
+ _transceiver->write(cstream, _endpoint->timeout());
+ }
+ else
+ {
+ if(compressFlag > 0)
+ {
+ //
+ // Message not compressed. Request compressed response, if any.
+ //
+ os->b[9] = 1;
+ }
+
+ //
+ // No compression, just fill in the message size.
+ //
+ Int sz = static_cast<Int>(os->b.size());
+ const Byte* p = reinterpret_cast<const Byte*>(&sz);
#ifdef ICE_BIG_ENDIAN
- reverse_copy(p, p + sizeof(Int), os->b.begin() + 10);
+ reverse_copy(p, p + sizeof(Int), os->b.begin() + 10);
#else
- copy(p, p + sizeof(Int), os->b.begin() + 10);
+ copy(p, p + sizeof(Int), os->b.begin() + 10);
#endif
-
- //
- // Send the reply.
- //
- os->i = os->b.begin();
- traceReply("sending reply", *os, _logger, _traceLevels);
- _transceiver->write(*os, _endpoint->timeout());
- }
+
+ //
+ // Send the reply.
+ //
+ os->i = os->b.begin();
+ traceReply("sending reply", *os, _logger, _traceLevels);
+ _transceiver->write(*os, _endpoint->timeout());
+ }
}
catch(const LocalException& ex)
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- setState(StateClosed, ex);
- }
-
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- assert(_state > StateNotValidated);
-
- try
- {
- if(--_dispatchCount == 0)
- {
- notifyAll();
- }
-
- if(_state == StateClosing && _dispatchCount == 0)
- {
- initiateShutdown();
- }
-
- if(_acmTimeout > 0)
- {
- _acmAbsoluteTimeout = IceUtil::Time::now() + IceUtil::Time::seconds(_acmTimeout);
- }
- }
- catch(const LocalException& ex)
- {
- setState(StateClosed, ex);
- }
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ setState(StateClosed, ex);
+ }
+
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ assert(_state > StateNotValidated);
+
+ try
+ {
+ if(--_dispatchCount == 0)
+ {
+ notifyAll();
+ }
+
+ if(_state == StateClosing && _dispatchCount == 0)
+ {
+ initiateShutdown();
+ }
+
+ if(_acmTimeout > 0)
+ {
+ _acmAbsoluteTimeout = IceUtil::Time::now() + IceUtil::Time::seconds(_acmTimeout);
+ }
+ }
+ catch(const LocalException& ex)
+ {
+ setState(StateClosed, ex);
+ }
}
}
@@ -1273,19 +1273,19 @@ Ice::ConnectionI::sendNoResponse()
try
{
- if(--_dispatchCount == 0)
- {
- notifyAll();
- }
+ if(--_dispatchCount == 0)
+ {
+ notifyAll();
+ }
- if(_state == StateClosing && _dispatchCount == 0)
- {
- initiateShutdown();
- }
+ if(_state == StateClosing && _dispatchCount == 0)
+ {
+ initiateShutdown();
+ }
}
catch(const LocalException& ex)
{
- setState(StateClosed, ex);
+ setState(StateClosed, ex);
}
}
@@ -1308,7 +1308,7 @@ Ice::ConnectionI::setAdapter(const ObjectAdapterPtr& adapter)
if(_exception.get())
{
- _exception->ice_throw();
+ _exception->ice_throw();
}
assert(_state < StateClosing);
@@ -1317,15 +1317,15 @@ Ice::ConnectionI::setAdapter(const ObjectAdapterPtr& adapter)
if(_adapter)
{
- _servantManager = dynamic_cast<ObjectAdapterI*>(_adapter.get())->getServantManager();
- if(!_servantManager)
- {
- _adapter = 0;
- }
+ _servantManager = dynamic_cast<ObjectAdapterI*>(_adapter.get())->getServantManager();
+ if(!_servantManager)
+ {
+ _adapter = 0;
+ }
}
else
{
- _servantManager = 0;
+ _servantManager = 0;
}
//
@@ -1351,7 +1351,7 @@ Ice::ConnectionI::createProxy(const Identity& ident) const
vector<ConnectionIPtr> connections;
connections.push_back(const_cast<ConnectionI*>(this));
ReferencePtr ref = _instance->referenceFactory()->create(ident, _instance->getDefaultContext(),
- "", Reference::ModeTwoway, connections);
+ "", Reference::ModeTwoway, connections);
return _instance->proxyFactory()->referenceToProxy(ref);
}
@@ -1396,28 +1396,28 @@ Ice::ConnectionI::message(BasicStream& stream, const ThreadPoolPtr& threadPool)
OutgoingAsyncPtr outAsync;
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- //
- // We must promote within the synchronization, otherwise there
- // could be various race conditions with close connection
- // messages and other messages.
- //
- threadPool->promoteFollower();
+ //
+ // We must promote within the synchronization, otherwise there
+ // could be various race conditions with close connection
+ // messages and other messages.
+ //
+ threadPool->promoteFollower();
- if(_state != StateClosed)
- {
- parseMessage(stream, invokeNum, requestId, compress, servantManager, adapter, outAsync);
- }
+ if(_state != StateClosed)
+ {
+ parseMessage(stream, invokeNum, requestId, compress, servantManager, adapter, outAsync);
+ }
- //
- // parseMessage() can close the connection, so we must check
- // for closed state again.
- //
- if(_state == StateClosed)
- {
- return;
- }
+ //
+ // parseMessage() can close the connection, so we must check
+ // for closed state again.
+ //
+ if(_state == StateClosed)
+ {
+ return;
+ }
}
//
@@ -1426,7 +1426,7 @@ Ice::ConnectionI::message(BasicStream& stream, const ThreadPoolPtr& threadPool)
//
if(outAsync)
{
- outAsync->__finished(stream);
+ outAsync->__finished(stream);
}
//
@@ -1450,57 +1450,57 @@ Ice::ConnectionI::finished(const ThreadPoolPtr& threadPool)
map<Int, AsyncRequest> asyncRequests;
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- --_finishedCount;
- assert(threadPool.get() == _threadPool.get());
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ --_finishedCount;
+ assert(threadPool.get() == _threadPool.get());
- if(_finishedCount == 0 && _state == StateClosed)
- {
- _threadPool->decFdsInUse();
+ if(_finishedCount == 0 && _state == StateClosed)
+ {
+ _threadPool->decFdsInUse();
- //
- // We must make sure that nobody is sending when we close
- // the transceiver.
- //
- IceUtil::Mutex::Lock sendSync(_sendMutex);
+ //
+ // We must make sure that nobody is sending when we close
+ // the transceiver.
+ //
+ IceUtil::Mutex::Lock sendSync(_sendMutex);
- try
- {
- _transceiver->close();
- }
- catch(const LocalException& ex)
- {
- localEx.reset(dynamic_cast<LocalException*>(ex.ice_clone()));
- }
+ try
+ {
+ _transceiver->close();
+ }
+ catch(const LocalException& ex)
+ {
+ localEx.reset(dynamic_cast<LocalException*>(ex.ice_clone()));
+ }
- _transceiver = 0;
- notifyAll();
- }
+ _transceiver = 0;
+ notifyAll();
+ }
- if(_state == StateClosed || _state == StateClosing)
- {
- requests.swap(_requests);
- _requestsHint = _requests.end();
+ if(_state == StateClosed || _state == StateClosing)
+ {
+ requests.swap(_requests);
+ _requestsHint = _requests.end();
- asyncRequests.swap(_asyncRequests);
- _asyncRequestsHint = _asyncRequests.end();
- }
+ asyncRequests.swap(_asyncRequests);
+ _asyncRequestsHint = _asyncRequests.end();
+ }
}
for(map<Int, Outgoing*>::iterator p = requests.begin(); p != requests.end(); ++p)
{
- p->second->finished(*_exception.get()); // The exception is immutable at this point.
+ p->second->finished(*_exception.get()); // The exception is immutable at this point.
}
for(map<Int, AsyncRequest>::iterator q = asyncRequests.begin(); q != asyncRequests.end(); ++q)
{
- q->second.p->__finished(*_exception.get()); // The exception is immutable at this point.
+ q->second.p->__finished(*_exception.get()); // The exception is immutable at this point.
}
if(localEx.get())
{
- localEx->ice_throw();
+ localEx->ice_throw();
}
}
@@ -1524,13 +1524,13 @@ Ice::ConnectionI::invokeException(const LocalException& ex, int invokeNum)
if(invokeNum > 0)
{
- assert(_dispatchCount > 0);
- _dispatchCount -= invokeNum;
- assert(_dispatchCount >= 0);
- if(_dispatchCount == 0)
- {
- notifyAll();
- }
+ assert(_dispatchCount > 0);
+ _dispatchCount -= invokeNum;
+ assert(_dispatchCount >= 0);
+ if(_dispatchCount == 0)
+ {
+ notifyAll();
+ }
}
}
@@ -1565,9 +1565,9 @@ Ice::ConnectionI::getTransceiver() const
}
Ice::ConnectionI::ConnectionI(const InstancePtr& instance,
- const TransceiverPtr& transceiver,
- const EndpointIPtr& endpoint,
- const ObjectAdapterPtr& adapter,
+ const TransceiverPtr& transceiver,
+ const EndpointIPtr& endpoint,
+ const ObjectAdapterPtr& adapter,
bool threadPerConnection,
size_t threadPerConnectionStackSize) :
EventHandler(instance),
@@ -1601,92 +1601,92 @@ Ice::ConnectionI::ConnectionI(const InstancePtr& instance,
Int& acmTimeout = const_cast<Int&>(_acmTimeout);
if(_endpoint->datagram())
{
- acmTimeout = 0;
+ acmTimeout = 0;
}
else
{
- if(_adapter)
- {
- acmTimeout = _instance->serverACM();
- }
- else
- {
- acmTimeout = _instance->clientACM();
- }
+ if(_adapter)
+ {
+ acmTimeout = _instance->serverACM();
+ }
+ else
+ {
+ acmTimeout = _instance->clientACM();
+ }
}
int& compressionLevel = const_cast<int&>(_compressionLevel);
compressionLevel = _instance->initializationData().properties->getPropertyAsIntWithDefault(
- "Ice.Compression.Level", 1);
+ "Ice.Compression.Level", 1);
if(compressionLevel < 1)
{
- compressionLevel = 1;
+ compressionLevel = 1;
}
else if(compressionLevel > 9)
{
- compressionLevel = 9;
+ compressionLevel = 9;
}
ObjectAdapterI* adapterImpl = _adapter ? dynamic_cast<ObjectAdapterI*>(_adapter.get()) : 0;
if(adapterImpl)
{
- _servantManager = adapterImpl->getServantManager();
+ _servantManager = adapterImpl->getServantManager();
}
__setNoDelete(true);
try
{
- if(!threadPerConnection)
- {
- //
- // Only set _threadPool if we really need it, i.e., if we are
- // not in thread per connection mode. Thread pools have lazy
- // initialization in Instance, and we don't want them to be
- // created if they are not needed.
- //
- if(adapterImpl)
- {
- const_cast<ThreadPoolPtr&>(_threadPool) = adapterImpl->getThreadPool();
- }
- else
- {
- const_cast<ThreadPoolPtr&>(_threadPool) = _instance->clientThreadPool();
- }
- _threadPool->incFdsInUse();
- }
- else
- {
- //
- // If we are in thread per connection mode, create the
- // thread for this connection.
- //
- _thread = new ThreadPerConnection(this);
- _thread->start(threadPerConnectionStackSize);
- }
+ if(!threadPerConnection)
+ {
+ //
+ // Only set _threadPool if we really need it, i.e., if we are
+ // not in thread per connection mode. Thread pools have lazy
+ // initialization in Instance, and we don't want them to be
+ // created if they are not needed.
+ //
+ if(adapterImpl)
+ {
+ const_cast<ThreadPoolPtr&>(_threadPool) = adapterImpl->getThreadPool();
+ }
+ else
+ {
+ const_cast<ThreadPoolPtr&>(_threadPool) = _instance->clientThreadPool();
+ }
+ _threadPool->incFdsInUse();
+ }
+ else
+ {
+ //
+ // If we are in thread per connection mode, create the
+ // thread for this connection.
+ //
+ _thread = new ThreadPerConnection(this);
+ _thread->start(threadPerConnectionStackSize);
+ }
}
catch(const IceUtil::Exception& ex)
{
- {
- Error out(_logger);
- if(threadPerConnection)
- {
- out << "cannot create thread for connection:\n" << ex;
- }
- // Otherwise with thread pool the thread pool itself
- // prints a warning if the threads cannot be created.
- }
-
- try
- {
- _transceiver->close();
- }
- catch(const LocalException&)
- {
- // Here we ignore any exceptions in close().
- }
-
- __setNoDelete(false);
- ex.ice_throw();
+ {
+ Error out(_logger);
+ if(threadPerConnection)
+ {
+ out << "cannot create thread for connection:\n" << ex;
+ }
+ // Otherwise with thread pool the thread pool itself
+ // prints a warning if the threads cannot be created.
+ }
+
+ try
+ {
+ _transceiver->close();
+ }
+ catch(const LocalException&)
+ {
+ // Here we ignore any exceptions in close().
+ }
+
+ __setNoDelete(false);
+ ex.ice_throw();
}
__setNoDelete(false);
}
@@ -1710,40 +1710,40 @@ Ice::ConnectionI::setState(State state, const LocalException& ex)
if(_state == state) // Don't switch twice.
{
- return;
+ return;
}
if(!_exception.get())
{
- //
- // If we are in closed state, an exception must be set.
- //
- assert(_state != StateClosed);
-
- _exception.reset(dynamic_cast<LocalException*>(ex.ice_clone()));
-
- if(_warn)
- {
- //
- // We don't warn if we are not validated.
- //
- if(_state > StateNotValidated)
- {
- //
- // Don't warn about certain expected exceptions.
- //
- if(!(dynamic_cast<const CloseConnectionException*>(_exception.get()) ||
- dynamic_cast<const ForcedCloseConnectionException*>(_exception.get()) ||
- dynamic_cast<const ConnectionTimeoutException*>(_exception.get()) ||
- dynamic_cast<const CommunicatorDestroyedException*>(_exception.get()) ||
- dynamic_cast<const ObjectAdapterDeactivatedException*>(_exception.get()) ||
- (dynamic_cast<const ConnectionLostException*>(_exception.get()) && _state == StateClosing)))
- {
- Warning out(_logger);
- out << "connection exception:\n" << *_exception.get() << '\n' << _desc;
- }
- }
- }
+ //
+ // If we are in closed state, an exception must be set.
+ //
+ assert(_state != StateClosed);
+
+ _exception.reset(dynamic_cast<LocalException*>(ex.ice_clone()));
+
+ if(_warn)
+ {
+ //
+ // We don't warn if we are not validated.
+ //
+ if(_state > StateNotValidated)
+ {
+ //
+ // Don't warn about certain expected exceptions.
+ //
+ if(!(dynamic_cast<const CloseConnectionException*>(_exception.get()) ||
+ dynamic_cast<const ForcedCloseConnectionException*>(_exception.get()) ||
+ dynamic_cast<const ConnectionTimeoutException*>(_exception.get()) ||
+ dynamic_cast<const CommunicatorDestroyedException*>(_exception.get()) ||
+ dynamic_cast<const ObjectAdapterDeactivatedException*>(_exception.get()) ||
+ (dynamic_cast<const ConnectionLostException*>(_exception.get()) && _state == StateClosing)))
+ {
+ Warning out(_logger);
+ out << "connection exception:\n" << *_exception.get() << '\n' << _desc;
+ }
+ }
+ }
}
//
@@ -1763,7 +1763,7 @@ Ice::ConnectionI::setState(State state)
//
if(_endpoint->datagram() && state == StateClosing)
{
- state = StateClosed;
+ state = StateClosed;
}
//
@@ -1771,133 +1771,133 @@ Ice::ConnectionI::setState(State state)
//
if(_state == StateNotValidated && state == StateClosing)
{
- state = StateClosed;
+ state = StateClosed;
}
if(_state == state) // Don't switch twice.
{
- return;
+ return;
}
switch(state)
{
- case StateNotValidated:
- {
- assert(false);
- break;
- }
+ case StateNotValidated:
+ {
+ assert(false);
+ break;
+ }
- case StateActive:
- {
- //
+ case StateActive:
+ {
+ //
// Can only switch from holding or not validated to
// active.
- //
- if(_state != StateHolding && _state != StateNotValidated)
- {
- return;
- }
- if(!_threadPerConnection)
- {
- registerWithPool();
- }
- break;
- }
-
- case StateHolding:
- {
- //
- // Can only switch from active or not validated to
- // holding.
- //
- if(_state != StateActive && _state != StateNotValidated)
- {
- return;
- }
- if(!_threadPerConnection)
- {
- unregisterWithPool();
- }
- break;
- }
-
- case StateClosing:
- {
- //
- // Can't change back from closed.
- //
- if(_state == StateClosed)
- {
- return;
- }
- if(!_threadPerConnection)
- {
- registerWithPool(); // We need to continue to read in closing state.
- }
- break;
- }
-
- case StateClosed:
- {
- if(_threadPerConnection)
- {
- //
- // If we are in thread per connection mode, we
- // shutdown both for reading and writing. This will
- // unblock and read call with an exception. The thread
- // per connection then closes the transceiver.
- //
- _transceiver->shutdownReadWrite();
- }
- else if(_state == StateNotValidated)
- {
- //
- // If we change from not validated we can close right
- // away.
- //
- assert(!_registeredWithPool);
-
- _threadPool->decFdsInUse();
-
- //
- // We must make sure that nobody is sending when we
- // close the transceiver.
- //
- IceUtil::Mutex::Lock sendSync(_sendMutex);
-
- try
- {
- _transceiver->close();
- }
- catch(const LocalException&)
- {
- // Here we ignore any exceptions in close().
- }
-
- _transceiver = 0;
- //notifyAll(); // We notify already below.
- }
- else
- {
- //
- // Otherwise we first must make sure that we are
- // registered, then we unregister, and let finished()
- // do the close.
- //
- registerWithPool();
- unregisterWithPool();
-
- //
- // We must prevent any further writes when _state == StateClosed.
- // However, functions such as sendResponse cannot acquire the main
- // mutex in order to check _state. Therefore we shut down the write
- // end of the transceiver, which causes subsequent write attempts
- // to fail with an exception.
- //
- _transceiver->shutdownWrite();
- }
- break;
- }
+ //
+ if(_state != StateHolding && _state != StateNotValidated)
+ {
+ return;
+ }
+ if(!_threadPerConnection)
+ {
+ registerWithPool();
+ }
+ break;
+ }
+
+ case StateHolding:
+ {
+ //
+ // Can only switch from active or not validated to
+ // holding.
+ //
+ if(_state != StateActive && _state != StateNotValidated)
+ {
+ return;
+ }
+ if(!_threadPerConnection)
+ {
+ unregisterWithPool();
+ }
+ break;
+ }
+
+ case StateClosing:
+ {
+ //
+ // Can't change back from closed.
+ //
+ if(_state == StateClosed)
+ {
+ return;
+ }
+ if(!_threadPerConnection)
+ {
+ registerWithPool(); // We need to continue to read in closing state.
+ }
+ break;
+ }
+
+ case StateClosed:
+ {
+ if(_threadPerConnection)
+ {
+ //
+ // If we are in thread per connection mode, we
+ // shutdown both for reading and writing. This will
+ // unblock and read call with an exception. The thread
+ // per connection then closes the transceiver.
+ //
+ _transceiver->shutdownReadWrite();
+ }
+ else if(_state == StateNotValidated)
+ {
+ //
+ // If we change from not validated we can close right
+ // away.
+ //
+ assert(!_registeredWithPool);
+
+ _threadPool->decFdsInUse();
+
+ //
+ // We must make sure that nobody is sending when we
+ // close the transceiver.
+ //
+ IceUtil::Mutex::Lock sendSync(_sendMutex);
+
+ try
+ {
+ _transceiver->close();
+ }
+ catch(const LocalException&)
+ {
+ // Here we ignore any exceptions in close().
+ }
+
+ _transceiver = 0;
+ //notifyAll(); // We notify already below.
+ }
+ else
+ {
+ //
+ // Otherwise we first must make sure that we are
+ // registered, then we unregister, and let finished()
+ // do the close.
+ //
+ registerWithPool();
+ unregisterWithPool();
+
+ //
+ // We must prevent any further writes when _state == StateClosed.
+ // However, functions such as sendResponse cannot acquire the main
+ // mutex in order to check _state. Therefore we shut down the write
+ // end of the transceiver, which causes subsequent write attempts
+ // to fail with an exception.
+ //
+ _transceiver->shutdownWrite();
+ }
+ break;
+ }
}
//
@@ -1909,14 +1909,14 @@ Ice::ConnectionI::setState(State state)
ConnectionMonitorPtr connectionMonitor = _instance->connectionMonitor();
if(connectionMonitor)
{
- if(state == StateActive)
- {
- connectionMonitor->add(this);
- }
- else if(_state == StateActive)
- {
- connectionMonitor->remove(this);
- }
+ if(state == StateActive)
+ {
+ connectionMonitor->add(this);
+ }
+ else if(_state == StateActive)
+ {
+ connectionMonitor->remove(this);
+ }
}
_state = state;
@@ -1926,14 +1926,14 @@ Ice::ConnectionI::setState(State state)
if(_state == StateClosing && _dispatchCount == 0)
{
- try
- {
- initiateShutdown();
- }
- catch(const LocalException& ex)
- {
- setState(StateClosed, ex);
- }
+ try
+ {
+ initiateShutdown();
+ }
+ catch(const LocalException& ex)
+ {
+ setState(StateClosed, ex);
+ }
}
}
@@ -1945,39 +1945,39 @@ Ice::ConnectionI::initiateShutdown() const
if(!_endpoint->datagram())
{
- IceUtil::Mutex::Lock sendSync(_sendMutex);
-
- //
- // Before we shut down, we send a close connection message.
- //
- BasicStream os(_instance.get());
- os.write(magic[0]);
- os.write(magic[1]);
- os.write(magic[2]);
- os.write(magic[3]);
- os.write(protocolMajor);
- os.write(protocolMinor);
- os.write(encodingMajor);
- os.write(encodingMinor);
- os.write(closeConnectionMsg);
- os.write((Byte)1); // Compression status: compression supported but not used.
- os.write(headerSize); // Message size.
-
- //
- // Send the message.
- //
- os.i = os.b.begin();
- traceHeader("sending close connection", os, _logger, _traceLevels);
- _transceiver->write(os, _endpoint->timeout());
- //
- // The CloseConnection message should be sufficient. Closing the write
- // end of the socket is probably an artifact of how things were done
- // in IIOP. In fact, shutting down the write end of the socket causes
- // problems on Windows by preventing the peer from using the socket.
- // For example, the peer is no longer able to continue writing a large
- // message after the socket is shutdown.
- //
- //_transceiver->shutdownWrite();
+ IceUtil::Mutex::Lock sendSync(_sendMutex);
+
+ //
+ // Before we shut down, we send a close connection message.
+ //
+ BasicStream os(_instance.get());
+ os.write(magic[0]);
+ os.write(magic[1]);
+ os.write(magic[2]);
+ os.write(magic[3]);
+ os.write(protocolMajor);
+ os.write(protocolMinor);
+ os.write(encodingMajor);
+ os.write(encodingMinor);
+ os.write(closeConnectionMsg);
+ os.write((Byte)1); // Compression status: compression supported but not used.
+ os.write(headerSize); // Message size.
+
+ //
+ // Send the message.
+ //
+ os.i = os.b.begin();
+ traceHeader("sending close connection", os, _logger, _traceLevels);
+ _transceiver->write(os, _endpoint->timeout());
+ //
+ // The CloseConnection message should be sufficient. Closing the write
+ // end of the socket is probably an artifact of how things were done
+ // in IIOP. In fact, shutting down the write end of the socket causes
+ // problems on Windows by preventing the peer from using the socket.
+ // For example, the peer is no longer able to continue writing a large
+ // message after the socket is shutdown.
+ //
+ //_transceiver->shutdownWrite();
}
}
@@ -1988,8 +1988,8 @@ Ice::ConnectionI::registerWithPool()
if(!_registeredWithPool)
{
- _threadPool->_register(_transceiver->fd(), this);
- _registeredWithPool = true;
+ _threadPool->_register(_transceiver->fd(), this);
+ _registeredWithPool = true;
}
}
@@ -2000,9 +2000,9 @@ Ice::ConnectionI::unregisterWithPool()
if(_registeredWithPool)
{
- _threadPool->unregister(_transceiver->fd());
- _registeredWithPool = false;
- ++_finishedCount; // For each unregistration, finished() is called once.
+ _threadPool->unregister(_transceiver->fd());
+ _registeredWithPool = false;
+ ++_finishedCount; // For each unregistration, finished() is called once.
}
}
@@ -2011,59 +2011,59 @@ getBZ2Error(int bzError)
{
if(bzError == BZ_RUN_OK)
{
- return ": BZ_RUN_OK";
+ return ": BZ_RUN_OK";
}
else if(bzError == BZ_FLUSH_OK)
{
- return ": BZ_FLUSH_OK";
+ return ": BZ_FLUSH_OK";
}
else if(bzError == BZ_FINISH_OK)
{
- return ": BZ_FINISH_OK";
+ return ": BZ_FINISH_OK";
}
else if(bzError == BZ_STREAM_END)
{
- return ": BZ_STREAM_END";
+ return ": BZ_STREAM_END";
}
else if(bzError == BZ_CONFIG_ERROR)
{
- return ": BZ_CONFIG_ERROR";
+ return ": BZ_CONFIG_ERROR";
}
else if(bzError == BZ_SEQUENCE_ERROR)
{
- return ": BZ_SEQUENCE_ERROR";
+ return ": BZ_SEQUENCE_ERROR";
}
else if(bzError == BZ_PARAM_ERROR)
{
- return ": BZ_PARAM_ERROR";
+ return ": BZ_PARAM_ERROR";
}
else if(bzError == BZ_MEM_ERROR)
{
- return ": BZ_MEM_ERROR";
+ return ": BZ_MEM_ERROR";
}
else if(bzError == BZ_DATA_ERROR)
{
- return ": BZ_DATA_ERROR";
+ return ": BZ_DATA_ERROR";
}
else if(bzError == BZ_DATA_ERROR_MAGIC)
{
- return ": BZ_DATA_ERROR_MAGIC";
+ return ": BZ_DATA_ERROR_MAGIC";
}
else if(bzError == BZ_IO_ERROR)
{
- return ": BZ_IO_ERROR";
+ return ": BZ_IO_ERROR";
}
else if(bzError == BZ_UNEXPECTED_EOF)
{
- return ": BZ_UNEXPECTED_EOF";
+ return ": BZ_UNEXPECTED_EOF";
}
else if(bzError == BZ_OUTBUFF_FULL)
{
- return ": BZ_OUTBUFF_FULL";
+ return ": BZ_OUTBUFF_FULL";
}
else
{
- return "";
+ return "";
}
}
@@ -2079,15 +2079,15 @@ Ice::ConnectionI::doCompress(BasicStream& uncompressed, BasicStream& compressed)
unsigned int compressedLen = static_cast<unsigned int>(uncompressedLen * 1.01 + 600);
compressed.b.resize(headerSize + sizeof(Int) + compressedLen);
int bzError = BZ2_bzBuffToBuffCompress(reinterpret_cast<char*>(&compressed.b[0]) + headerSize + sizeof(Int),
- &compressedLen,
- reinterpret_cast<char*>(&uncompressed.b[0]) + headerSize,
- uncompressedLen,
- _compressionLevel, 0, 0);
+ &compressedLen,
+ reinterpret_cast<char*>(&uncompressed.b[0]) + headerSize,
+ uncompressedLen,
+ _compressionLevel, 0, 0);
if(bzError != BZ_OK)
{
- CompressionException ex(__FILE__, __LINE__);
- ex.reason = "BZ2_bzBuffToBuffCompress failed" + getBZ2Error(bzError);
- throw ex;
+ CompressionException ex(__FILE__, __LINE__);
+ ex.reason = "BZ2_bzBuffToBuffCompress failed" + getBZ2Error(bzError);
+ throw ex;
}
compressed.b.resize(headerSize + sizeof(Int) + compressedLen);
@@ -2130,22 +2130,22 @@ Ice::ConnectionI::doUncompress(BasicStream& compressed, BasicStream& uncompresse
compressed.read(uncompressedSize);
if(uncompressedSize <= headerSize)
{
- throw IllegalMessageSizeException(__FILE__, __LINE__);
+ throw IllegalMessageSizeException(__FILE__, __LINE__);
}
uncompressed.resize(uncompressedSize);
unsigned int uncompressedLen = uncompressedSize - headerSize;
unsigned int compressedLen = static_cast<unsigned int>(compressed.b.size() - headerSize - sizeof(Int));
int bzError = BZ2_bzBuffToBuffDecompress(reinterpret_cast<char*>(&uncompressed.b[0]) + headerSize,
- &uncompressedLen,
- reinterpret_cast<char*>(&compressed.b[0]) + headerSize + sizeof(Int),
- compressedLen,
- 0, 0);
+ &uncompressedLen,
+ reinterpret_cast<char*>(&compressed.b[0]) + headerSize + sizeof(Int),
+ compressedLen,
+ 0, 0);
if(bzError != BZ_OK)
{
- CompressionException ex(__FILE__, __LINE__);
- ex.reason = "BZ2_bzBuffToBuffCompress failed" + getBZ2Error(bzError);
- throw ex;
+ CompressionException ex(__FILE__, __LINE__);
+ ex.reason = "BZ2_bzBuffToBuffCompress failed" + getBZ2Error(bzError);
+ throw ex;
}
copy(compressed.b.begin(), compressed.b.begin() + headerSize, uncompressed.b.begin());
@@ -2153,222 +2153,222 @@ Ice::ConnectionI::doUncompress(BasicStream& compressed, BasicStream& uncompresse
void
Ice::ConnectionI::parseMessage(BasicStream& stream, Int& invokeNum, Int& requestId, Byte& compress,
- ServantManagerPtr& servantManager, ObjectAdapterPtr& adapter,
- OutgoingAsyncPtr& outAsync)
+ ServantManagerPtr& servantManager, ObjectAdapterPtr& adapter,
+ OutgoingAsyncPtr& outAsync)
{
assert(_state > StateNotValidated && _state < StateClosed);
if(_acmTimeout > 0)
{
- _acmAbsoluteTimeout = IceUtil::Time::now() + IceUtil::Time::seconds(_acmTimeout);
+ _acmAbsoluteTimeout = IceUtil::Time::now() + IceUtil::Time::seconds(_acmTimeout);
}
try
{
- //
- // We don't need to check magic and version here. This has
- // already been done by the ThreadPool or the
- // ThreadPerConnection, which provides us with the stream.
- //
- assert(stream.i == stream.b.end());
- stream.i = stream.b.begin() + 8;
- Byte messageType;
- stream.read(messageType);
- stream.read(compress);
- if(compress == 2)
- {
- BasicStream ustream(_instance.get());
- doUncompress(stream, ustream);
- stream.b.swap(ustream.b);
- }
- stream.i = stream.b.begin() + headerSize;
+ //
+ // We don't need to check magic and version here. This has
+ // already been done by the ThreadPool or the
+ // ThreadPerConnection, which provides us with the stream.
+ //
+ assert(stream.i == stream.b.end());
+ stream.i = stream.b.begin() + 8;
+ Byte messageType;
+ stream.read(messageType);
+ stream.read(compress);
+ if(compress == 2)
+ {
+ BasicStream ustream(_instance.get());
+ doUncompress(stream, ustream);
+ stream.b.swap(ustream.b);
+ }
+ stream.i = stream.b.begin() + headerSize;
- switch(messageType)
- {
- case closeConnectionMsg:
- {
- traceHeader("received close connection", stream, _logger, _traceLevels);
- if(_endpoint->datagram())
- {
- if(_warn)
- {
- Warning out(_logger);
- out << "ignoring close connection message for datagram connection:\n" << _desc;
- }
- }
- else
- {
- setState(StateClosed, CloseConnectionException(__FILE__, __LINE__));
- }
- break;
- }
-
- case requestMsg:
- {
- if(_state == StateClosing)
- {
- traceRequest("received request during closing\n"
- "(ignored by server, client will retry)",
- stream, _logger, _traceLevels);
- }
- else
- {
- traceRequest("received request", stream, _logger, _traceLevels);
- stream.read(requestId);
- invokeNum = 1;
- servantManager = _servantManager;
- adapter = _adapter;
- ++_dispatchCount;
- }
- break;
- }
-
- case requestBatchMsg:
- {
- if(_state == StateClosing)
- {
- traceBatchRequest("received batch request during closing\n"
- "(ignored by server, client will retry)",
- stream, _logger, _traceLevels);
- }
- else
- {
- traceBatchRequest("received batch request", stream, _logger, _traceLevels);
- stream.read(invokeNum);
- if(invokeNum < 0)
- {
- invokeNum = 0;
- throw NegativeSizeException(__FILE__, __LINE__);
- }
- servantManager = _servantManager;
- adapter = _adapter;
- _dispatchCount += invokeNum;
- }
- break;
- }
-
- case replyMsg:
- {
- traceReply("received reply", stream, _logger, _traceLevels);
-
- stream.read(requestId);
-
- map<Int, Outgoing*>::iterator p = _requests.end();
- map<Int, AsyncRequest>::iterator q = _asyncRequests.end();
-
- if(_requestsHint != _requests.end())
- {
- if(_requestsHint->first == requestId)
- {
- p = _requestsHint;
- }
- }
-
- if(p == _requests.end())
- {
- if(_asyncRequestsHint != _asyncRequests.end())
- {
- if(_asyncRequestsHint->first == requestId)
- {
- q = _asyncRequestsHint;
- }
- }
- }
-
- if(p == _requests.end() && q == _asyncRequests.end())
- {
- p = _requests.find(requestId);
- }
-
- if(p == _requests.end() && q == _asyncRequests.end())
- {
- q = _asyncRequests.find(requestId);
- }
-
- if(p == _requests.end() && q == _asyncRequests.end())
- {
- throw UnknownRequestIdException(__FILE__, __LINE__);
- }
-
- if(p != _requests.end())
- {
- p->second->finished(stream);
-
- if(p == _requestsHint)
- {
- _requests.erase(p++);
- _requestsHint = p;
- }
- else
- {
- _requests.erase(p);
- }
- }
- else
- {
- assert(q != _asyncRequests.end());
-
- outAsync = q->second.p;
-
- if(q == _asyncRequestsHint)
- {
- _asyncRequests.erase(q++);
- _asyncRequestsHint = q;
- }
- else
- {
- _asyncRequests.erase(q);
- }
- }
-
- break;
- }
-
- case validateConnectionMsg:
- {
- traceHeader("received validate connection", stream, _logger, _traceLevels);
- if(_warn)
- {
- Warning out(_logger);
- out << "ignoring unexpected validate connection message:\n" << _desc;
- }
- break;
- }
-
- default:
- {
- traceHeader("received unknown message\n"
- "(invalid, closing connection)",
- stream, _logger, _traceLevels);
- throw UnknownMessageException(__FILE__, __LINE__);
- break;
- }
- }
+ switch(messageType)
+ {
+ case closeConnectionMsg:
+ {
+ traceHeader("received close connection", stream, _logger, _traceLevels);
+ if(_endpoint->datagram())
+ {
+ if(_warn)
+ {
+ Warning out(_logger);
+ out << "ignoring close connection message for datagram connection:\n" << _desc;
+ }
+ }
+ else
+ {
+ setState(StateClosed, CloseConnectionException(__FILE__, __LINE__));
+ }
+ break;
+ }
+
+ case requestMsg:
+ {
+ if(_state == StateClosing)
+ {
+ traceRequest("received request during closing\n"
+ "(ignored by server, client will retry)",
+ stream, _logger, _traceLevels);
+ }
+ else
+ {
+ traceRequest("received request", stream, _logger, _traceLevels);
+ stream.read(requestId);
+ invokeNum = 1;
+ servantManager = _servantManager;
+ adapter = _adapter;
+ ++_dispatchCount;
+ }
+ break;
+ }
+
+ case requestBatchMsg:
+ {
+ if(_state == StateClosing)
+ {
+ traceBatchRequest("received batch request during closing\n"
+ "(ignored by server, client will retry)",
+ stream, _logger, _traceLevels);
+ }
+ else
+ {
+ traceBatchRequest("received batch request", stream, _logger, _traceLevels);
+ stream.read(invokeNum);
+ if(invokeNum < 0)
+ {
+ invokeNum = 0;
+ throw NegativeSizeException(__FILE__, __LINE__);
+ }
+ servantManager = _servantManager;
+ adapter = _adapter;
+ _dispatchCount += invokeNum;
+ }
+ break;
+ }
+
+ case replyMsg:
+ {
+ traceReply("received reply", stream, _logger, _traceLevels);
+
+ stream.read(requestId);
+
+ map<Int, Outgoing*>::iterator p = _requests.end();
+ map<Int, AsyncRequest>::iterator q = _asyncRequests.end();
+
+ if(_requestsHint != _requests.end())
+ {
+ if(_requestsHint->first == requestId)
+ {
+ p = _requestsHint;
+ }
+ }
+
+ if(p == _requests.end())
+ {
+ if(_asyncRequestsHint != _asyncRequests.end())
+ {
+ if(_asyncRequestsHint->first == requestId)
+ {
+ q = _asyncRequestsHint;
+ }
+ }
+ }
+
+ if(p == _requests.end() && q == _asyncRequests.end())
+ {
+ p = _requests.find(requestId);
+ }
+
+ if(p == _requests.end() && q == _asyncRequests.end())
+ {
+ q = _asyncRequests.find(requestId);
+ }
+
+ if(p == _requests.end() && q == _asyncRequests.end())
+ {
+ throw UnknownRequestIdException(__FILE__, __LINE__);
+ }
+
+ if(p != _requests.end())
+ {
+ p->second->finished(stream);
+
+ if(p == _requestsHint)
+ {
+ _requests.erase(p++);
+ _requestsHint = p;
+ }
+ else
+ {
+ _requests.erase(p);
+ }
+ }
+ else
+ {
+ assert(q != _asyncRequests.end());
+
+ outAsync = q->second.p;
+
+ if(q == _asyncRequestsHint)
+ {
+ _asyncRequests.erase(q++);
+ _asyncRequestsHint = q;
+ }
+ else
+ {
+ _asyncRequests.erase(q);
+ }
+ }
+
+ break;
+ }
+
+ case validateConnectionMsg:
+ {
+ traceHeader("received validate connection", stream, _logger, _traceLevels);
+ if(_warn)
+ {
+ Warning out(_logger);
+ out << "ignoring unexpected validate connection message:\n" << _desc;
+ }
+ break;
+ }
+
+ default:
+ {
+ traceHeader("received unknown message\n"
+ "(invalid, closing connection)",
+ stream, _logger, _traceLevels);
+ throw UnknownMessageException(__FILE__, __LINE__);
+ break;
+ }
+ }
}
catch(const SocketException& ex)
{
- exception(ex);
+ exception(ex);
}
catch(const LocalException& ex)
{
- if(_endpoint->datagram())
- {
- if(_warn)
- {
- Warning out(_logger);
- out << "datagram connection exception:\n" << ex << '\n' << _desc;
- }
- }
- else
- {
- setState(StateClosed, ex);
- }
+ if(_endpoint->datagram())
+ {
+ if(_warn)
+ {
+ Warning out(_logger);
+ out << "datagram connection exception:\n" << ex << '\n' << _desc;
+ }
+ }
+ else
+ {
+ setState(StateClosed, ex);
+ }
}
}
void
Ice::ConnectionI::invokeAll(BasicStream& stream, Int invokeNum, Int requestId, Byte compress,
- const ServantManagerPtr& servantManager, const ObjectAdapterPtr& adapter)
+ const ServantManagerPtr& servantManager, const ObjectAdapterPtr& adapter)
{
//
// Note: In contrast to other private or protected methods, this
@@ -2377,45 +2377,45 @@ Ice::ConnectionI::invokeAll(BasicStream& stream, Int invokeNum, Int requestId, B
try
{
- while(invokeNum > 0)
- {
- //
- // Prepare the invocation.
- //
- bool response = !_endpoint->datagram() && requestId != 0;
- Incoming in(_instance.get(), this, adapter, response, compress, requestId);
- BasicStream* is = in.is();
- stream.swap(*is);
- BasicStream* os = in.os();
-
- //
- // Prepare the response if necessary.
- //
- if(response)
- {
- assert(invokeNum == 1); // No further invocations if a response is expected.
- os->writeBlob(replyHdr, sizeof(replyHdr));
-
- //
- // Add the request ID.
- //
- os->write(requestId);
- }
-
- in.invoke(servantManager);
-
- //
- // If there are more invocations, we need the stream back.
- //
- if(--invokeNum > 0)
- {
- stream.swap(*is);
- }
- }
+ while(invokeNum > 0)
+ {
+ //
+ // Prepare the invocation.
+ //
+ bool response = !_endpoint->datagram() && requestId != 0;
+ Incoming in(_instance.get(), this, adapter, response, compress, requestId);
+ BasicStream* is = in.is();
+ stream.swap(*is);
+ BasicStream* os = in.os();
+
+ //
+ // Prepare the response if necessary.
+ //
+ if(response)
+ {
+ assert(invokeNum == 1); // No further invocations if a response is expected.
+ os->writeBlob(replyHdr, sizeof(replyHdr));
+
+ //
+ // Add the request ID.
+ //
+ os->write(requestId);
+ }
+
+ in.invoke(servantManager);
+
+ //
+ // If there are more invocations, we need the stream back.
+ //
+ if(--invokeNum > 0)
+ {
+ stream.swap(*is);
+ }
+ }
}
catch(const LocalException& ex)
{
- invokeException(ex, invokeNum); // Fatal invocation exception
+ invokeException(ex, invokeNum); // Fatal invocation exception
}
}
@@ -2430,40 +2430,40 @@ Ice::ConnectionI::run()
//
if(!_endpoint->datagram())
{
- try
- {
- validate();
- }
- catch(const LocalException&)
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- assert(_state == StateClosed);
-
- //
- // We must make sure that nobody is sending when we close
- // the transceiver.
- //
- IceUtil::Mutex::Lock sendSync(_sendMutex);
-
- if(_transceiver)
- {
- try
- {
- _transceiver->close();
- }
- catch(const LocalException&)
- {
- // Here we ignore any exceptions in close().
- }
-
- _transceiver = 0;
- }
- notifyAll();
- return;
- }
-
- activate();
+ try
+ {
+ validate();
+ }
+ catch(const LocalException&)
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ assert(_state == StateClosed);
+
+ //
+ // We must make sure that nobody is sending when we close
+ // the transceiver.
+ //
+ IceUtil::Mutex::Lock sendSync(_sendMutex);
+
+ if(_transceiver)
+ {
+ try
+ {
+ _transceiver->close();
+ }
+ catch(const LocalException&)
+ {
+ // Here we ignore any exceptions in close().
+ }
+
+ _transceiver = 0;
+ }
+ notifyAll();
+ return;
+ }
+
+ activate();
}
const bool warnUdp = _instance->initializationData().properties->getPropertyAsInt("Ice.Warn.Datagrams") > 0;
@@ -2472,213 +2472,213 @@ Ice::ConnectionI::run()
while(!closed)
{
- //
- // We must accept new connections outside the thread
- // synchronization, because we use blocking accept.
- //
-
- BasicStream stream(_instance.get());
-
- try
- {
- stream.b.resize(headerSize);
- stream.i = stream.b.begin();
- _transceiver->read(stream, -1);
-
- ptrdiff_t pos = stream.i - stream.b.begin();
- if(pos < headerSize)
- {
- //
- // This situation is possible for small UDP packets.
- //
- throw IllegalMessageSizeException(__FILE__, __LINE__);
- }
- stream.i = stream.b.begin();
- const Byte* header;
- stream.readBlob(header, headerSize);
- if(header[0] != magic[0] || header[1] != magic[1] || header[2] != magic[2] || header[3] != magic[3])
- {
- BadMagicException ex(__FILE__, __LINE__);
- ex.badMagic = Ice::ByteSeq(&header[0], &header[0] + sizeof(magic));
- throw ex;
- }
- if(header[4] != protocolMajor)
- {
- UnsupportedProtocolException ex(__FILE__, __LINE__);
- ex.badMajor = static_cast<unsigned char>(header[4]);
- ex.badMinor = static_cast<unsigned char>(header[5]);
- ex.major = static_cast<unsigned char>(protocolMajor);
- ex.minor = static_cast<unsigned char>(protocolMinor);
- throw ex;
- }
- if(header[6] != encodingMajor)
- {
- UnsupportedEncodingException ex(__FILE__, __LINE__);
- ex.badMajor = static_cast<unsigned char>(header[6]);
- ex.badMinor = static_cast<unsigned char>(header[7]);
- ex.major = static_cast<unsigned char>(encodingMajor);
- ex.minor = static_cast<unsigned char>(encodingMinor);
- throw ex;
- }
-
- Int size;
- stream.i -= sizeof(Int);
- stream.read(size);
- if(size < headerSize)
- {
- throw IllegalMessageSizeException(__FILE__, __LINE__);
- }
- if(size > static_cast<Int>(_instance->messageSizeMax()))
- {
- throw MemoryLimitException(__FILE__, __LINE__);
- }
- if(size > static_cast<Int>(stream.b.size()))
- {
- stream.b.resize(size);
- }
- stream.i = stream.b.begin() + pos;
-
- if(stream.i != stream.b.end())
- {
- if(_endpoint->datagram())
- {
- if(warnUdp)
- {
- Warning out(_logger);
- out << "DatagramLimitException: maximum size of " << pos << " exceeded";
- }
- throw DatagramLimitException(__FILE__, __LINE__);
- }
- else
- {
- _transceiver->read(stream, -1);
- assert(stream.i == stream.b.end());
- }
- }
- }
- catch(const DatagramLimitException&) // Expected.
- {
- continue;
- }
- catch(const SocketException& ex)
- {
- exception(ex);
- }
- catch(const LocalException& ex)
- {
- if(_endpoint->datagram())
- {
- if(_warn)
- {
- Warning out(_logger);
- out << "datagram connection exception:\n" << ex << '\n' << _desc;
- }
- continue;
- }
- else
- {
- exception(ex);
- }
- }
-
- Byte compress = 0;
- Int requestId = 0;
- Int invokeNum = 0;
- ServantManagerPtr servantManager;
- ObjectAdapterPtr adapter;
- OutgoingAsyncPtr outAsync;
-
- auto_ptr<LocalException> localEx;
-
- map<Int, Outgoing*> requests;
- map<Int, AsyncRequest> asyncRequests;
-
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- while(_state == StateHolding)
- {
- wait();
- }
-
- if(_state != StateClosed)
- {
- parseMessage(stream, invokeNum, requestId, compress, servantManager, adapter, outAsync);
- }
-
- //
+ //
+ // We must accept new connections outside the thread
+ // synchronization, because we use blocking accept.
+ //
+
+ BasicStream stream(_instance.get());
+
+ try
+ {
+ stream.b.resize(headerSize);
+ stream.i = stream.b.begin();
+ _transceiver->read(stream, -1);
+
+ ptrdiff_t pos = stream.i - stream.b.begin();
+ if(pos < headerSize)
+ {
+ //
+ // This situation is possible for small UDP packets.
+ //
+ throw IllegalMessageSizeException(__FILE__, __LINE__);
+ }
+ stream.i = stream.b.begin();
+ const Byte* header;
+ stream.readBlob(header, headerSize);
+ if(header[0] != magic[0] || header[1] != magic[1] || header[2] != magic[2] || header[3] != magic[3])
+ {
+ BadMagicException ex(__FILE__, __LINE__);
+ ex.badMagic = Ice::ByteSeq(&header[0], &header[0] + sizeof(magic));
+ throw ex;
+ }
+ if(header[4] != protocolMajor)
+ {
+ UnsupportedProtocolException ex(__FILE__, __LINE__);
+ ex.badMajor = static_cast<unsigned char>(header[4]);
+ ex.badMinor = static_cast<unsigned char>(header[5]);
+ ex.major = static_cast<unsigned char>(protocolMajor);
+ ex.minor = static_cast<unsigned char>(protocolMinor);
+ throw ex;
+ }
+ if(header[6] != encodingMajor)
+ {
+ UnsupportedEncodingException ex(__FILE__, __LINE__);
+ ex.badMajor = static_cast<unsigned char>(header[6]);
+ ex.badMinor = static_cast<unsigned char>(header[7]);
+ ex.major = static_cast<unsigned char>(encodingMajor);
+ ex.minor = static_cast<unsigned char>(encodingMinor);
+ throw ex;
+ }
+
+ Int size;
+ stream.i -= sizeof(Int);
+ stream.read(size);
+ if(size < headerSize)
+ {
+ throw IllegalMessageSizeException(__FILE__, __LINE__);
+ }
+ if(size > static_cast<Int>(_instance->messageSizeMax()))
+ {
+ throw MemoryLimitException(__FILE__, __LINE__);
+ }
+ if(size > static_cast<Int>(stream.b.size()))
+ {
+ stream.b.resize(size);
+ }
+ stream.i = stream.b.begin() + pos;
+
+ if(stream.i != stream.b.end())
+ {
+ if(_endpoint->datagram())
+ {
+ if(warnUdp)
+ {
+ Warning out(_logger);
+ out << "DatagramLimitException: maximum size of " << pos << " exceeded";
+ }
+ throw DatagramLimitException(__FILE__, __LINE__);
+ }
+ else
+ {
+ _transceiver->read(stream, -1);
+ assert(stream.i == stream.b.end());
+ }
+ }
+ }
+ catch(const DatagramLimitException&) // Expected.
+ {
+ continue;
+ }
+ catch(const SocketException& ex)
+ {
+ exception(ex);
+ }
+ catch(const LocalException& ex)
+ {
+ if(_endpoint->datagram())
+ {
+ if(_warn)
+ {
+ Warning out(_logger);
+ out << "datagram connection exception:\n" << ex << '\n' << _desc;
+ }
+ continue;
+ }
+ else
+ {
+ exception(ex);
+ }
+ }
+
+ Byte compress = 0;
+ Int requestId = 0;
+ Int invokeNum = 0;
+ ServantManagerPtr servantManager;
+ ObjectAdapterPtr adapter;
+ OutgoingAsyncPtr outAsync;
+
+ auto_ptr<LocalException> localEx;
+
+ map<Int, Outgoing*> requests;
+ map<Int, AsyncRequest> asyncRequests;
+
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ while(_state == StateHolding)
+ {
+ wait();
+ }
+
+ if(_state != StateClosed)
+ {
+ parseMessage(stream, invokeNum, requestId, compress, servantManager, adapter, outAsync);
+ }
+
+ //
// parseMessage() can close the connection, so we must
// check for closed state again.
- //
- if(_state == StateClosed)
- {
- //
- // We must make sure that nobody is sending when we close
- // the transceiver.
- //
- IceUtil::Mutex::Lock sendSync(_sendMutex);
-
- try
- {
- _transceiver->close();
- }
- catch(const LocalException& ex)
- {
- localEx.reset(dynamic_cast<LocalException*>(ex.ice_clone()));
- }
-
- _transceiver = 0;
- notifyAll();
-
- //
- // We cannot simply return here. We have to make sure
- // that all requests (regular and async) are notified
- // about the closed connection below.
- //
- closed = true;
- }
-
- if(_state == StateClosed || _state == StateClosing)
- {
- requests.swap(_requests);
- _requestsHint = _requests.end();
-
- asyncRequests.swap(_asyncRequests);
- _asyncRequestsHint = _asyncRequests.end();
- }
- }
-
- //
- // Asynchronous replies must be handled outside the thread
- // synchronization, so that nested calls are possible.
- //
- if(outAsync)
- {
- outAsync->__finished(stream);
- }
-
- //
- // Method invocation (or multiple invocations for batch messages)
- // must be done outside the thread synchronization, so that nested
- // calls are possible.
- //
- invokeAll(stream, invokeNum, requestId, compress, servantManager, adapter);
-
- for(map<Int, Outgoing*>::iterator p = requests.begin(); p != requests.end(); ++p)
- {
- p->second->finished(*_exception.get()); // The exception is immutable at this point.
- }
-
- for(map<Int, AsyncRequest>::iterator q = asyncRequests.begin(); q != asyncRequests.end(); ++q)
- {
- q->second.p->__finished(*_exception.get()); // The exception is immutable at this point.
- }
-
- if(localEx.get())
- {
- assert(closed);
- localEx->ice_throw();
- }
+ //
+ if(_state == StateClosed)
+ {
+ //
+ // We must make sure that nobody is sending when we close
+ // the transceiver.
+ //
+ IceUtil::Mutex::Lock sendSync(_sendMutex);
+
+ try
+ {
+ _transceiver->close();
+ }
+ catch(const LocalException& ex)
+ {
+ localEx.reset(dynamic_cast<LocalException*>(ex.ice_clone()));
+ }
+
+ _transceiver = 0;
+ notifyAll();
+
+ //
+ // We cannot simply return here. We have to make sure
+ // that all requests (regular and async) are notified
+ // about the closed connection below.
+ //
+ closed = true;
+ }
+
+ if(_state == StateClosed || _state == StateClosing)
+ {
+ requests.swap(_requests);
+ _requestsHint = _requests.end();
+
+ asyncRequests.swap(_asyncRequests);
+ _asyncRequestsHint = _asyncRequests.end();
+ }
+ }
+
+ //
+ // Asynchronous replies must be handled outside the thread
+ // synchronization, so that nested calls are possible.
+ //
+ if(outAsync)
+ {
+ outAsync->__finished(stream);
+ }
+
+ //
+ // Method invocation (or multiple invocations for batch messages)
+ // must be done outside the thread synchronization, so that nested
+ // calls are possible.
+ //
+ invokeAll(stream, invokeNum, requestId, compress, servantManager, adapter);
+
+ for(map<Int, Outgoing*>::iterator p = requests.begin(); p != requests.end(); ++p)
+ {
+ p->second->finished(*_exception.get()); // The exception is immutable at this point.
+ }
+
+ for(map<Int, AsyncRequest>::iterator q = asyncRequests.begin(); q != asyncRequests.end(); ++q)
+ {
+ q->second.p->__finished(*_exception.get()); // The exception is immutable at this point.
+ }
+
+ if(localEx.get())
+ {
+ assert(closed);
+ localEx->ice_throw();
+ }
}
}
@@ -2700,19 +2700,19 @@ Ice::ConnectionI::ThreadPerConnection::run()
_connection->run();
}
catch(const Exception& ex)
- {
- Error out(_connection->_logger);
- out << "exception in thread per connection:\n" << _connection->toString() << ex;
+ {
+ Error out(_connection->_logger);
+ out << "exception in thread per connection:\n" << _connection->toString() << ex;
}
catch(const std::exception& ex)
{
- Error out(_connection->_logger);
- out << "std::exception in thread per connection:\n" << _connection->toString() << ex.what();
+ Error out(_connection->_logger);
+ out << "std::exception in thread per connection:\n" << _connection->toString() << ex.what();
}
catch(...)
{
- Error out(_connection->_logger);
- out << "unknown exception in thread per connection:\n" << _connection->toString();
+ Error out(_connection->_logger);
+ out << "unknown exception in thread per connection:\n" << _connection->toString();
}
if(_connection->_instance->initializationData().threadHook)
diff --git a/cpp/src/Ice/ConnectionI.h b/cpp/src/Ice/ConnectionI.h
index 626f1c776be..f07841c5632 100644
--- a/cpp/src/Ice/ConnectionI.h
+++ b/cpp/src/Ice/ConnectionI.h
@@ -40,15 +40,15 @@ namespace Ice
class LocalException;
class ICE_API ConnectionI : public Connection, public IceInternal::EventHandler,
- public IceUtil::Monitor<IceUtil::Mutex>
+ public IceUtil::Monitor<IceUtil::Mutex>
{
public:
void validate();
enum DestructionReason
{
- ObjectAdapterDeactivated,
- CommunicatorDestroyed
+ ObjectAdapterDeactivated,
+ CommunicatorDestroyed
};
void activate();
void hold();
@@ -103,18 +103,18 @@ public:
private:
ConnectionI(const IceInternal::InstancePtr&, const IceInternal::TransceiverPtr&,
- const IceInternal::EndpointIPtr&, const ObjectAdapterPtr&, bool, size_t);
+ const IceInternal::EndpointIPtr&, const ObjectAdapterPtr&, bool, size_t);
virtual ~ConnectionI();
friend class IceInternal::IncomingConnectionFactory;
friend class IceInternal::OutgoingConnectionFactory;
enum State
{
- StateNotValidated,
- StateActive,
- StateHolding,
- StateClosing,
- StateClosed
+ StateNotValidated,
+ StateActive,
+ StateHolding,
+ StateClosing,
+ StateClosed
};
void resetBatch(bool);
@@ -132,22 +132,22 @@ private:
void doUncompress(IceInternal::BasicStream&, IceInternal::BasicStream&);
void parseMessage(IceInternal::BasicStream&, Int&, Int&, Byte&,
- IceInternal::ServantManagerPtr&, ObjectAdapterPtr&, IceInternal::OutgoingAsyncPtr&);
+ IceInternal::ServantManagerPtr&, ObjectAdapterPtr&, IceInternal::OutgoingAsyncPtr&);
void invokeAll(IceInternal::BasicStream&, Int, Int, Byte,
- const IceInternal::ServantManagerPtr&, const ObjectAdapterPtr&);
+ const IceInternal::ServantManagerPtr&, const ObjectAdapterPtr&);
void run(); // For thread per connection.
class ThreadPerConnection : public IceUtil::Thread
{
public:
-
- ThreadPerConnection(const ConnectionIPtr&);
- virtual void run();
+
+ ThreadPerConnection(const ConnectionIPtr&);
+ virtual void run();
private:
-
- ConnectionIPtr _connection;
+
+ ConnectionIPtr _connection;
};
friend class ThreadPerConnection;
// Defined as mutable because "isFinished() const" sets this to 0.
@@ -183,8 +183,8 @@ private:
struct AsyncRequest
{
- IceInternal::OutgoingAsyncPtr p;
- IceUtil::Time t;
+ IceInternal::OutgoingAsyncPtr p;
+ IceUtil::Time t;
};
std::map<Int, AsyncRequest> _asyncRequests;
std::map<Int, AsyncRequest>::iterator _asyncRequestsHint;
diff --git a/cpp/src/Ice/ConnectionMonitor.cpp b/cpp/src/Ice/ConnectionMonitor.cpp
index d67962fb9e9..3c9eee7845a 100644
--- a/cpp/src/Ice/ConnectionMonitor.cpp
+++ b/cpp/src/Ice/ConnectionMonitor.cpp
@@ -24,13 +24,13 @@ void
IceInternal::ConnectionMonitor::destroy()
{
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- assert(_instance);
- _instance = 0;
- _connections.clear();
-
- notify();
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ assert(_instance);
+ _instance = 0;
+ _connections.clear();
+
+ notify();
}
getThreadControl().join();
@@ -71,53 +71,53 @@ IceInternal::ConnectionMonitor::run()
{
while(true)
{
- set<ConnectionIPtr> connections;
-
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- if(_instance && !timedWait(_interval))
- {
- connections = _connections;
- }
+ set<ConnectionIPtr> connections;
+
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ if(_instance && !timedWait(_interval))
+ {
+ connections = _connections;
+ }
- if(!_instance)
- {
- return;
- }
- }
-
- //
- // Monitor connections outside the thread synchronization, so
- // that connections can be added or removed during monitoring.
- //
- for(set<ConnectionIPtr>::const_iterator p = connections.begin(); p != connections.end(); ++p)
- {
- try
- {
- (*p)->monitor();
- }
- catch(const Exception& ex)
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- if(!_instance)
- {
- return;
- }
+ if(!_instance)
+ {
+ return;
+ }
+ }
+
+ //
+ // Monitor connections outside the thread synchronization, so
+ // that connections can be added or removed during monitoring.
+ //
+ for(set<ConnectionIPtr>::const_iterator p = connections.begin(); p != connections.end(); ++p)
+ {
+ try
+ {
+ (*p)->monitor();
+ }
+ catch(const Exception& ex)
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ if(!_instance)
+ {
+ return;
+ }
- Error out(_instance->initializationData().logger);
- out << "exception in connection monitor:\n" << ex;
- }
- catch(...)
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- if(!_instance)
- {
- return;
- }
+ Error out(_instance->initializationData().logger);
+ out << "exception in connection monitor:\n" << ex;
+ }
+ catch(...)
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ if(!_instance)
+ {
+ return;
+ }
- Error out(_instance->initializationData().logger);
- out << "unknown exception in connection monitor";
- }
- }
+ Error out(_instance->initializationData().logger);
+ out << "unknown exception in connection monitor";
+ }
+ }
}
}
diff --git a/cpp/src/Ice/DLLMain.cpp b/cpp/src/Ice/DLLMain.cpp
index 55f94abae45..dab9d417bb4 100755
--- a/cpp/src/Ice/DLLMain.cpp
+++ b/cpp/src/Ice/DLLMain.cpp
@@ -34,7 +34,7 @@ ice_DLL_Main(HINSTANCE hDLL, DWORD reason, LPVOID reserved)
}
else if(reason == DLL_THREAD_DETACH)
{
- Ice::ImplicitContextI::cleanupThread();
+ Ice::ImplicitContextI::cleanupThread();
}
return TRUE;
diff --git a/cpp/src/Ice/DefaultsAndOverrides.cpp b/cpp/src/Ice/DefaultsAndOverrides.cpp
index 04f5508d903..64bcd99b63b 100644
--- a/cpp/src/Ice/DefaultsAndOverrides.cpp
+++ b/cpp/src/Ice/DefaultsAndOverrides.cpp
@@ -38,33 +38,33 @@ IceInternal::DefaultsAndOverrides::DefaultsAndOverrides(const PropertiesPtr& pro
value = properties->getProperty("Ice.Override.Timeout");
if(!value.empty())
{
- const_cast<bool&>(overrideTimeout) = true;
- const_cast<Int&>(overrideTimeoutValue) = properties->getPropertyAsInt("Ice.Override.Timeout");
+ const_cast<bool&>(overrideTimeout) = true;
+ const_cast<Int&>(overrideTimeoutValue) = properties->getPropertyAsInt("Ice.Override.Timeout");
}
value = properties->getProperty("Ice.Override.ConnectTimeout");
if(!value.empty())
{
- const_cast<bool&>(overrideConnectTimeout) = true;
- const_cast<Int&>(overrideConnectTimeoutValue) = properties->getPropertyAsInt("Ice.Override.ConnectTimeout");
+ const_cast<bool&>(overrideConnectTimeout) = true;
+ const_cast<Int&>(overrideConnectTimeoutValue) = properties->getPropertyAsInt("Ice.Override.ConnectTimeout");
}
value = properties->getProperty("Ice.Override.Compress");
if(!value.empty())
{
- const_cast<bool&>(overrideCompress) = true;
- const_cast<bool&>(overrideCompressValue) = properties->getPropertyAsInt("Ice.Override.Compress");
+ const_cast<bool&>(overrideCompress) = true;
+ const_cast<bool&>(overrideCompressValue) = properties->getPropertyAsInt("Ice.Override.Compress");
}
value = properties->getProperty("Ice.Override.Secure");
if(!value.empty())
{
- const_cast<bool&>(overrideSecure) = true;
- const_cast<bool&>(overrideSecureValue) = properties->getPropertyAsInt("Ice.Override.Secure");
+ const_cast<bool&>(overrideSecure) = true;
+ const_cast<bool&>(overrideSecureValue) = properties->getPropertyAsInt("Ice.Override.Secure");
}
const_cast<bool&>(defaultCollocationOptimization) =
- properties->getPropertyAsIntWithDefault("Ice.Default.CollocationOptimization", 1) > 0;
+ properties->getPropertyAsIntWithDefault("Ice.Default.CollocationOptimization", 1) > 0;
value = properties->getPropertyWithDefault("Ice.Default.EndpointSelection", "Random");
if(value == "Random")
@@ -83,8 +83,8 @@ IceInternal::DefaultsAndOverrides::DefaultsAndOverrides(const PropertiesPtr& pro
}
const_cast<int&>(defaultLocatorCacheTimeout) =
- properties->getPropertyAsIntWithDefault("Ice.Default.LocatorCacheTimeout", -1);
+ properties->getPropertyAsIntWithDefault("Ice.Default.LocatorCacheTimeout", -1);
const_cast<bool&>(defaultPreferSecure) =
- properties->getPropertyAsIntWithDefault("Ice.Default.PreferSecure", 0) > 0;
+ properties->getPropertyAsIntWithDefault("Ice.Default.PreferSecure", 0) > 0;
}
diff --git a/cpp/src/Ice/Direct.cpp b/cpp/src/Ice/Direct.cpp
index d27825ab907..b25c85fb9e1 100644
--- a/cpp/src/Ice/Direct.cpp
+++ b/cpp/src/Ice/Direct.cpp
@@ -39,55 +39,55 @@ IceInternal::Direct::Direct(const Current& current) :
try
{
- _servant = servantManager->findServant(_current.id, _current.facet);
- if(!_servant)
- {
- _locator = servantManager->findServantLocator(_current.id.category);
- if(!_locator && !_current.id.category.empty())
- {
- _locator = servantManager->findServantLocator("");
- }
- if(_locator)
- {
- _servant = _locator->locate(_current, _cookie);
- }
- }
- if(!_servant)
- {
- if(servantManager && servantManager->hasServant(_current.id))
- {
- FacetNotExistException ex(__FILE__, __LINE__);
- ex.id = _current.id;
- ex.facet = _current.facet;
- ex.operation = _current.operation;
- throw ex;
- }
- else
- {
- ObjectNotExistException ex(__FILE__, __LINE__);
- ex.id = _current.id;
- ex.facet = _current.facet;
- ex.operation = _current.operation;
- throw ex;
- }
- }
+ _servant = servantManager->findServant(_current.id, _current.facet);
+ if(!_servant)
+ {
+ _locator = servantManager->findServantLocator(_current.id.category);
+ if(!_locator && !_current.id.category.empty())
+ {
+ _locator = servantManager->findServantLocator("");
+ }
+ if(_locator)
+ {
+ _servant = _locator->locate(_current, _cookie);
+ }
+ }
+ if(!_servant)
+ {
+ if(servantManager && servantManager->hasServant(_current.id))
+ {
+ FacetNotExistException ex(__FILE__, __LINE__);
+ ex.id = _current.id;
+ ex.facet = _current.facet;
+ ex.operation = _current.operation;
+ throw ex;
+ }
+ else
+ {
+ ObjectNotExistException ex(__FILE__, __LINE__);
+ ex.id = _current.id;
+ ex.facet = _current.facet;
+ ex.operation = _current.operation;
+ throw ex;
+ }
+ }
}
catch(...)
{
- if(_locator && _servant)
- {
- try
- {
- _locator->finished(_current, _servant, _cookie);
- }
- catch(...)
- {
- adapter->decDirectCount();
- throw;
- }
- }
- adapter->decDirectCount();
- throw;
+ if(_locator && _servant)
+ {
+ try
+ {
+ _locator->finished(_current, _servant, _cookie);
+ }
+ catch(...)
+ {
+ adapter->decDirectCount();
+ throw;
+ }
+ }
+ adapter->decDirectCount();
+ throw;
}
}
@@ -104,15 +104,15 @@ IceInternal::Direct::destroy()
if(_locator && _servant)
{
- try
- {
- _locator->finished(_current, _servant, _cookie);
- }
- catch(...)
- {
- adapter->decDirectCount();
- throw;
- }
+ try
+ {
+ _locator->finished(_current, _servant, _cookie);
+ }
+ catch(...)
+ {
+ adapter->decDirectCount();
+ throw;
+ }
}
adapter->decDirectCount();
diff --git a/cpp/src/Ice/DynamicLibrary.cpp b/cpp/src/Ice/DynamicLibrary.cpp
index d1b25c1a46c..769b0368b19 100644
--- a/cpp/src/Ice/DynamicLibrary.cpp
+++ b/cpp/src/Ice/DynamicLibrary.cpp
@@ -66,21 +66,21 @@ IceInternal::DynamicLibrary::loadEntryPoint(const string& entryPoint, bool useIc
libName = libSpec;
if(useIceVersion)
{
- int majorVersion = (ICE_INT_VERSION / 10000);
- int minorVersion = (ICE_INT_VERSION / 100) - majorVersion * 100;
- ostringstream os;
- os << majorVersion * 10 + minorVersion;
+ int majorVersion = (ICE_INT_VERSION / 10000);
+ int minorVersion = (ICE_INT_VERSION / 100) - majorVersion * 100;
+ ostringstream os;
+ os << majorVersion * 10 + minorVersion;
- int patchVersion = ICE_INT_VERSION % 100;
- if(patchVersion > 50)
- {
- os << 'b';
- if(patchVersion >= 52)
- {
- os << (patchVersion - 50);
- }
- }
- version = os.str();
+ int patchVersion = ICE_INT_VERSION % 100;
+ if(patchVersion > 50)
+ {
+ os << 'b';
+ if(patchVersion >= 52)
+ {
+ os << (patchVersion - 50);
+ }
+ }
+ version = os.str();
}
}
else
@@ -101,7 +101,7 @@ IceInternal::DynamicLibrary::loadEntryPoint(const string& entryPoint, bool useIc
lib = "lib" + libName;
if(!version.empty())
{
- lib += "." + version;
+ lib += "." + version;
}
lib += ".dylib";
#elif defined(__hpux)
@@ -112,7 +112,7 @@ IceInternal::DynamicLibrary::loadEntryPoint(const string& entryPoint, bool useIc
}
else
{
- lib += ".sl";
+ lib += ".sl";
}
#elif defined(_AIX)
lib = "lib" + libName + ".a(lib" + libName + ".so";
diff --git a/cpp/src/Ice/EndpointFactoryManager.cpp b/cpp/src/Ice/EndpointFactoryManager.cpp
index bb8a784e9ab..25db4169e20 100644
--- a/cpp/src/Ice/EndpointFactoryManager.cpp
+++ b/cpp/src/Ice/EndpointFactoryManager.cpp
@@ -75,8 +75,8 @@ IceInternal::EndpointFactoryManager::create(const string& str) const
if(beg == string::npos)
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
+ ex.str = str;
+ throw ex;
}
string::size_type end = str.find_first_of(delim, beg);
diff --git a/cpp/src/Ice/EventLoggerI.cpp b/cpp/src/Ice/EventLoggerI.cpp
index a61325f1463..c626e62c83f 100755
--- a/cpp/src/Ice/EventLoggerI.cpp
+++ b/cpp/src/Ice/EventLoggerI.cpp
@@ -70,7 +70,7 @@ Ice::EventLoggerI::EventLoggerI(const string& appName) :
// "EventMessageFile" key should contain the path to this DLL.
//
err = RegSetValueEx(hKey, "EventMessageFile", 0, REG_EXPAND_SZ,
- (unsigned char*)path, static_cast<DWORD>(strlen(path) + 1));
+ (unsigned char*)path, static_cast<DWORD>(strlen(path) + 1));
if(err != ERROR_SUCCESS)
{
RegCloseKey(hKey);
diff --git a/cpp/src/Ice/Exception.cpp b/cpp/src/Ice/Exception.cpp
index d43712b6658..3141a604d3e 100644
--- a/cpp/src/Ice/Exception.cpp
+++ b/cpp/src/Ice/Exception.cpp
@@ -56,7 +56,7 @@ Ice::InitializationException::ice_print(ostream& out) const
out << ":\ninitialization exception";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -67,7 +67,7 @@ Ice::UnknownException::ice_print(ostream& out) const
out << ":\nunknown exception";
if(!unknown.empty())
{
- out << ":\n" << unknown;
+ out << ":\n" << unknown;
}
}
@@ -78,7 +78,7 @@ Ice::UnknownLocalException::ice_print(ostream& out) const
out << ":\nunknown local exception";
if(!unknown.empty())
{
- out << ":\n" << unknown;
+ out << ":\n" << unknown;
}
}
@@ -89,7 +89,7 @@ Ice::UnknownUserException::ice_print(ostream& out) const
out << ":\nunknown user exception";
if(!unknown.empty())
{
- out << ":\n" << unknown;
+ out << ":\n" << unknown;
}
}
@@ -238,11 +238,11 @@ Ice::SocketException::ice_print(ostream& out) const
out << ":\nsocket exception: ";
if(error == 0)
{
- out << "unknown error";
+ out << "unknown error";
}
else
{
- out << errorToString(error);
+ out << errorToString(error);
}
}
@@ -253,7 +253,7 @@ Ice::FileException::ice_print(ostream& out) const
out << ":\nfile exception: " << errorToString(error);
if(!path.empty())
{
- out << "\npath: " << path;
+ out << "\npath: " << path;
}
}
@@ -278,11 +278,11 @@ Ice::ConnectionLostException::ice_print(ostream& out) const
out << ":\nconnection lost: ";
if(error == 0)
{
- out << "recv() returned zero";
+ out << "recv() returned zero";
}
else
{
- out << errorToString(error);
+ out << errorToString(error);
}
}
@@ -328,7 +328,7 @@ Ice::ProtocolException::ice_print(ostream& out) const
out << ":\nprotocol exception";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -338,23 +338,23 @@ Ice::BadMagicException::ice_print(ostream& out) const
Exception::ice_print(out);
out << ":\nunknown magic number: ";
- ios_base::fmtflags originalFlags = out.flags(); // Save stream state
+ ios_base::fmtflags originalFlags = out.flags(); // Save stream state
ostream::char_type originalFill = out.fill();
- out.flags(ios_base::hex); // Change to hex
- out.fill('0'); // Fill with leading zeros
+ out.flags(ios_base::hex); // Change to hex
+ out.fill('0'); // Fill with leading zeros
out << "0x" << setw(2) << static_cast<unsigned int>(static_cast<unsigned char>(badMagic[0])) << ", ";
out << "0x" << setw(2) << static_cast<unsigned int>(static_cast<unsigned char>(badMagic[1])) << ", ";
out << "0x" << setw(2) << static_cast<unsigned int>(static_cast<unsigned char>(badMagic[2])) << ", ";
out << "0x" << setw(2) << static_cast<unsigned int>(static_cast<unsigned char>(badMagic[3]));
- out.fill(originalFill); // Restore stream state
+ out.fill(originalFill); // Restore stream state
out.flags(originalFlags);
if(!reason.empty())
{
- out << "\n" << reason;
+ out << "\n" << reason;
}
}
@@ -374,7 +374,7 @@ Ice::UnsupportedEncodingException::ice_print(ostream& out) const
out << "\n(can only support encodings compatible with version " << major << "." << major << ")";
if(!reason.empty())
{
- out << "\n" << reason;
+ out << "\n" << reason;
}
}
@@ -385,7 +385,7 @@ Ice::UnknownMessageException::ice_print(ostream& out) const
out << ":\nprotocol error: unknown message type";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -396,7 +396,7 @@ Ice::ConnectionNotValidatedException::ice_print(ostream& out) const
out << ":\nprotocol error: received message over unvalidated connection";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -407,7 +407,7 @@ Ice::UnknownRequestIdException::ice_print(ostream& out) const
out << ":\nprotocol error: unknown request id";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -418,7 +418,7 @@ Ice::UnknownReplyStatusException::ice_print(ostream& out) const
out << ":\nprotocol error: unknown reply status";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -429,7 +429,7 @@ Ice::CloseConnectionException::ice_print(ostream& out) const
out << ":\nprotocol error: connection closed";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -440,7 +440,7 @@ Ice::ForcedCloseConnectionException::ice_print(ostream& out) const
out << ":\nprotocol error: connection forcefully closed";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -451,7 +451,7 @@ Ice::IllegalMessageSizeException::ice_print(ostream& out) const
out << ":\nprotocol error: illegal message size";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -462,7 +462,7 @@ Ice::CompressionException::ice_print(ostream& out) const
out << ":\nprotocol error: failed to compress or uncompress data";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -473,7 +473,7 @@ Ice::DatagramLimitException::ice_print(ostream& out) const
out << ":\nprotocol error: maximum datagram payload size exceeded";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -484,7 +484,7 @@ Ice::MarshalException::ice_print(ostream& out) const
out << ":\nprotocol error: error during marshaling or unmarshaling";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -495,7 +495,7 @@ Ice::ProxyUnmarshalException::ice_print(ostream& out) const
out << ":\nprotocol error: inconsistent proxy data during unmarshaling";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -506,7 +506,7 @@ Ice::UnmarshalOutOfBoundsException::ice_print(ostream& out) const
out << ":\nprotocol error: out of bounds during unmarshaling";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -517,7 +517,7 @@ Ice::IllegalIndirectionException::ice_print(ostream& out) const
out << ":\nprotocol error: encountered illegal protocol indirection";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -528,21 +528,21 @@ Ice::NoObjectFactoryException::ice_print(ostream& out) const
out << ":\nprotocol error: no suitable object factory found for `" << type << "'";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
-}
+}
void
Ice::UnexpectedObjectException::ice_print(ostream& out) const
{
Exception::ice_print(out);
out << ":\nunexpected class instance of type `" << type <<
- "'; expected instance of type `" << expectedType << "'";
+ "'; expected instance of type `" << expectedType << "'";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
-}
+}
void
Ice::MemoryLimitException::ice_print(ostream& out) const
@@ -551,7 +551,7 @@ Ice::MemoryLimitException::ice_print(ostream& out) const
out << ":\nprotocol error: memory limit exceeded";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -562,7 +562,7 @@ Ice::StringConversionException::ice_print(ostream& out) const
out << ":\nprotocol error: string conversion failed";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -573,7 +573,7 @@ Ice::EncapsulationException::ice_print(ostream& out) const
out << ":\nprotocol error: illegal encapsulation";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -584,7 +584,7 @@ Ice::NegativeSizeException::ice_print(ostream& out) const
out << ":\nprotocol error: negative size for sequence, dictionary, etc.";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -656,7 +656,7 @@ Ice::SecurityException::ice_print(ostream& out) const
out << ":\nsecurity exception";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
diff --git a/cpp/src/Ice/FactoryTableDef.cpp b/cpp/src/Ice/FactoryTableDef.cpp
index e31a7fd0a7e..9241c8da8d6 100644
--- a/cpp/src/Ice/FactoryTableDef.cpp
+++ b/cpp/src/Ice/FactoryTableDef.cpp
@@ -17,11 +17,11 @@
namespace IceInternal
{
-FactoryTableWrapper factoryTableWrapper; // Single global instance of the wrapper object that
- // initializes factoryTable.
+FactoryTableWrapper factoryTableWrapper; // Single global instance of the wrapper object that
+ // initializes factoryTable.
-ICE_API FactoryTableDef* factoryTable; // Single global instance of the factory table for
- // non-local exceptions and non-abstract classes
+ICE_API FactoryTableDef* factoryTable; // Single global instance of the factory table for
+ // non-local exceptions and non-abstract classes
}
//
@@ -35,11 +35,11 @@ IceInternal::FactoryTableDef::addExceptionFactory(const std::string& t, const Ic
EFTable::iterator i = _eft.find(t);
if(i == _eft.end())
{
- _eft[t] = EFPair(f, 1);
+ _eft[t] = EFPair(f, 1);
}
else
{
- i->second.second++;
+ i->second.second++;
}
}
@@ -54,23 +54,23 @@ IceInternal::FactoryTableDef::getExceptionFactory(const std::string& t) const
#ifdef __APPLE__
if(i == _eft.end())
{
- lock.release();
-
- //
- // Try to find the symbol, if found this should trigger the
- // object static constructors to be called.
- //
- std::string symbol = "__F";
- for(std::string::const_iterator p = t.begin(); p != t.end(); ++p)
- {
- symbol += ((*p) == ':') ? '_' : *p;
- }
- symbol += "__initializer";
- dlsym(RTLD_DEFAULT, symbol.c_str());
-
- lock.acquire();
-
- i = _eft.find(t);
+ lock.release();
+
+ //
+ // Try to find the symbol, if found this should trigger the
+ // object static constructors to be called.
+ //
+ std::string symbol = "__F";
+ for(std::string::const_iterator p = t.begin(); p != t.end(); ++p)
+ {
+ symbol += ((*p) == ':') ? '_' : *p;
+ }
+ symbol += "__initializer";
+ dlsym(RTLD_DEFAULT, symbol.c_str());
+
+ lock.acquire();
+
+ i = _eft.find(t);
}
#endif
return i != _eft.end() ? i->second.first : IceInternal::UserExceptionFactoryPtr();
@@ -89,10 +89,10 @@ IceInternal::FactoryTableDef::removeExceptionFactory(const std::string& t)
EFTable::iterator i = _eft.find(t);
if(i != _eft.end())
{
- if(--i->second.second == 0)
- {
- _eft.erase(i);
- }
+ if(--i->second.second == 0)
+ {
+ _eft.erase(i);
+ }
}
}
@@ -106,11 +106,11 @@ IceInternal::FactoryTableDef::addObjectFactory(const std::string& t, const Ice::
OFTable::iterator i = _oft.find(t);
if(i == _oft.end())
{
- _oft[t] = OFPair(f, 1);
+ _oft[t] = OFPair(f, 1);
}
else
{
- i->second.second++;
+ i->second.second++;
}
}
@@ -125,23 +125,23 @@ IceInternal::FactoryTableDef::getObjectFactory(const std::string& t) const
#ifdef __APPLE__
if(i == _oft.end())
{
- lock.release();
-
- //
- // Try to find the symbol, if found this should trigger the
- // object static constructors to be called.
- //
- std::string symbol = "__F";
- for(std::string::const_iterator p = t.begin(); p != t.end(); ++p)
- {
- symbol += ((*p) == ':') ? '_' : *p;
- }
- symbol += "__initializer";
- dlsym(RTLD_DEFAULT, symbol.c_str());
-
- lock.acquire();
-
- i = _oft.find(t);
+ lock.release();
+
+ //
+ // Try to find the symbol, if found this should trigger the
+ // object static constructors to be called.
+ //
+ std::string symbol = "__F";
+ for(std::string::const_iterator p = t.begin(); p != t.end(); ++p)
+ {
+ symbol += ((*p) == ':') ? '_' : *p;
+ }
+ symbol += "__initializer";
+ dlsym(RTLD_DEFAULT, symbol.c_str());
+
+ lock.acquire();
+
+ i = _oft.find(t);
}
#endif
return i != _oft.end() ? i->second.first : Ice::ObjectFactoryPtr();
@@ -160,10 +160,10 @@ IceInternal::FactoryTableDef::removeObjectFactory(const std::string& t)
OFTable::iterator i = _oft.find(t);
if(i != _oft.end())
{
- if(--i->second.second == 0)
- {
- _oft.erase(i);
- }
+ if(--i->second.second == 0)
+ {
+ _oft.erase(i);
+ }
}
}
@@ -193,7 +193,7 @@ IceInternal::FactoryTableWrapper::initialize()
IceUtil::StaticMutex::Lock lock(_m);
if(_initCount == 0)
{
- factoryTable = new FactoryTableDef;
+ factoryTable = new FactoryTableDef;
}
++_initCount;
}
@@ -207,9 +207,9 @@ IceInternal::FactoryTableWrapper::finalize()
IceUtil::StaticMutex::Lock lock(_m);
if(--_initCount == 0)
{
- delete factoryTable;
+ delete factoryTable;
}
}
IceUtil::StaticMutex IceInternal::FactoryTableWrapper::_m = ICE_STATIC_MUTEX_INITIALIZER;
-int IceInternal::FactoryTableWrapper::_initCount = 0; // Initialization count
+int IceInternal::FactoryTableWrapper::_initCount = 0; // Initialization count
diff --git a/cpp/src/Ice/GC.cpp b/cpp/src/Ice/GC.cpp
index 432a34a7469..605997439a5 100755
--- a/cpp/src/Ice/GC.cpp
+++ b/cpp/src/Ice/GC.cpp
@@ -35,14 +35,14 @@ recursivelyReachable(GCShared* p, GCObjectSet& o)
{
if(o.find(p) == o.end())
{
- assert(p);
- o.insert(p);
- GCCountMap tmp;
- p->__gcReachable(tmp);
- for(GCCountMap::const_iterator i = tmp.begin(); i != tmp.end(); ++i)
- {
- recursivelyReachable(i->first, o);
- }
+ assert(p);
+ o.insert(p);
+ GCCountMap tmp;
+ p->__gcReachable(tmp);
+ for(GCCountMap::const_iterator i = tmp.begin(); i != tmp.end(); ++i)
+ {
+ recursivelyReachable(i->first, o);
+ }
}
}
@@ -82,13 +82,13 @@ IceInternal::GCShared::__decRef()
assert(_ref > 0);
if(--_ref == 0)
{
- doDelete = !_noDelete;
- _noDelete = true;
+ doDelete = !_noDelete;
+ _noDelete = true;
}
lock.release();
if(doDelete)
{
- delete this;
+ delete this;
}
}
@@ -114,10 +114,10 @@ IceInternal::GCShared::__gcIncRef()
if(_ref == 0)
{
#ifdef NDEBUG // To avoid annoying warnings about variables that are not used...
- gcObjects.insert(this);
+ gcObjects.insert(this);
#else
- std::pair<GCObjectSet::iterator, bool> rc = gcObjects.insert(this);
- assert(rc.second);
+ std::pair<GCObjectSet::iterator, bool> rc = gcObjects.insert(this);
+ assert(rc.second);
#endif
}
++_ref;
@@ -131,19 +131,19 @@ IceInternal::GCShared::__gcDecRef()
assert(_ref > 0);
if(--_ref == 0)
{
- doDelete = !_noDelete;
- _noDelete = true;
+ doDelete = !_noDelete;
+ _noDelete = true;
#ifdef NDEBUG // To avoid annoying warnings about variables that are not used...
- gcObjects.erase(this);
+ gcObjects.erase(this);
#else
- GCObjectSet::size_type num = gcObjects.erase(this);
- assert(num == 1);
+ GCObjectSet::size_type num = gcObjects.erase(this);
+ assert(num == 1);
#endif
}
lock.release();
if(doDelete)
{
- delete this;
+ delete this;
}
}
@@ -158,7 +158,7 @@ IceInternal::GC::GC(int interval, StatsCallback cb)
StaticMutex::Lock sync(numCollectorsMutex);
if(numCollectors++ > 0)
{
- abort(); // Enforce singleton.
+ abort(); // Enforce singleton.
}
_state = NotStarted;
@@ -179,33 +179,33 @@ IceInternal::GC::run()
assert(_interval > 0);
{
- Monitor<Mutex>::Lock sync(*this);
+ Monitor<Mutex>::Lock sync(*this);
- _state = Started;
- notify();
+ _state = Started;
+ notify();
}
Time waitTime = Time::seconds(_interval);
while(true)
{
- bool collect = false;
- {
- Monitor<Mutex>::Lock sync(*this);
-
- if(_state == Stopping)
- {
- _state = Stopped;
- return;
- }
- if(!timedWait(waitTime))
- {
- collect = true;
- }
- }
- if(collect)
- {
- collectGarbage();
- }
+ bool collect = false;
+ {
+ Monitor<Mutex>::Lock sync(*this);
+
+ if(_state == Stopping)
+ {
+ _state = Stopped;
+ return;
+ }
+ if(!timedWait(waitTime))
+ {
+ collect = true;
+ }
+ }
+ if(collect)
+ {
+ collectGarbage();
+ }
}
}
@@ -213,32 +213,32 @@ void
IceInternal::GC::stop()
{
{
- Monitor<Mutex>::Lock sync(*this);
-
- if(_state >= Stopping)
- {
- return; // Don't attempt to stop the thread twice.
- }
-
- //
- // Wait until the thread is actually started. (If we don't do this, we
- // can get a problem if a call to stop() immediately follows a call to start():
- // the call to stop() may happen before pthread_create() has scheduled the thread's run()
- // function, and then the notify() that is used to tell the thread to stop can be lost.
- //
- while(_state < Started)
- {
- wait();
- }
+ Monitor<Mutex>::Lock sync(*this);
+
+ if(_state >= Stopping)
+ {
+ return; // Don't attempt to stop the thread twice.
+ }
+
+ //
+ // Wait until the thread is actually started. (If we don't do this, we
+ // can get a problem if a call to stop() immediately follows a call to start():
+ // the call to stop() may happen before pthread_create() has scheduled the thread's run()
+ // function, and then the notify() that is used to tell the thread to stop can be lost.
+ //
+ while(_state < Started)
+ {
+ wait();
+ }
}
//
// Tell the thread to stop.
//
{
- Monitor<Mutex>::Lock sync(*this);
- _state = Stopping;
- notify();
+ Monitor<Mutex>::Lock sync(*this);
+ _state = Stopping;
+ notify();
}
getThreadControl().join();
@@ -252,13 +252,13 @@ IceInternal::GC::collectGarbage()
// Do nothing if the collector is running already.
//
{
- Monitor<Mutex>::Lock sync(*this);
+ Monitor<Mutex>::Lock sync(*this);
- if(_collecting)
- {
- return;
- }
- _collecting = true;
+ if(_collecting)
+ {
+ return;
+ }
+ _collecting = true;
}
RecMutex::Lock sync(gcRecMutex); // Prevent any further class reference count activity.
@@ -268,108 +268,108 @@ IceInternal::GC::collectGarbage()
if(_statsCallback)
{
- t = Time::now();
- stats.examined = static_cast<int>(gcObjects.size());
+ t = Time::now();
+ stats.examined = static_cast<int>(gcObjects.size());
}
GCCountMap counts;
{
- //
- // gcObjects contains the set of class instances that have at least one member of class type,
- // that is, gcObjects contains all those instances that can point at other instances.
- //
- // Create a map that, for each object in gcObjects, contains an <object, refcount> pair.
- // In addition, for each object in gcObjects, add the objects that are immediately (not
- // recursively) reachable from that object to a reachable map that counts how many times
- // the object is pointed at.
- //
- GCCountMap reachable;
- {
- for(GCObjectSet::const_iterator i = gcObjects.begin(); i != gcObjects.end(); ++i)
- {
- counts.insert(GCCountMap::value_type(*i, (*i)->__getRefUnsafe()));
- (*i)->__gcReachable(reachable);
- }
- }
-
- //
- // Decrement the reference count for each object in the counts map by the count in the reachable
- // map. This drops the reference count of each object in the counts map by the number of times that
- // the object is pointed at by other objects in the counts map.
//
- {
- for(GCCountMap::const_iterator i = reachable.begin(); i != reachable.end(); ++i)
- {
- GCCountMap::iterator pos = counts.find(i->first);
- assert(pos != counts.end());
- pos->second -= i->second;
- }
- }
+ // gcObjects contains the set of class instances that have at least one member of class type,
+ // that is, gcObjects contains all those instances that can point at other instances.
+ //
+ // Create a map that, for each object in gcObjects, contains an <object, refcount> pair.
+ // In addition, for each object in gcObjects, add the objects that are immediately (not
+ // recursively) reachable from that object to a reachable map that counts how many times
+ // the object is pointed at.
+ //
+ GCCountMap reachable;
+ {
+ for(GCObjectSet::const_iterator i = gcObjects.begin(); i != gcObjects.end(); ++i)
+ {
+ counts.insert(GCCountMap::value_type(*i, (*i)->__getRefUnsafe()));
+ (*i)->__gcReachable(reachable);
+ }
+ }
+
+ //
+ // Decrement the reference count for each object in the counts map by the count in the reachable
+ // map. This drops the reference count of each object in the counts map by the number of times that
+ // the object is pointed at by other objects in the counts map.
+ //
+ {
+ for(GCCountMap::const_iterator i = reachable.begin(); i != reachable.end(); ++i)
+ {
+ GCCountMap::iterator pos = counts.find(i->first);
+ assert(pos != counts.end());
+ pos->second -= i->second;
+ }
+ }
}
{
- //
- // Any instances in the counts map with a ref count > 0 are referenced from outside the objects in
- // gcObjects (and are therefore reachable from the program, for example, via Ptr variable on the stack).
- // The set of live objects therefore are all the objects with a reference count > 0, as well as all
- // objects that are (recursively) reachable from these objects.
- //
- GCObjectSet liveObjects;
- {
- for(GCCountMap::const_iterator i = counts.begin(); i != counts.end(); ++i)
- {
- if(i->second > 0)
- {
- recursivelyReachable(i->first, liveObjects);
- }
- }
- }
-
- //
- // Remove all live objects from the counts map.
- //
- {
- for(GCObjectSet::const_iterator i = liveObjects.begin(); i != liveObjects.end(); ++i)
- {
+ //
+ // Any instances in the counts map with a ref count > 0 are referenced from outside the objects in
+ // gcObjects (and are therefore reachable from the program, for example, via Ptr variable on the stack).
+ // The set of live objects therefore are all the objects with a reference count > 0, as well as all
+ // objects that are (recursively) reachable from these objects.
+ //
+ GCObjectSet liveObjects;
+ {
+ for(GCCountMap::const_iterator i = counts.begin(); i != counts.end(); ++i)
+ {
+ if(i->second > 0)
+ {
+ recursivelyReachable(i->first, liveObjects);
+ }
+ }
+ }
+
+ //
+ // Remove all live objects from the counts map.
+ //
+ {
+ for(GCObjectSet::const_iterator i = liveObjects.begin(); i != liveObjects.end(); ++i)
+ {
#ifndef NDEBUG
- size_t erased =
+ size_t erased =
#endif
- counts.erase(*i);
- assert(erased != 0);
- }
- }
+ counts.erase(*i);
+ assert(erased != 0);
+ }
+ }
}
//
// What is left in the counts map can be garbage collected.
//
{
- GCCountMap::const_iterator i;
- for(i = counts.begin(); i != counts.end(); ++i)
- {
- //
- // For classes with members that point at potentially-cyclic instances, __gcClear()
- // decrements the reference count of the pointed-at instances as many times as they are
- // pointed at and clears the corresponding Ptr members in the pointing class.
- // For classes that cannot be part of a cycle (because they do not contain class members)
- // and are therefore true leaves, __gcClear() assigns 0 to the corresponding class member,
- // which either decrements the ref count or, if it reaches zero, deletes the instance as usual.
- //
- i->first->__gcClear();
- }
- for(i = counts.begin(); i != counts.end(); ++i)
- {
- gcObjects.erase(i->first); // Remove this object from candidate set.
- delete i->first; // Delete this object.
- }
+ GCCountMap::const_iterator i;
+ for(i = counts.begin(); i != counts.end(); ++i)
+ {
+ //
+ // For classes with members that point at potentially-cyclic instances, __gcClear()
+ // decrements the reference count of the pointed-at instances as many times as they are
+ // pointed at and clears the corresponding Ptr members in the pointing class.
+ // For classes that cannot be part of a cycle (because they do not contain class members)
+ // and are therefore true leaves, __gcClear() assigns 0 to the corresponding class member,
+ // which either decrements the ref count or, if it reaches zero, deletes the instance as usual.
+ //
+ i->first->__gcClear();
+ }
+ for(i = counts.begin(); i != counts.end(); ++i)
+ {
+ gcObjects.erase(i->first); // Remove this object from candidate set.
+ delete i->first; // Delete this object.
+ }
}
if(_statsCallback)
{
- stats.time = Time::now() - t;
- stats.collected = static_cast<int>(counts.size());
- _statsCallback(stats);
+ stats.time = Time::now() - t;
+ stats.collected = static_cast<int>(counts.size());
+ _statsCallback(stats);
}
//
@@ -381,8 +381,8 @@ IceInternal::GC::collectGarbage()
counts.clear();
{
- Monitor<Mutex>::Lock sync(*this);
+ Monitor<Mutex>::Lock sync(*this);
- _collecting = false;
+ _collecting = false;
}
}
diff --git a/cpp/src/Ice/IdentityUtil.cpp b/cpp/src/Ice/IdentityUtil.cpp
index 8b078b0e96c..4758804b4fb 100644
--- a/cpp/src/Ice/IdentityUtil.cpp
+++ b/cpp/src/Ice/IdentityUtil.cpp
@@ -81,10 +81,10 @@ Ice::identityToString(const Identity& ident)
{
if(ident.category.empty())
{
- return IceUtil::escapeString(ident.name, "/");
+ return IceUtil::escapeString(ident.name, "/");
}
else
{
- return IceUtil::escapeString(ident.category, "/") + '/' + IceUtil::escapeString(ident.name, "/");
+ return IceUtil::escapeString(ident.category, "/") + '/' + IceUtil::escapeString(ident.name, "/");
}
}
diff --git a/cpp/src/Ice/ImplicitContextI.cpp b/cpp/src/Ice/ImplicitContextI.cpp
index ab78a011dab..7dd27c0fada 100644
--- a/cpp/src/Ice/ImplicitContextI.cpp
+++ b/cpp/src/Ice/ImplicitContextI.cpp
@@ -80,14 +80,14 @@ public:
struct Slot
{
- Slot() :
- context(0),
- owner(-1) // just to avoid UMR; a random value would work as well
- {
- }
-
- Context* context;
- long owner;
+ Slot() :
+ context(0),
+ owner(-1) // just to avoid UMR; a random value would work as well
+ {
+ }
+
+ Context* context;
+ long owner;
};
@@ -129,25 +129,25 @@ ImplicitContextI::create(const std::string& kind)
{
if(kind == "None" || kind == "")
{
- return 0;
+ return 0;
}
else if(kind == "Shared")
{
- return new SharedImplicitContext;
+ return new SharedImplicitContext;
}
else if(kind == "SharedWithoutLocking")
{
- return new SharedImplicitContextWithoutLocking;
+ return new SharedImplicitContextWithoutLocking;
}
else if(kind == "PerThread")
{
- return new PerThreadImplicitContext;
+ return new PerThreadImplicitContext;
}
else
{
- throw Ice::InitializationException(
- __FILE__, __LINE__,
- "'" + kind + "' is not a valid value for Ice.ImplicitContext");
+ throw Ice::InitializationException(
+ __FILE__, __LINE__,
+ "'" + kind + "' is not a valid value for Ice.ImplicitContext");
return 0; // Keep the compiler happy.
}
}
@@ -158,8 +158,8 @@ ImplicitContextI::cleanupThread()
{
if(PerThreadImplicitContext::_nextId > 0)
{
- PerThreadImplicitContext::threadDestructor(
- TlsGetValue(PerThreadImplicitContext::_key));
+ PerThreadImplicitContext::threadDestructor(
+ TlsGetValue(PerThreadImplicitContext::_key));
}
}
#endif
@@ -186,7 +186,7 @@ SharedImplicitContextWithoutLocking::get(const string& k) const
Context::const_iterator p = _context.find(k);
if(p == _context.end())
{
- throw NotSetException(__FILE__, __LINE__, k);
+ throw NotSetException(__FILE__, __LINE__, k);
}
return p->second;
}
@@ -197,7 +197,7 @@ SharedImplicitContextWithoutLocking::getWithDefault(const string& k, const strin
Context::const_iterator p = _context.find(k);
if(p == _context.end())
{
- return d;
+ return d;
}
return p->second;
}
@@ -213,7 +213,7 @@ SharedImplicitContextWithoutLocking::remove(const string& k)
{
if(_context.erase(k) == 0)
{
- throw NotSetException(__FILE__, __LINE__, k);
+ throw NotSetException(__FILE__, __LINE__, k);
}
}
@@ -222,17 +222,17 @@ SharedImplicitContextWithoutLocking::write(const Context& proxyCtx, ::IceInterna
{
if(proxyCtx.size() == 0)
{
- __write(s, _context, __U__Context());
+ __write(s, _context, __U__Context());
}
else if(_context.size() == 0)
{
- __write(s, proxyCtx, __U__Context());
+ __write(s, proxyCtx, __U__Context());
}
else
{
- Context combined = proxyCtx;
- combined.insert(_context.begin(), _context.end());
- __write(s, combined, __U__Context());
+ Context combined = proxyCtx;
+ combined.insert(_context.begin(), _context.end());
+ __write(s, combined, __U__Context());
}
}
@@ -241,16 +241,16 @@ SharedImplicitContextWithoutLocking::combine(const Context& proxyCtx, Context& c
{
if(proxyCtx.size() == 0)
{
- ctx = _context;
+ ctx = _context;
}
else if(_context.size() == 0)
{
- ctx = proxyCtx;
+ ctx = proxyCtx;
}
else
{
- ctx = proxyCtx;
- ctx.insert(_context.begin(), _context.end());
+ ctx = proxyCtx;
+ ctx.insert(_context.begin(), _context.end());
}
}
@@ -307,19 +307,19 @@ SharedImplicitContext::write(const Context& proxyCtx, ::IceInternal::BasicStream
IceUtil::Mutex::Lock lock(_mutex);
if(proxyCtx.size() == 0)
{
- __write(s, _context, __U__Context());
+ __write(s, _context, __U__Context());
}
else if(_context.size() == 0)
{
- lock.release();
- __write(s, proxyCtx, __U__Context());
+ lock.release();
+ __write(s, proxyCtx, __U__Context());
}
else
{
- Context combined = proxyCtx;
- combined.insert(_context.begin(), _context.end());
- lock.release();
- __write(s, combined, __U__Context());
+ Context combined = proxyCtx;
+ combined.insert(_context.begin(), _context.end());
+ lock.release();
+ __write(s, combined, __U__Context());
}
}
@@ -350,22 +350,22 @@ PerThreadImplicitContext::PerThreadImplicitContext()
_id = _nextId++;
if(_id == 0)
{
- //
- // Initialize; note that we never dealloc this key (it would be
- // complex, and since it's a static variable, it's not really a leak)
- //
+ //
+ // Initialize; note that we never dealloc this key (it would be
+ // complex, and since it's a static variable, it's not really a leak)
+ //
#ifdef _WIN32
- _key = TlsAlloc();
- if(_key == TLS_OUT_OF_INDEXES)
- {
- throw IceUtil::ThreadSyscallException(__FILE__, __LINE__, GetLastError());
- }
+ _key = TlsAlloc();
+ if(_key == TLS_OUT_OF_INDEXES)
+ {
+ throw IceUtil::ThreadSyscallException(__FILE__, __LINE__, GetLastError());
+ }
#else
- int err = pthread_key_create(&_key, &threadDestructor);
- if(err != 0)
- {
- throw IceUtil::ThreadSyscallException(__FILE__, __LINE__, err);
- }
+ int err = pthread_key_create(&_key, &threadDestructor);
+ if(err != 0)
+ {
+ throw IceUtil::ThreadSyscallException(__FILE__, __LINE__, err);
+ }
#endif
}
@@ -374,17 +374,17 @@ PerThreadImplicitContext::PerThreadImplicitContext()
//
if(_indexInUse == 0)
{
- _indexInUse = new IndexInUse(1);
+ _indexInUse = new IndexInUse(1);
}
size_t i = 0;
while(i < _indexInUse->size() && (*_indexInUse)[i])
{
- i++;
+ i++;
}
if(i == _indexInUse->size())
{
- _indexInUse->resize(i + 1);
+ _indexInUse->resize(i + 1);
}
(*_indexInUse)[i] = true;
_index = i;
@@ -397,8 +397,8 @@ PerThreadImplicitContext::~PerThreadImplicitContext()
if(find(_indexInUse->begin(), _indexInUse->end(), true) == _indexInUse->end())
{
- delete _indexInUse;
- _indexInUse = 0;
+ delete _indexInUse;
+ _indexInUse = 0;
}
}
@@ -408,17 +408,17 @@ PerThreadImplicitContext::threadDestructor(void* v)
SlotVector* sv = static_cast<SlotVector*>(v);
if(sv != 0)
{
- //
- // Cleanup each slot
- //
- for(SlotVector::iterator p = sv->begin(); p != sv->end(); ++p)
- {
- delete p->context;
- }
- //
- // Then the vector
- //
- delete sv;
+ //
+ // Cleanup each slot
+ //
+ for(SlotVector::iterator p = sv->begin(); p != sv->end(); ++p)
+ {
+ delete p->context;
+ }
+ //
+ // Then the vector
+ //
+ delete sv;
}
}
@@ -432,65 +432,65 @@ PerThreadImplicitContext::getThreadContext(bool allocate) const
#endif
if(sv == 0)
{
- if(!allocate)
- {
- return 0;
- }
+ if(!allocate)
+ {
+ return 0;
+ }
- sv = new SlotVector(_index + 1);
+ sv = new SlotVector(_index + 1);
#ifdef _WIN32
- if(TlsSetValue(_key, sv) == 0)
- {
- throw IceUtil::ThreadSyscallException(__FILE__, __LINE__, GetLastError());
- }
+ if(TlsSetValue(_key, sv) == 0)
+ {
+ throw IceUtil::ThreadSyscallException(__FILE__, __LINE__, GetLastError());
+ }
#else
- if(int err = pthread_setspecific(_key, sv))
- {
- throw IceUtil::ThreadSyscallException(__FILE__, __LINE__, err);
- }
+ if(int err = pthread_setspecific(_key, sv))
+ {
+ throw IceUtil::ThreadSyscallException(__FILE__, __LINE__, err);
+ }
#endif
}
else
{
- if(sv->size() <= _index)
- {
- if(!allocate)
- {
- return 0;
- }
- else
- {
- sv->resize(_index + 1);
- }
- }
+ if(sv->size() <= _index)
+ {
+ if(!allocate)
+ {
+ return 0;
+ }
+ else
+ {
+ sv->resize(_index + 1);
+ }
+ }
}
Slot& slot = (*sv)[_index];
if(slot.context != 0)
{
- if(slot.owner != _id)
- {
- //
- // Reuse the slot from another (dead) communicator
- //
- slot.context->clear();
- slot.owner = _id;
- }
- //
- // else keep this slot.context
- //
+ if(slot.owner != _id)
+ {
+ //
+ // Reuse the slot from another (dead) communicator
+ //
+ slot.context->clear();
+ slot.owner = _id;
+ }
+ //
+ // else keep this slot.context
+ //
}
else
{
- if(allocate)
- {
- slot.context = new Context;
- slot.owner = _id;
- }
- //
- // else keep null slot.context
- //
+ if(allocate)
+ {
+ slot.context = new Context;
+ slot.owner = _id;
+ }
+ //
+ // else keep null slot.context
+ //
}
return slot.context;
}
@@ -505,33 +505,33 @@ PerThreadImplicitContext::clearThreadContext() const
#endif
if(sv != 0 && _index < sv->size())
{
- delete (*sv)[_index].context;
- (*sv)[_index].context = 0;
-
- int i = sv->size() - 1;
- while(i >= 0 && (*sv)[i].context == 0)
- {
- i--;
- }
- if(i < 0)
- {
- delete sv;
+ delete (*sv)[_index].context;
+ (*sv)[_index].context = 0;
+
+ int i = sv->size() - 1;
+ while(i >= 0 && (*sv)[i].context == 0)
+ {
+ i--;
+ }
+ if(i < 0)
+ {
+ delete sv;
#ifdef _WIN32
- if(TlsSetValue(_key, 0) == 0)
- {
- IceUtil::ThreadSyscallException(__FILE__, __LINE__, GetLastError());
- }
+ if(TlsSetValue(_key, 0) == 0)
+ {
+ IceUtil::ThreadSyscallException(__FILE__, __LINE__, GetLastError());
+ }
#else
- if(int err = pthread_setspecific(_key, 0))
- {
- throw IceUtil::ThreadSyscallException(__FILE__, __LINE__, err);
- }
+ if(int err = pthread_setspecific(_key, 0))
+ {
+ throw IceUtil::ThreadSyscallException(__FILE__, __LINE__, err);
+ }
#endif
- }
- else
- {
- sv->resize(i + 1);
- }
+ }
+ else
+ {
+ sv->resize(i + 1);
+ }
}
}
@@ -542,11 +542,11 @@ PerThreadImplicitContext::getContext() const
Context* ctx = getThreadContext(false);
if(ctx == 0)
{
- return Context();
+ return Context();
}
else
{
- return *ctx;
+ return *ctx;
}
}
@@ -555,13 +555,13 @@ PerThreadImplicitContext::setContext(const Context& newContext)
{
if(newContext.size() == 0)
{
- clearThreadContext();
+ clearThreadContext();
}
else
{
- Context* ctx = getThreadContext(true);
- assert(ctx != 0);
- *ctx = newContext;
+ Context* ctx = getThreadContext(true);
+ assert(ctx != 0);
+ *ctx = newContext;
}
}
@@ -571,12 +571,12 @@ PerThreadImplicitContext::get(const string& k) const
Context* ctx = getThreadContext(false);
if(ctx == 0)
{
- throw NotSetException(__FILE__, __LINE__, k);
+ throw NotSetException(__FILE__, __LINE__, k);
}
Context::const_iterator p = ctx->find(k);
if(p == ctx->end())
{
- throw NotSetException(__FILE__, __LINE__, k);
+ throw NotSetException(__FILE__, __LINE__, k);
}
return p->second;
}
@@ -587,12 +587,12 @@ PerThreadImplicitContext::getWithDefault(const string& k, const string& d) const
Context* ctx = getThreadContext(false);
if(ctx == 0)
{
- return d;
+ return d;
}
Context::const_iterator p = ctx->find(k);
if(p == ctx->end())
{
- return d;
+ return d;
}
return p->second;
}
@@ -610,12 +610,12 @@ PerThreadImplicitContext::remove(const string& k)
Context* ctx = getThreadContext(false);
if(ctx == 0 || ctx->erase(k) == 0)
{
- throw NotSetException(__FILE__, __LINE__, k);
+ throw NotSetException(__FILE__, __LINE__, k);
}
if(ctx->size() == 0)
{
- clearThreadContext();
+ clearThreadContext();
}
}
@@ -626,17 +626,17 @@ PerThreadImplicitContext::write(const Context& proxyCtx, ::IceInternal::BasicStr
if(threadCtx == 0 || threadCtx->size() == 0)
{
- __write(s, proxyCtx, __U__Context());
+ __write(s, proxyCtx, __U__Context());
}
else if(proxyCtx.size() == 0)
{
- __write(s, *threadCtx, __U__Context());
+ __write(s, *threadCtx, __U__Context());
}
else
{
- Context combined = proxyCtx;
- combined.insert(threadCtx->begin(), threadCtx->end());
- __write(s, combined, __U__Context());
+ Context combined = proxyCtx;
+ combined.insert(threadCtx->begin(), threadCtx->end());
+ __write(s, combined, __U__Context());
}
}
@@ -647,15 +647,15 @@ PerThreadImplicitContext::combine(const Context& proxyCtx, Context& ctx) const
if(threadCtx == 0 || threadCtx->size() == 0)
{
- ctx = proxyCtx;
+ ctx = proxyCtx;
}
else if(proxyCtx.size() == 0)
{
- ctx = *threadCtx;
+ ctx = *threadCtx;
}
else
{
- ctx = proxyCtx;
- ctx.insert(threadCtx->begin(), threadCtx->end());
+ ctx = proxyCtx;
+ ctx.insert(threadCtx->begin(), threadCtx->end());
}
}
diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp
index bd41e14fef1..22dbebf73e7 100644
--- a/cpp/src/Ice/Incoming.cpp
+++ b/cpp/src/Ice/Incoming.cpp
@@ -25,8 +25,8 @@ using namespace Ice;
using namespace IceInternal;
IceInternal::IncomingBase::IncomingBase(Instance* instance, ConnectionI* connection,
- const ObjectAdapterPtr& adapter,
- bool response, Byte compress, Int requestId) :
+ const ObjectAdapterPtr& adapter,
+ bool response, Byte compress, Int requestId) :
_response(response),
_compress(compress),
_os(instance),
@@ -74,199 +74,199 @@ IceInternal::IncomingBase::__handleException(const Ice::Exception& ex)
{
try
{
- ex.ice_throw();
+ ex.ice_throw();
}
catch(RequestFailedException& ex)
{
- if(ex.id.name.empty())
- {
- ex.id = _current.id;
- }
-
- if(ex.facet.empty() && !_current.facet.empty())
- {
- ex.facet = _current.facet;
- }
-
- if(ex.operation.empty() && !_current.operation.empty())
- {
- ex.operation = _current.operation;
- }
-
- if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 1)
- {
- __warning(ex);
- }
-
- if(_response)
- {
- _os.endWriteEncaps();
- _os.b.resize(headerSize + 4); // Dispatch status position.
- if(dynamic_cast<ObjectNotExistException*>(&ex))
- {
- _os.write(static_cast<Byte>(DispatchObjectNotExist));
- }
- else if(dynamic_cast<FacetNotExistException*>(&ex))
- {
- _os.write(static_cast<Byte>(DispatchFacetNotExist));
- }
- else if(dynamic_cast<OperationNotExistException*>(&ex))
- {
- _os.write(static_cast<Byte>(DispatchOperationNotExist));
- }
- else
- {
- assert(false);
- }
-
- ex.id.__write(&_os);
-
- //
- // For compatibility with the old FacetPath.
- //
- if(ex.facet.empty())
- {
- _os.write(static_cast<string*>(0), static_cast<string*>(0));
- }
- else
- {
- _os.write(&ex.facet, &ex.facet + 1);
- }
-
- _os.write(ex.operation, false);
-
- _connection->sendResponse(&_os, _compress);
- }
- else
- {
- _connection->sendNoResponse();
- }
+ if(ex.id.name.empty())
+ {
+ ex.id = _current.id;
+ }
+
+ if(ex.facet.empty() && !_current.facet.empty())
+ {
+ ex.facet = _current.facet;
+ }
+
+ if(ex.operation.empty() && !_current.operation.empty())
+ {
+ ex.operation = _current.operation;
+ }
+
+ if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 1)
+ {
+ __warning(ex);
+ }
+
+ if(_response)
+ {
+ _os.endWriteEncaps();
+ _os.b.resize(headerSize + 4); // Dispatch status position.
+ if(dynamic_cast<ObjectNotExistException*>(&ex))
+ {
+ _os.write(static_cast<Byte>(DispatchObjectNotExist));
+ }
+ else if(dynamic_cast<FacetNotExistException*>(&ex))
+ {
+ _os.write(static_cast<Byte>(DispatchFacetNotExist));
+ }
+ else if(dynamic_cast<OperationNotExistException*>(&ex))
+ {
+ _os.write(static_cast<Byte>(DispatchOperationNotExist));
+ }
+ else
+ {
+ assert(false);
+ }
+
+ ex.id.__write(&_os);
+
+ //
+ // For compatibility with the old FacetPath.
+ //
+ if(ex.facet.empty())
+ {
+ _os.write(static_cast<string*>(0), static_cast<string*>(0));
+ }
+ else
+ {
+ _os.write(&ex.facet, &ex.facet + 1);
+ }
+
+ _os.write(ex.operation, false);
+
+ _connection->sendResponse(&_os, _compress);
+ }
+ else
+ {
+ _connection->sendNoResponse();
+ }
}
catch(const UnknownLocalException& ex)
{
- if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
- {
- __warning(ex);
- }
-
- if(_response)
- {
- _os.endWriteEncaps();
- _os.b.resize(headerSize + 4); // Dispatch status position.
- _os.write(static_cast<Byte>(DispatchUnknownLocalException));
- _os.write(ex.unknown, false);
- _connection->sendResponse(&_os, _compress);
- }
- else
- {
- _connection->sendNoResponse();
- }
+ if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
+ {
+ __warning(ex);
+ }
+
+ if(_response)
+ {
+ _os.endWriteEncaps();
+ _os.b.resize(headerSize + 4); // Dispatch status position.
+ _os.write(static_cast<Byte>(DispatchUnknownLocalException));
+ _os.write(ex.unknown, false);
+ _connection->sendResponse(&_os, _compress);
+ }
+ else
+ {
+ _connection->sendNoResponse();
+ }
}
catch(const UnknownUserException& ex)
{
- if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
- {
- __warning(ex);
- }
-
- if(_response)
- {
- _os.endWriteEncaps();
- _os.b.resize(headerSize + 4); // Dispatch status position.
- _os.write(static_cast<Byte>(DispatchUnknownUserException));
- _os.write(ex.unknown, false);
- _connection->sendResponse(&_os, _compress);
- }
- else
- {
- _connection->sendNoResponse();
- }
+ if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
+ {
+ __warning(ex);
+ }
+
+ if(_response)
+ {
+ _os.endWriteEncaps();
+ _os.b.resize(headerSize + 4); // Dispatch status position.
+ _os.write(static_cast<Byte>(DispatchUnknownUserException));
+ _os.write(ex.unknown, false);
+ _connection->sendResponse(&_os, _compress);
+ }
+ else
+ {
+ _connection->sendNoResponse();
+ }
}
catch(const UnknownException& ex)
{
- if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
- {
- __warning(ex);
- }
-
- if(_response)
- {
- _os.endWriteEncaps();
- _os.b.resize(headerSize + 4); // Dispatch status position.
- _os.write(static_cast<Byte>(DispatchUnknownException));
- _os.write(ex.unknown, false);
- _connection->sendResponse(&_os, _compress);
- }
- else
- {
- _connection->sendNoResponse();
- }
+ if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
+ {
+ __warning(ex);
+ }
+
+ if(_response)
+ {
+ _os.endWriteEncaps();
+ _os.b.resize(headerSize + 4); // Dispatch status position.
+ _os.write(static_cast<Byte>(DispatchUnknownException));
+ _os.write(ex.unknown, false);
+ _connection->sendResponse(&_os, _compress);
+ }
+ else
+ {
+ _connection->sendNoResponse();
+ }
}
catch(const LocalException& ex)
{
- if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
- {
- __warning(ex);
- }
-
- if(_response)
- {
- _os.endWriteEncaps();
- _os.b.resize(headerSize + 4); // Dispatch status position.
- _os.write(static_cast<Byte>(DispatchUnknownLocalException));
- ostringstream str;
- str << ex;
- _os.write(str.str(), false);
- _connection->sendResponse(&_os, _compress);
- }
- else
- {
- _connection->sendNoResponse();
- }
+ if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
+ {
+ __warning(ex);
+ }
+
+ if(_response)
+ {
+ _os.endWriteEncaps();
+ _os.b.resize(headerSize + 4); // Dispatch status position.
+ _os.write(static_cast<Byte>(DispatchUnknownLocalException));
+ ostringstream str;
+ str << ex;
+ _os.write(str.str(), false);
+ _connection->sendResponse(&_os, _compress);
+ }
+ else
+ {
+ _connection->sendNoResponse();
+ }
}
catch(const UserException& ex)
{
- if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
- {
- __warning(ex);
- }
-
- if(_response)
- {
- _os.endWriteEncaps();
- _os.b.resize(headerSize + 4); // Dispatch status position.
- _os.write(static_cast<Byte>(DispatchUnknownUserException));
- ostringstream str;
- str << ex;
- _os.write(str.str(), false);
- _connection->sendResponse(&_os, _compress);
- }
- else
- {
- _connection->sendNoResponse();
- }
+ if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
+ {
+ __warning(ex);
+ }
+
+ if(_response)
+ {
+ _os.endWriteEncaps();
+ _os.b.resize(headerSize + 4); // Dispatch status position.
+ _os.write(static_cast<Byte>(DispatchUnknownUserException));
+ ostringstream str;
+ str << ex;
+ _os.write(str.str(), false);
+ _connection->sendResponse(&_os, _compress);
+ }
+ else
+ {
+ _connection->sendNoResponse();
+ }
}
catch(const Exception& ex)
{
- if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
- {
- __warning(ex);
- }
-
- if(_response)
- {
- _os.endWriteEncaps();
- _os.b.resize(headerSize + 4); // Dispatch status position.
- _os.write(static_cast<Byte>(DispatchUnknownException));
- ostringstream str;
- str << ex;
- _os.write(str.str(), false);
- _connection->sendResponse(&_os, _compress);
- }
- else
- {
- _connection->sendNoResponse();
- }
+ if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
+ {
+ __warning(ex);
+ }
+
+ if(_response)
+ {
+ _os.endWriteEncaps();
+ _os.b.resize(headerSize + 4); // Dispatch status position.
+ _os.write(static_cast<Byte>(DispatchUnknownException));
+ ostringstream str;
+ str << ex;
+ _os.write(str.str(), false);
+ _connection->sendResponse(&_os, _compress);
+ }
+ else
+ {
+ _connection->sendNoResponse();
+ }
}
}
@@ -275,22 +275,22 @@ IceInternal::IncomingBase::__handleException(const std::exception& ex)
{
if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
{
- __warning(string("std::exception: ") + ex.what());
+ __warning(string("std::exception: ") + ex.what());
}
if(_response)
{
- _os.endWriteEncaps();
- _os.b.resize(headerSize + 4); // Dispatch status position.
- _os.write(static_cast<Byte>(DispatchUnknownException));
- ostringstream str;
- str << "std::exception: " << ex.what();
- _os.write(str.str(), false);
- _connection->sendResponse(&_os, _compress);
+ _os.endWriteEncaps();
+ _os.b.resize(headerSize + 4); // Dispatch status position.
+ _os.write(static_cast<Byte>(DispatchUnknownException));
+ ostringstream str;
+ str << "std::exception: " << ex.what();
+ _os.write(str.str(), false);
+ _connection->sendResponse(&_os, _compress);
}
else
{
- _connection->sendNoResponse();
+ _connection->sendNoResponse();
}
}
@@ -299,27 +299,27 @@ IceInternal::IncomingBase::__handleException()
{
if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
{
- __warning("unknown c++ exception");
+ __warning("unknown c++ exception");
}
if(_response)
{
- _os.endWriteEncaps();
- _os.b.resize(headerSize + 4); // Dispatch status position.
- _os.write(static_cast<Byte>(DispatchUnknownException));
- string reason = "unknown c++ exception";
- _os.write(reason, false);
- _connection->sendResponse(&_os, _compress);
+ _os.endWriteEncaps();
+ _os.b.resize(headerSize + 4); // Dispatch status position.
+ _os.write(static_cast<Byte>(DispatchUnknownException));
+ string reason = "unknown c++ exception";
+ _os.write(reason, false);
+ _connection->sendResponse(&_os, _compress);
}
else
{
- _connection->sendNoResponse();
+ _connection->sendNoResponse();
}
}
IceInternal::Incoming::Incoming(Instance* instance, ConnectionI* connection,
- const ObjectAdapterPtr& adapter,
- bool response, Byte compress, Int requestId) :
+ const ObjectAdapterPtr& adapter,
+ bool response, Byte compress, Int requestId) :
IncomingBase(instance, connection, adapter, response, compress, requestId),
_is(instance)
{
@@ -338,16 +338,16 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager)
//
string facet;
{
- vector<string> facetPath;
- _is.read(facetPath);
- if(!facetPath.empty())
- {
- if(facetPath.size() > 1)
- {
- throw MarshalException(__FILE__, __LINE__);
- }
- facet.swap(facetPath[0]);
- }
+ vector<string> facetPath;
+ _is.read(facetPath);
+ if(!facetPath.empty())
+ {
+ if(facetPath.size() > 1)
+ {
+ throw MarshalException(__FILE__, __LINE__);
+ }
+ facet.swap(facetPath[0]);
+ }
}
_current.facet.swap(facet);
@@ -361,19 +361,19 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager)
_is.readSize(sz);
while(sz--)
{
- pair<const string, string> pr;
- _is.read(const_cast<string&>(pr.first));
- _is.read(pr.second);
- _current.ctx.insert(_current.ctx.end(), pr);
+ pair<const string, string> pr;
+ _is.read(const_cast<string&>(pr.first));
+ _is.read(pr.second);
+ _current.ctx.insert(_current.ctx.end(), pr);
}
_is.startReadEncaps();
if(_response)
{
- assert(_os.b.size() == headerSize + 4); // Dispatch status position.
- _os.write(static_cast<Byte>(0));
- _os.startWriteEncaps();
+ assert(_os.b.size() == headerSize + 4); // Dispatch status position.
+ _os.write(static_cast<Byte>(0));
+ _os.startWriteEncaps();
}
// Initialize status to some value, to keep the compiler happy.
@@ -387,72 +387,72 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager)
try
{
- try
- {
- if(servantManager)
- {
- _servant = servantManager->findServant(_current.id, _current.facet);
- if(!_servant)
- {
- _locator = servantManager->findServantLocator(_current.id.category);
- if(!_locator && !_current.id.category.empty())
- {
- _locator = servantManager->findServantLocator("");
- }
- if(_locator)
- {
- _servant = _locator->locate(_current, _cookie);
- }
- }
- }
- if(!_servant)
- {
- if(servantManager && servantManager->hasServant(_current.id))
- {
- status = DispatchFacetNotExist;
- }
- else
- {
- status = DispatchObjectNotExist;
- }
- }
- else
- {
- status = _servant->__dispatch(*this, _current);
- }
- }
- catch(...)
- {
- if(_locator && _servant && status != DispatchAsync)
- {
- _locator->finished(_current, _servant, _cookie);
- }
-
- throw;
- }
-
- if(_locator && _servant && status != DispatchAsync)
- {
- _locator->finished(_current, _servant, _cookie);
- }
+ try
+ {
+ if(servantManager)
+ {
+ _servant = servantManager->findServant(_current.id, _current.facet);
+ if(!_servant)
+ {
+ _locator = servantManager->findServantLocator(_current.id.category);
+ if(!_locator && !_current.id.category.empty())
+ {
+ _locator = servantManager->findServantLocator("");
+ }
+ if(_locator)
+ {
+ _servant = _locator->locate(_current, _cookie);
+ }
+ }
+ }
+ if(!_servant)
+ {
+ if(servantManager && servantManager->hasServant(_current.id))
+ {
+ status = DispatchFacetNotExist;
+ }
+ else
+ {
+ status = DispatchObjectNotExist;
+ }
+ }
+ else
+ {
+ status = _servant->__dispatch(*this, _current);
+ }
+ }
+ catch(...)
+ {
+ if(_locator && _servant && status != DispatchAsync)
+ {
+ _locator->finished(_current, _servant, _cookie);
+ }
+
+ throw;
+ }
+
+ if(_locator && _servant && status != DispatchAsync)
+ {
+ _locator->finished(_current, _servant, _cookie);
+ }
}
catch(const Exception& ex)
{
- _is.endReadEncaps();
- __handleException(ex);
- return;
+ _is.endReadEncaps();
+ __handleException(ex);
+ return;
}
catch(const std::exception& ex)
{
- _is.endReadEncaps();
- __handleException(ex);
- return;
+ _is.endReadEncaps();
+ __handleException(ex);
+ return;
}
catch(...)
{
- _is.endReadEncaps();
- __handleException();
- return;
+ _is.endReadEncaps();
+ __handleException();
+ return;
}
//
@@ -469,50 +469,50 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager)
//
if(status == DispatchAsync)
{
- //
- // If this was an asynchronous dispatch, we're done here.
- //
- return;
+ //
+ // If this was an asynchronous dispatch, we're done here.
+ //
+ return;
}
if(_response)
{
- _os.endWriteEncaps();
-
- if(status != DispatchOK && status != DispatchUserException)
- {
- assert(status == DispatchObjectNotExist ||
- status == DispatchFacetNotExist ||
- status == DispatchOperationNotExist);
-
- _os.b.resize(headerSize + 4); // Dispatch status position.
- _os.write(static_cast<Byte>(status));
-
- _current.id.__write(&_os);
-
- //
- // For compatibility with the old FacetPath.
- //
- if(_current.facet.empty())
- {
- _os.write(static_cast<string*>(0), static_cast<string*>(0));
- }
- else
- {
- _os.write(&_current.facet, &_current.facet + 1);
- }
-
- _os.write(_current.operation, false);
- }
- else
- {
- *(_os.b.begin() + headerSize + 4) = static_cast<Byte>(status); // Dispatch status position.
- }
-
- _connection->sendResponse(&_os, _compress);
+ _os.endWriteEncaps();
+
+ if(status != DispatchOK && status != DispatchUserException)
+ {
+ assert(status == DispatchObjectNotExist ||
+ status == DispatchFacetNotExist ||
+ status == DispatchOperationNotExist);
+
+ _os.b.resize(headerSize + 4); // Dispatch status position.
+ _os.write(static_cast<Byte>(status));
+
+ _current.id.__write(&_os);
+
+ //
+ // For compatibility with the old FacetPath.
+ //
+ if(_current.facet.empty())
+ {
+ _os.write(static_cast<string*>(0), static_cast<string*>(0));
+ }
+ else
+ {
+ _os.write(&_current.facet, &_current.facet + 1);
+ }
+
+ _os.write(_current.operation, false);
+ }
+ else
+ {
+ *(_os.b.begin() + headerSize + 4) = static_cast<Byte>(status); // Dispatch status position.
+ }
+
+ _connection->sendResponse(&_os, _compress);
}
else
{
- _connection->sendNoResponse();
+ _connection->sendNoResponse();
}
}
diff --git a/cpp/src/Ice/IncomingAsync.cpp b/cpp/src/Ice/IncomingAsync.cpp
index 00127ea64e9..b7c60f8592d 100644
--- a/cpp/src/Ice/IncomingAsync.cpp
+++ b/cpp/src/Ice/IncomingAsync.cpp
@@ -41,34 +41,34 @@ IceInternal::IncomingAsync::__response(bool ok)
{
try
{
- if(!__servantLocatorFinished())
- {
- return;
- }
-
- if(_response)
- {
- _os.endWriteEncaps();
-
- if(ok)
- {
- *(_os.b.begin() + headerSize + 4) = static_cast<Byte>(DispatchOK);
- }
- else
- {
- *(_os.b.begin() + headerSize + 4) = static_cast<Byte>(DispatchUserException);
- }
-
- _connection->sendResponse(&_os, _compress);
- }
- else
- {
- _connection->sendNoResponse();
- }
+ if(!__servantLocatorFinished())
+ {
+ return;
+ }
+
+ if(_response)
+ {
+ _os.endWriteEncaps();
+
+ if(ok)
+ {
+ *(_os.b.begin() + headerSize + 4) = static_cast<Byte>(DispatchOK);
+ }
+ else
+ {
+ *(_os.b.begin() + headerSize + 4) = static_cast<Byte>(DispatchUserException);
+ }
+
+ _connection->sendResponse(&_os, _compress);
+ }
+ else
+ {
+ _connection->sendNoResponse();
+ }
}
catch(const LocalException& ex)
{
- _connection->invokeException(ex, 1); // Fatal invocation exception
+ _connection->invokeException(ex, 1); // Fatal invocation exception
}
}
@@ -77,16 +77,16 @@ IceInternal::IncomingAsync::__exception(const Exception& exc)
{
try
{
- if(!__servantLocatorFinished())
- {
- return;
- }
+ if(!__servantLocatorFinished())
+ {
+ return;
+ }
- __handleException(exc);
+ __handleException(exc);
}
catch(const LocalException& ex)
{
- _connection->invokeException(ex, 1); // Fatal invocation exception
+ _connection->invokeException(ex, 1); // Fatal invocation exception
}
}
@@ -95,16 +95,16 @@ IceInternal::IncomingAsync::__exception(const std::exception& exc)
{
try
{
- if(!__servantLocatorFinished())
- {
- return;
- }
+ if(!__servantLocatorFinished())
+ {
+ return;
+ }
- __handleException(exc);
+ __handleException(exc);
}
catch(const LocalException& ex)
{
- _connection->invokeException(ex, 1); // Fatal invocation exception
+ _connection->invokeException(ex, 1); // Fatal invocation exception
}
}
@@ -113,16 +113,16 @@ IceInternal::IncomingAsync::__exception()
{
try
{
- if(!__servantLocatorFinished())
- {
- return;
- }
+ if(!__servantLocatorFinished())
+ {
+ return;
+ }
- __handleException();
+ __handleException();
}
catch(const LocalException& ex)
{
- _connection->invokeException(ex, 1); // Fatal invocation exception
+ _connection->invokeException(ex, 1); // Fatal invocation exception
}
}
@@ -131,26 +131,26 @@ IceInternal::IncomingAsync::__servantLocatorFinished()
{
try
{
- if(_locator && _servant)
- {
- _locator->finished(_current, _servant, _cookie);
- }
- return true;
+ if(_locator && _servant)
+ {
+ _locator->finished(_current, _servant, _cookie);
+ }
+ return true;
}
catch(const Exception& ex)
{
- __handleException(ex);
- return false;
+ __handleException(ex);
+ return false;
}
catch(const std::exception& ex)
{
- __handleException(ex);
- return false;
+ __handleException(ex);
+ return false;
}
catch(...)
{
- __handleException();
- return false;
+ __handleException();
+ return false;
}
}
@@ -164,12 +164,12 @@ IceAsync::Ice::AMD_Object_ice_invoke::ice_response(bool ok, const vector<Byte>&
{
try
{
- __os()->writeBlob(outParams);
+ __os()->writeBlob(outParams);
}
catch(const LocalException& ex)
{
- __exception(ex);
- return;
+ __exception(ex);
+ return;
}
__response(ok);
}
@@ -202,12 +202,12 @@ IceAsync::Ice::AMD_Array_Object_ice_invoke::ice_response(bool ok, const pair<con
{
try
{
- __os()->writeBlob(outParams.first, static_cast<Int>(outParams.second - outParams.first));
+ __os()->writeBlob(outParams.first, static_cast<Int>(outParams.second - outParams.first));
}
catch(const LocalException& ex)
{
- __exception(ex);
- return;
+ __exception(ex);
+ return;
}
__response(ok);
}
diff --git a/cpp/src/Ice/Initialize.cpp b/cpp/src/Ice/Initialize.cpp
index cb7252ddf94..70ce1296280 100644
--- a/cpp/src/Ice/Initialize.cpp
+++ b/cpp/src/Ice/Initialize.cpp
@@ -32,7 +32,7 @@ Ice::collectGarbage()
{
if(theCollector)
{
- theCollector->collectGarbage();
+ theCollector->collectGarbage();
}
}
@@ -80,7 +80,7 @@ Ice::stringSeqToArgs(const StringSeq& args, int& argc, char* argv[])
//
if(argv && argcOrig != argc)
{
- argv[argc] = 0;
+ argv[argc] = 0;
}
}
@@ -115,7 +115,7 @@ inline void checkIceVersion(Int version)
//
if(ICE_INT_VERSION != version)
{
- throw VersionMismatchException(__FILE__, __LINE__);
+ throw VersionMismatchException(__FILE__, __LINE__);
}
# else
@@ -124,7 +124,7 @@ inline void checkIceVersion(Int version)
//
if(ICE_INT_VERSION / 100 != version / 100)
{
- throw VersionMismatchException(__FILE__, __LINE__);
+ throw VersionMismatchException(__FILE__, __LINE__);
}
//
@@ -132,7 +132,7 @@ inline void checkIceVersion(Int version)
//
if(version % 100 > 50)
{
- throw VersionMismatchException(__FILE__, __LINE__);
+ throw VersionMismatchException(__FILE__, __LINE__);
}
//
@@ -141,7 +141,7 @@ inline void checkIceVersion(Int version)
//
if(version % 100 > ICE_INT_VERSION % 100)
{
- throw VersionMismatchException(__FILE__, __LINE__);
+ throw VersionMismatchException(__FILE__, __LINE__);
}
# endif
@@ -172,42 +172,42 @@ Ice::initialize(StringSeq& args, const InitializationData& initializationData, I
CommunicatorPtr communicator;
try
{
- //
- // Make a dummy argc/argv.
- // (We can't use argsToStringSeq() because that requires an already initialized argv.)
- //
- int argc = args.size();
- origArgc = argc;
- argv = new char*[args.size() + 1];
- int i;
- for(i = 0; i != argc; ++i)
- {
- argv[i] = new char[args[i].size() + 1];
+ //
+ // Make a dummy argc/argv.
+ // (We can't use argsToStringSeq() because that requires an already initialized argv.)
+ //
+ int argc = args.size();
+ origArgc = argc;
+ argv = new char*[args.size() + 1];
+ int i;
+ for(i = 0; i != argc; ++i)
+ {
+ argv[i] = new char[args[i].size() + 1];
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
- strcpy_s(argv[i], args[i].size() + 1, args[i].c_str());
+ strcpy_s(argv[i], args[i].size() + 1, args[i].c_str());
#else
- strcpy(argv[i], args[i].c_str());
+ strcpy(argv[i], args[i].c_str());
#endif
- }
- argv[argc] = 0;
-
- communicator = initialize(argc, argv, initializationData, version);
-
- args = argsToStringSeq(argc, argv);
-
- for(i = 0; i < origArgc; ++i)
- {
- delete[] argv[i];
- }
- delete[] argv;
+ }
+ argv[argc] = 0;
+
+ communicator = initialize(argc, argv, initializationData, version);
+
+ args = argsToStringSeq(argc, argv);
+
+ for(i = 0; i < origArgc; ++i)
+ {
+ delete[] argv[i];
+ }
+ delete[] argv;
}
catch(...)
{
- for(int i = 0; i < origArgc; ++i)
- {
- delete[] argv[i];
- }
- delete[] argv;
+ for(int i = 0; i < origArgc; ++i)
+ {
+ delete[] argv[i];
+ }
+ delete[] argv;
throw;
}
return communicator;
@@ -249,7 +249,7 @@ Ice::initializeWithLogger(int& argc, char* argv[], const LoggerPtr& logger, Int
CommunicatorPtr
Ice::initializeWithPropertiesAndLogger(int& argc, char* argv[], const PropertiesPtr& properties,
- const LoggerPtr& logger, Int version)
+ const LoggerPtr& logger, Int version)
{
InitializationData initData;
initData.properties = properties;
diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp
index 5548d792c9b..ecb2f466bd2 100644
--- a/cpp/src/Ice/Instance.cpp
+++ b/cpp/src/Ice/Instance.cpp
@@ -98,7 +98,7 @@ IceInternal::Instance::routerManager() const
if(_state == StateDestroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
return _routerManager;
@@ -111,7 +111,7 @@ IceInternal::Instance::locatorManager() const
if(_state == StateDestroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
return _locatorManager;
@@ -124,7 +124,7 @@ IceInternal::Instance::referenceFactory() const
if(_state == StateDestroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
return _referenceFactory;
@@ -137,7 +137,7 @@ IceInternal::Instance::proxyFactory() const
if(_state == StateDestroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
return _proxyFactory;
@@ -150,7 +150,7 @@ IceInternal::Instance::outgoingConnectionFactory() const
if(_state == StateDestroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
return _outgoingConnectionFactory;
@@ -163,7 +163,7 @@ IceInternal::Instance::connectionMonitor() const
if(_state == StateDestroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
return _connectionMonitor;
@@ -176,7 +176,7 @@ IceInternal::Instance::servantFactoryManager() const
if(_state == StateDestroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
return _servantFactoryManager;
@@ -189,7 +189,7 @@ IceInternal::Instance::objectAdapterFactory() const
if(_state == StateDestroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
return _objectAdapterFactory;
@@ -202,12 +202,12 @@ IceInternal::Instance::clientThreadPool()
if(_state == StateDestroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
if(!_clientThreadPool) // Lazy initialization.
{
- _clientThreadPool = new ThreadPool(this, "Ice.ThreadPool.Client", 0);
+ _clientThreadPool = new ThreadPool(this, "Ice.ThreadPool.Client", 0);
}
return _clientThreadPool;
@@ -220,13 +220,13 @@ IceInternal::Instance::serverThreadPool()
if(_state == StateDestroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
if(!_serverThreadPool) // Lazy initialization.
{
- int timeout = _initData.properties->getPropertyAsInt("Ice.ServerIdleTime");
- _serverThreadPool = new ThreadPool(this, "Ice.ThreadPool.Server", timeout);
+ int timeout = _initData.properties->getPropertyAsInt("Ice.ServerIdleTime");
+ _serverThreadPool = new ThreadPool(this, "Ice.ThreadPool.Server", timeout);
}
return _serverThreadPool;
@@ -253,7 +253,7 @@ IceInternal::Instance::endpointFactoryManager() const
if(_state == StateDestroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
return _endpointFactoryManager;
@@ -266,7 +266,7 @@ IceInternal::Instance::dynamicLibraryList() const
if(_state == StateDestroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
return _dynamicLibraryList;
@@ -279,7 +279,7 @@ IceInternal::Instance::pluginManager() const
if(_state == StateDestroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
return _pluginManager;
@@ -306,15 +306,15 @@ IceInternal::Instance::flushBatchRequests()
ObjectAdapterFactoryPtr adapterFactory;
{
- IceUtil::RecMutex::Lock sync(*this);
+ IceUtil::RecMutex::Lock sync(*this);
- if(_state == StateDestroyed)
- {
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
- }
+ if(_state == StateDestroyed)
+ {
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ }
- connectionFactory = _outgoingConnectionFactory;
- adapterFactory = _objectAdapterFactory;
+ connectionFactory = _outgoingConnectionFactory;
+ adapterFactory = _objectAdapterFactory;
}
connectionFactory->flushBatchRequests();
@@ -328,7 +328,7 @@ IceInternal::Instance::setDefaultContext(const Context& ctx)
if(_state == StateDestroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
_defaultContext = new SharedContext(ctx);
@@ -341,7 +341,7 @@ IceInternal::Instance::getDefaultContext() const
if(_state == StateDestroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
return _defaultContext;
@@ -409,15 +409,15 @@ IceInternal::Instance::stringToIdentity(const string& s) const
if(_initData.stringConverter)
{
string tmpString;
- _initData.stringConverter->fromUTF8(reinterpret_cast<const Byte*>(ident.name.data()),
- reinterpret_cast<const Byte*>(ident.name.data() + ident.name.size()),
- tmpString);
- ident.name = tmpString;
+ _initData.stringConverter->fromUTF8(reinterpret_cast<const Byte*>(ident.name.data()),
+ reinterpret_cast<const Byte*>(ident.name.data() + ident.name.size()),
+ tmpString);
+ ident.name = tmpString;
- _initData.stringConverter->fromUTF8(reinterpret_cast<const Byte*>(ident.category.data()),
- reinterpret_cast<const Byte*>(ident.category.data() + ident.category.size()),
- tmpString);
- ident.category = tmpString;
+ _initData.stringConverter->fromUTF8(reinterpret_cast<const Byte*>(ident.category.data()),
+ reinterpret_cast<const Byte*>(ident.category.data() + ident.category.size()),
+ tmpString);
+ ident.category = tmpString;
}
return ident;
@@ -432,12 +432,12 @@ IceInternal::Instance::identityToString(const Identity& ident) const
{
UTF8BufferI buffer;
Byte* last = _initData.stringConverter->toUTF8(ident.name.data(), ident.name.data() + ident.name.size(),
- buffer);
+ buffer);
name = string(reinterpret_cast<const char*>(buffer.getBuffer()), last - buffer.getBuffer());
- buffer.reset();
+ buffer.reset();
last = _initData.stringConverter->toUTF8(ident.category.data(), ident.category.data() + ident.category.size(),
- buffer);
+ buffer);
category = string(reinterpret_cast<const char*>(buffer.getBuffer()), last - buffer.getBuffer());
}
@@ -464,189 +464,189 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi
{
try
{
- __setNoDelete(true);
-
- IceUtil::StaticMutex::Lock sync(staticMutex);
- instanceCount++;
-
- if(!_initData.properties)
- {
- _initData.properties = createProperties();
- }
-
- if(!oneOffDone)
- {
- //
- // StdOut and StdErr redirection
- //
- string stdOutFilename = _initData.properties->getProperty("Ice.StdOut");
- string stdErrFilename = _initData.properties->getProperty("Ice.StdErr");
-
- if(stdOutFilename != "")
- {
- FILE* file = freopen(stdOutFilename.c_str(), "a", stdout);
- if(file == 0)
- {
- FileException ex(__FILE__, __LINE__);
- ex.path = stdOutFilename;
- ex.error = getSystemErrno();
- throw ex;
- }
- }
-
- if(stdErrFilename != "")
- {
- FILE* file = freopen(stdErrFilename.c_str(), "a", stderr);
- if(file == 0)
- {
- FileException ex(__FILE__, __LINE__);
- ex.path = stdErrFilename;
- ex.error = getSystemErrno();
- throw ex;
- }
- }
-
- if(_initData.properties->getPropertyAsInt("Ice.NullHandleAbort") > 0)
- {
- IceUtil::nullHandleAbort = true;
- }
-
+ __setNoDelete(true);
+
+ IceUtil::StaticMutex::Lock sync(staticMutex);
+ instanceCount++;
+
+ if(!_initData.properties)
+ {
+ _initData.properties = createProperties();
+ }
+
+ if(!oneOffDone)
+ {
+ //
+ // StdOut and StdErr redirection
+ //
+ string stdOutFilename = _initData.properties->getProperty("Ice.StdOut");
+ string stdErrFilename = _initData.properties->getProperty("Ice.StdErr");
+
+ if(stdOutFilename != "")
+ {
+ FILE* file = freopen(stdOutFilename.c_str(), "a", stdout);
+ if(file == 0)
+ {
+ FileException ex(__FILE__, __LINE__);
+ ex.path = stdOutFilename;
+ ex.error = getSystemErrno();
+ throw ex;
+ }
+ }
+
+ if(stdErrFilename != "")
+ {
+ FILE* file = freopen(stdErrFilename.c_str(), "a", stderr);
+ if(file == 0)
+ {
+ FileException ex(__FILE__, __LINE__);
+ ex.path = stdErrFilename;
+ ex.error = getSystemErrno();
+ throw ex;
+ }
+ }
+
+ if(_initData.properties->getPropertyAsInt("Ice.NullHandleAbort") > 0)
+ {
+ IceUtil::nullHandleAbort = true;
+ }
+
#ifndef _WIN32
- string newUser = _initData.properties->getProperty("Ice.ChangeUser");
- if(!newUser.empty())
- {
- struct passwd* pw = getpwnam(newUser.c_str());
- if(!pw)
- {
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
- }
-
- if(setgid(pw->pw_gid) == -1)
- {
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
- }
-
- if(setuid(pw->pw_uid) == -1)
- {
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
- }
- }
+ string newUser = _initData.properties->getProperty("Ice.ChangeUser");
+ if(!newUser.empty())
+ {
+ struct passwd* pw = getpwnam(newUser.c_str());
+ if(!pw)
+ {
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
+ }
+
+ if(setgid(pw->pw_gid) == -1)
+ {
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
+ }
+
+ if(setuid(pw->pw_uid) == -1)
+ {
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
+ }
+ }
#endif
- oneOffDone = true;
- }
-
- if(instanceCount == 1)
- {
-
+ oneOffDone = true;
+ }
+
+ if(instanceCount == 1)
+ {
+
#ifdef _WIN32
- WORD version = MAKEWORD(1, 1);
- WSADATA data;
- if(WSAStartup(version, &data) != 0)
- {
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
+ WORD version = MAKEWORD(1, 1);
+ WSADATA data;
+ if(WSAStartup(version, &data) != 0)
+ {
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
#endif
-
+
#ifndef _WIN32
- struct sigaction action;
- action.sa_handler = SIG_IGN;
- sigemptyset(&action.sa_mask);
- action.sa_flags = 0;
- sigaction(SIGPIPE, &action, 0);
-
- if(_initData.properties->getPropertyAsInt("Ice.UseSyslog") > 0)
- {
- identForOpenlog = _initData.properties->getProperty("Ice.ProgramName");
- if(identForOpenlog.empty())
- {
- identForOpenlog = "<Unknown Ice Program>";
- }
- openlog(identForOpenlog.c_str(), LOG_PID, LOG_USER);
- }
+ struct sigaction action;
+ action.sa_handler = SIG_IGN;
+ sigemptyset(&action.sa_mask);
+ action.sa_flags = 0;
+ sigaction(SIGPIPE, &action, 0);
+
+ if(_initData.properties->getPropertyAsInt("Ice.UseSyslog") > 0)
+ {
+ identForOpenlog = _initData.properties->getProperty("Ice.ProgramName");
+ if(identForOpenlog.empty())
+ {
+ identForOpenlog = "<Unknown Ice Program>";
+ }
+ openlog(identForOpenlog.c_str(), LOG_PID, LOG_USER);
+ }
#endif
- }
-
- sync.release();
-
+ }
+
+ sync.release();
+
- if(!_initData.logger)
- {
+ if(!_initData.logger)
+ {
#ifdef _WIN32
- if(_initData.properties->getPropertyAsInt("Ice.UseEventLog") > 0)
- {
- _initData.logger = new EventLoggerI(_initData.properties->getProperty("Ice.ProgramName"));
- }
+ if(_initData.properties->getPropertyAsInt("Ice.UseEventLog") > 0)
+ {
+ _initData.logger = new EventLoggerI(_initData.properties->getProperty("Ice.ProgramName"));
+ }
#else
- if(_initData.properties->getPropertyAsInt("Ice.UseSyslog") > 0)
- {
- _initData.logger = new SysLoggerI;
- }
+ if(_initData.properties->getPropertyAsInt("Ice.UseSyslog") > 0)
+ {
+ _initData.logger = new SysLoggerI;
+ }
#endif
- else
- {
- _initData.logger = getProcessLogger();
- }
- }
-
- const_cast<TraceLevelsPtr&>(_traceLevels) = new TraceLevels(_initData.properties);
-
- const_cast<DefaultsAndOverridesPtr&>(_defaultsAndOverrides) = new DefaultsAndOverrides(_initData.properties);
-
- {
- static const int defaultMessageSizeMax = 1024;
- Int num = _initData.properties->getPropertyAsIntWithDefault("Ice.MessageSizeMax", defaultMessageSizeMax);
- if(num < 1)
- {
- const_cast<size_t&>(_messageSizeMax) = defaultMessageSizeMax * 1024; // Ignore stupid values.
- }
- else if(static_cast<size_t>(num) > (size_t)(0x7fffffff / 1024))
- {
- const_cast<size_t&>(_messageSizeMax) = static_cast<size_t>(0x7fffffff);
- }
- else
- {
- // Property is in kilobytes, _messageSizeMax in bytes.
- const_cast<size_t&>(_messageSizeMax) = static_cast<size_t>(num) * 1024;
- }
- }
-
- //
- // Client ACM enabled by default. Server ACM disabled by default.
- //
- const_cast<Int&>(_clientACM) = _initData.properties->getPropertyAsIntWithDefault("Ice.ACM.Client", 60);
- const_cast<Int&>(_serverACM) = _initData.properties->getPropertyAsInt("Ice.ACM.Server");
-
- const_cast<bool&>(_threadPerConnection) = _initData.properties->getPropertyAsInt("Ice.ThreadPerConnection") > 0;
-
- {
- Int stackSize = _initData.properties->getPropertyAsInt("Ice.ThreadPerConnection.StackSize");
- if(stackSize < 0)
- {
- stackSize = 0;
- }
- const_cast<size_t&>(_threadPerConnectionStackSize) = static_cast<size_t>(stackSize);
- }
-
- const_cast<ImplicitContextIPtr&>(_implicitContext) =
- ImplicitContextI::create(_initData.properties->getProperty("Ice.ImplicitContext"));
-
- _routerManager = new RouterManager;
-
- _locatorManager = new LocatorManager;
-
- _referenceFactory = new ReferenceFactory(this, communicator);
-
- _proxyFactory = new ProxyFactory(this);
-
- _endpointFactoryManager = new EndpointFactoryManager(this);
+ else
+ {
+ _initData.logger = getProcessLogger();
+ }
+ }
+
+ const_cast<TraceLevelsPtr&>(_traceLevels) = new TraceLevels(_initData.properties);
+
+ const_cast<DefaultsAndOverridesPtr&>(_defaultsAndOverrides) = new DefaultsAndOverrides(_initData.properties);
+
+ {
+ static const int defaultMessageSizeMax = 1024;
+ Int num = _initData.properties->getPropertyAsIntWithDefault("Ice.MessageSizeMax", defaultMessageSizeMax);
+ if(num < 1)
+ {
+ const_cast<size_t&>(_messageSizeMax) = defaultMessageSizeMax * 1024; // Ignore stupid values.
+ }
+ else if(static_cast<size_t>(num) > (size_t)(0x7fffffff / 1024))
+ {
+ const_cast<size_t&>(_messageSizeMax) = static_cast<size_t>(0x7fffffff);
+ }
+ else
+ {
+ // Property is in kilobytes, _messageSizeMax in bytes.
+ const_cast<size_t&>(_messageSizeMax) = static_cast<size_t>(num) * 1024;
+ }
+ }
+
+ //
+ // Client ACM enabled by default. Server ACM disabled by default.
+ //
+ const_cast<Int&>(_clientACM) = _initData.properties->getPropertyAsIntWithDefault("Ice.ACM.Client", 60);
+ const_cast<Int&>(_serverACM) = _initData.properties->getPropertyAsInt("Ice.ACM.Server");
+
+ const_cast<bool&>(_threadPerConnection) = _initData.properties->getPropertyAsInt("Ice.ThreadPerConnection") > 0;
+
+ {
+ Int stackSize = _initData.properties->getPropertyAsInt("Ice.ThreadPerConnection.StackSize");
+ if(stackSize < 0)
+ {
+ stackSize = 0;
+ }
+ const_cast<size_t&>(_threadPerConnectionStackSize) = static_cast<size_t>(stackSize);
+ }
+
+ const_cast<ImplicitContextIPtr&>(_implicitContext) =
+ ImplicitContextI::create(_initData.properties->getProperty("Ice.ImplicitContext"));
+
+ _routerManager = new RouterManager;
+
+ _locatorManager = new LocatorManager;
+
+ _referenceFactory = new ReferenceFactory(this, communicator);
+
+ _proxyFactory = new ProxyFactory(this);
+
+ _endpointFactoryManager = new EndpointFactoryManager(this);
EndpointFactoryPtr tcpEndpointFactory = new TcpEndpointFactory(this);
_endpointFactoryManager->add(tcpEndpointFactory);
EndpointFactoryPtr udpEndpointFactory = new UdpEndpointFactory(this);
@@ -656,28 +656,28 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi
_pluginManager = new PluginManagerI(communicator, _dynamicLibraryList);
- _outgoingConnectionFactory = new OutgoingConnectionFactory(this);
+ _outgoingConnectionFactory = new OutgoingConnectionFactory(this);
- _servantFactoryManager = new ObjectFactoryManager();
+ _servantFactoryManager = new ObjectFactoryManager();
- _objectAdapterFactory = new ObjectAdapterFactory(this, communicator);
+ _objectAdapterFactory = new ObjectAdapterFactory(this, communicator);
- if(_initData.wstringConverter == 0)
- {
- _initData.wstringConverter = new UnicodeWstringConverter();
- }
+ if(_initData.wstringConverter == 0)
+ {
+ _initData.wstringConverter = new UnicodeWstringConverter();
+ }
- __setNoDelete(false);
+ __setNoDelete(false);
}
catch(...)
{
- {
- IceUtil::StaticMutex::Lock sync(staticMutex);
- --instanceCount;
- }
- destroy();
- __setNoDelete(false);
- throw;
+ {
+ IceUtil::StaticMutex::Lock sync(staticMutex);
+ --instanceCount;
+ }
+ destroy();
+ __setNoDelete(false);
+ throw;
}
}
@@ -703,21 +703,21 @@ IceInternal::Instance::~Instance()
if(--instanceCount == 0)
{
#ifdef _WIN32
- WSACleanup();
+ WSACleanup();
#endif
-
+
#ifndef _WIN32
- struct sigaction action;
- action.sa_handler = SIG_DFL;
- sigemptyset(&action.sa_mask);
- action.sa_flags = 0;
- sigaction(SIGPIPE, &action, 0);
-
- if(!identForOpenlog.empty())
- {
- closelog();
- identForOpenlog.clear();
- }
+ struct sigaction action;
+ action.sa_handler = SIG_DFL;
+ sigemptyset(&action.sa_mask);
+ action.sa_flags = 0;
+ sigaction(SIGPIPE, &action, 0);
+
+ if(!identForOpenlog.empty())
+ {
+ closelog();
+ identForOpenlog.clear();
+ }
#endif
}
}
@@ -755,24 +755,24 @@ IceInternal::Instance::finishSetup(int& argc, char* argv[])
bool printProcessId = false;
if(!printProcessIdDone && _initData.properties->getPropertyAsInt("Ice.PrintProcessId") > 0)
{
- //
- // Safe double-check locking (no dependent variable!)
- //
- IceUtil::StaticMutex::Lock sync(staticMutex);
- printProcessId = !printProcessIdDone;
-
- //
- // We anticipate: we want to print it once, and we don't care when.
- //
- printProcessIdDone = true;
+ //
+ // Safe double-check locking (no dependent variable!)
+ //
+ IceUtil::StaticMutex::Lock sync(staticMutex);
+ printProcessId = !printProcessIdDone;
+
+ //
+ // We anticipate: we want to print it once, and we don't care when.
+ //
+ printProcessIdDone = true;
}
if(printProcessId)
{
#ifdef _MSC_VER
- cout << _getpid() << endl;
+ cout << _getpid() << endl;
#else
- cout << getpid() << endl;
+ cout << getpid() << endl;
#endif
}
@@ -782,20 +782,20 @@ IceInternal::Instance::finishSetup(int& argc, char* argv[])
Int interval = 0;
if(_clientACM > 0 && _serverACM > 0)
{
- interval = min(_clientACM, _serverACM);
+ interval = min(_clientACM, _serverACM);
}
else if(_clientACM > 0)
{
- interval = _clientACM;
+ interval = _clientACM;
}
else if(_serverACM > 0)
{
- interval = _serverACM;
+ interval = _serverACM;
}
interval = _initData.properties->getPropertyAsIntWithDefault("Ice.MonitorConnections", interval);
if(interval > 0)
{
- _connectionMonitor = new ConnectionMonitor(this, interval);
+ _connectionMonitor = new ConnectionMonitor(this, interval);
}
//
@@ -808,29 +808,29 @@ bool
IceInternal::Instance::destroy()
{
{
- IceUtil::RecMutex::Lock sync(*this);
-
- //
- // If the _state is not StateActive then the instance is
- // either being destroyed, or has already been destroyed.
- //
- if(_state != StateActive)
- {
- return false;
- }
+ IceUtil::RecMutex::Lock sync(*this);
+
+ //
+ // If the _state is not StateActive then the instance is
+ // either being destroyed, or has already been destroyed.
+ //
+ if(_state != StateActive)
+ {
+ return false;
+ }
- //
- // We cannot set state to StateDestroyed otherwise instance
- // methods called during the destroy process (such as
- // outgoingConnectionFactory() from
- // ObjectAdapterI::deactivate() will cause an exception.
- //
- _state = StateDestroyInProgress;
+ //
+ // We cannot set state to StateDestroyed otherwise instance
+ // methods called during the destroy process (such as
+ // outgoingConnectionFactory() from
+ // ObjectAdapterI::deactivate() will cause an exception.
+ //
+ _state = StateDestroyInProgress;
}
if(_objectAdapterFactory)
{
- _objectAdapterFactory->shutdown();
+ _objectAdapterFactory->shutdown();
}
if(_outgoingConnectionFactory)
@@ -852,74 +852,74 @@ IceInternal::Instance::destroy()
ThreadPoolPtr clientThreadPool;
{
- IceUtil::RecMutex::Lock sync(*this);
-
- _objectAdapterFactory = 0;
- _outgoingConnectionFactory = 0;
-
- if(_connectionMonitor)
- {
- _connectionMonitor->destroy();
- _connectionMonitor = 0;
- }
-
- if(_serverThreadPool)
- {
- _serverThreadPool->destroy();
- std::swap(_serverThreadPool, serverThreadPool);
- }
-
- if(_clientThreadPool)
- {
- _clientThreadPool->destroy();
- std::swap(_clientThreadPool, clientThreadPool);
- }
-
- if(_servantFactoryManager)
- {
- _servantFactoryManager->destroy();
- _servantFactoryManager = 0;
- }
-
- if(_referenceFactory)
- {
- _referenceFactory->destroy();
- _referenceFactory = 0;
- }
-
- // No destroy function defined.
- // _proxyFactory->destroy();
- _proxyFactory = 0;
-
- if(_routerManager)
- {
- _routerManager->destroy();
- _routerManager = 0;
- }
-
- if(_locatorManager)
- {
- _locatorManager->destroy();
- _locatorManager = 0;
- }
-
- if(_endpointFactoryManager)
- {
- _endpointFactoryManager->destroy();
- _endpointFactoryManager = 0;
- }
-
- if(_pluginManager)
- {
- _pluginManager->destroy();
- _pluginManager = 0;
- }
-
- // No destroy function defined.
- // _dynamicLibraryList->destroy();
- _dynamicLibraryList = 0;
-
- _state = StateDestroyed;
+ IceUtil::RecMutex::Lock sync(*this);
+
+ _objectAdapterFactory = 0;
+ _outgoingConnectionFactory = 0;
+
+ if(_connectionMonitor)
+ {
+ _connectionMonitor->destroy();
+ _connectionMonitor = 0;
+ }
+
+ if(_serverThreadPool)
+ {
+ _serverThreadPool->destroy();
+ std::swap(_serverThreadPool, serverThreadPool);
+ }
+
+ if(_clientThreadPool)
+ {
+ _clientThreadPool->destroy();
+ std::swap(_clientThreadPool, clientThreadPool);
+ }
+
+ if(_servantFactoryManager)
+ {
+ _servantFactoryManager->destroy();
+ _servantFactoryManager = 0;
+ }
+
+ if(_referenceFactory)
+ {
+ _referenceFactory->destroy();
+ _referenceFactory = 0;
+ }
+
+ // No destroy function defined.
+ // _proxyFactory->destroy();
+ _proxyFactory = 0;
+
+ if(_routerManager)
+ {
+ _routerManager->destroy();
+ _routerManager = 0;
+ }
+
+ if(_locatorManager)
+ {
+ _locatorManager->destroy();
+ _locatorManager = 0;
+ }
+
+ if(_endpointFactoryManager)
+ {
+ _endpointFactoryManager->destroy();
+ _endpointFactoryManager = 0;
+ }
+
+ if(_pluginManager)
+ {
+ _pluginManager->destroy();
+ _pluginManager = 0;
+ }
+
+ // No destroy function defined.
+ // _dynamicLibraryList->destroy();
+ _dynamicLibraryList = 0;
+
+ _state = StateDestroyed;
}
//
@@ -927,11 +927,11 @@ IceInternal::Instance::destroy()
//
if(clientThreadPool)
{
- clientThreadPool->joinWithAllThreads();
+ clientThreadPool->joinWithAllThreads();
}
if(serverThreadPool)
{
- serverThreadPool->joinWithAllThreads();
+ serverThreadPool->joinWithAllThreads();
}
return true;
}
@@ -956,7 +956,7 @@ IceInternal::UTF8BufferI::getMoreBytes(size_t howMany, Byte* firstUnused)
}
else
{
- assert(firstUnused != 0);
+ assert(firstUnused != 0);
_offset = firstUnused - _buffer;
_buffer = (Byte*)realloc(_buffer, _offset + howMany);
}
diff --git a/cpp/src/Ice/Instance.h b/cpp/src/Ice/Instance.h
index 3a4245ff2b7..27f875fc181 100644
--- a/cpp/src/Ice/Instance.h
+++ b/cpp/src/Ice/Instance.h
@@ -81,7 +81,7 @@ public:
const Ice::ImplicitContextIPtr& getImplicitContext() const
{
- return _implicitContext;
+ return _implicitContext;
}
private:
@@ -94,9 +94,9 @@ private:
enum State
{
- StateActive,
- StateDestroyInProgress,
- StateDestroyed
+ StateActive,
+ StateDestroyInProgress,
+ StateDestroyed
};
State _state;
Ice::InitializationData _initData;
diff --git a/cpp/src/Ice/LocatorInfo.cpp b/cpp/src/Ice/LocatorInfo.cpp
index 146126f95ab..15e27d67d03 100644
--- a/cpp/src/Ice/LocatorInfo.cpp
+++ b/cpp/src/Ice/LocatorInfo.cpp
@@ -54,7 +54,7 @@ IceInternal::LocatorManager::get(const LocatorPrx& loc)
{
if(!loc)
{
- return 0;
+ return 0;
}
LocatorPrx locator = LocatorPrx::uncheckedCast(loc->ice_locator(0)); // The locator can't be located.
@@ -69,39 +69,39 @@ IceInternal::LocatorManager::get(const LocatorPrx& loc)
if(_tableHint != _table.end())
{
- if(_tableHint->first == locator)
- {
- p = _tableHint;
- }
+ if(_tableHint->first == locator)
+ {
+ p = _tableHint;
+ }
}
if(p == _table.end())
{
- p = _table.find(locator);
+ p = _table.find(locator);
}
if(p == _table.end())
{
- //
- // Rely on locator identity for the adapter table. We want to
- // have only one table per locator (not one per locator
- // proxy).
- //
- map<Identity, LocatorTablePtr>::iterator t = _locatorTables.find(locator->ice_getIdentity());
- if(t == _locatorTables.end())
- {
- t = _locatorTables.insert(_locatorTables.begin(),
- pair<const Identity, LocatorTablePtr>(locator->ice_getIdentity(),
- new LocatorTable()));
- }
-
- _tableHint = _table.insert(_tableHint,
- pair<const LocatorPrx, LocatorInfoPtr>(locator,
- new LocatorInfo(locator, t->second)));
+ //
+ // Rely on locator identity for the adapter table. We want to
+ // have only one table per locator (not one per locator
+ // proxy).
+ //
+ map<Identity, LocatorTablePtr>::iterator t = _locatorTables.find(locator->ice_getIdentity());
+ if(t == _locatorTables.end())
+ {
+ t = _locatorTables.insert(_locatorTables.begin(),
+ pair<const Identity, LocatorTablePtr>(locator->ice_getIdentity(),
+ new LocatorTable()));
+ }
+
+ _tableHint = _table.insert(_tableHint,
+ pair<const LocatorPrx, LocatorInfoPtr>(locator,
+ new LocatorInfo(locator, t->second)));
}
else
{
- _tableHint = p;
+ _tableHint = p;
}
return _tableHint->second;
@@ -125,7 +125,7 @@ IceInternal::LocatorTable::getAdapterEndpoints(const string& adapter, int ttl, v
{
if(ttl == 0) // No locator cache.
{
- return false;
+ return false;
}
IceUtil::Mutex::Lock sync(*this);
@@ -134,8 +134,8 @@ IceInternal::LocatorTable::getAdapterEndpoints(const string& adapter, int ttl, v
if(p != _adapterEndpointsMap.end() && checkTTL(p->second.first, ttl))
{
- endpoints = p->second.second;
- return true;
+ endpoints = p->second.second;
+ return true;
}
return false;
}
@@ -149,11 +149,11 @@ IceInternal::LocatorTable::addAdapterEndpoints(const string& adapter, const vect
if(p != _adapterEndpointsMap.end())
{
- p->second = make_pair(IceUtil::Time::now(), endpoints);
+ p->second = make_pair(IceUtil::Time::now(), endpoints);
}
else
{
- _adapterEndpointsMap.insert(make_pair(adapter, make_pair(IceUtil::Time::now(), endpoints)));
+ _adapterEndpointsMap.insert(make_pair(adapter, make_pair(IceUtil::Time::now(), endpoints)));
}
}
@@ -165,7 +165,7 @@ IceInternal::LocatorTable::removeAdapterEndpoints(const string& adapter)
map<string, pair<IceUtil::Time, vector<EndpointIPtr> > >::iterator p = _adapterEndpointsMap.find(adapter);
if(p == _adapterEndpointsMap.end())
{
- return vector<EndpointIPtr>();
+ return vector<EndpointIPtr>();
}
vector<EndpointIPtr> endpoints = p->second.second;
@@ -180,7 +180,7 @@ IceInternal::LocatorTable::getProxy(const Identity& id, int ttl, ObjectPrx& prox
{
if(ttl == 0) // No locator cache
{
- return false;
+ return false;
}
IceUtil::Mutex::Lock sync(*this);
@@ -189,8 +189,8 @@ IceInternal::LocatorTable::getProxy(const Identity& id, int ttl, ObjectPrx& prox
if(p != _objectMap.end() && checkTTL(p->second.first, ttl))
{
- proxy = p->second.second;
- return true;
+ proxy = p->second.second;
+ return true;
}
return false;
}
@@ -204,11 +204,11 @@ IceInternal::LocatorTable::addProxy(const Identity& id, const ObjectPrx& proxy)
if(p != _objectMap.end())
{
- p->second = make_pair(IceUtil::Time::now(), proxy);
+ p->second = make_pair(IceUtil::Time::now(), proxy);
}
else
{
- _objectMap.insert(make_pair(id, make_pair(IceUtil::Time::now(), proxy)));
+ _objectMap.insert(make_pair(id, make_pair(IceUtil::Time::now(), proxy)));
}
}
@@ -220,7 +220,7 @@ IceInternal::LocatorTable::removeProxy(const Identity& id)
map<Identity, pair<IceUtil::Time, ObjectPrx> >::iterator p = _objectMap.find(id);
if(p == _objectMap.end())
{
- return 0;
+ return 0;
}
ObjectPrx proxy = p->second.second;
@@ -234,11 +234,11 @@ IceInternal::LocatorTable::checkTTL(const IceUtil::Time& time, int ttl) const
assert(ttl != 0);
if (ttl < 0) // TTL = infinite
{
- return true;
+ return true;
}
else
{
- return IceUtil::Time::now() - time <= IceUtil::Time::seconds(ttl);
+ return IceUtil::Time::now() - time <= IceUtil::Time::seconds(ttl);
}
}
@@ -293,12 +293,12 @@ IceInternal::LocatorInfo::getLocatorRegistry()
if(!_locatorRegistry) // Lazy initialization.
{
- _locatorRegistry = _locator->getRegistry();
+ _locatorRegistry = _locator->getRegistry();
- //
- // The locator registry can't be located.
- //
- _locatorRegistry = LocatorRegistryPrx::uncheckedCast(_locatorRegistry->ice_locator(0));
+ //
+ // The locator registry can't be located.
+ //
+ _locatorRegistry = LocatorRegistryPrx::uncheckedCast(_locatorRegistry->ice_locator(0));
}
return _locatorRegistry;
@@ -312,156 +312,156 @@ IceInternal::LocatorInfo::getEndpoints(const IndirectReferencePtr& ref, int ttl,
cached = true;
try
{
- if(!ref->getAdapterId().empty())
- {
- if(!_table->getAdapterEndpoints(ref->getAdapterId(), ttl, endpoints))
- {
- cached = false;
-
- if(ref->getInstance()->traceLevels()->location >= 1)
- {
- Trace out(ref->getInstance()->initializationData().logger,
- ref->getInstance()->traceLevels()->locationCat);
- out << "searching for adapter by id" << "\n";
- out << "adapter = " << ref->getAdapterId();
- }
-
- object = _locator->findAdapterById(ref->getAdapterId());
- if(object)
- {
- endpoints = object->__reference()->getEndpoints();
- _table->addAdapterEndpoints(ref->getAdapterId(), endpoints);
- }
- }
- }
- else
- {
- bool objectCached = true;
- if(!_table->getProxy(ref->getIdentity(), ttl, object))
- {
- if(ref->getInstance()->traceLevels()->location >= 1)
- {
- Trace out(ref->getInstance()->initializationData().logger,
- ref->getInstance()->traceLevels()->locationCat);
- out << "searching for object by id" << "\n";
- out << "object = " << ref->getInstance()->identityToString(ref->getIdentity());
- }
-
- objectCached = false;
- object = _locator->findObjectById(ref->getIdentity());
- }
-
- bool endpointsCached = true;
- if(object)
- {
- DirectReferencePtr odr = DirectReferencePtr::dynamicCast(object->__reference());
- if(odr)
- {
- endpointsCached = false;
- endpoints = odr->getEndpoints();
- }
- else
- {
- IndirectReferencePtr oir = IndirectReferencePtr::dynamicCast(object->__reference());
- assert(oir);
- if(!oir->getAdapterId().empty())
- {
- endpoints = getEndpoints(oir, ttl, endpointsCached);
- }
- }
- }
-
- if(!objectCached && !endpoints.empty())
- {
- _table->addProxy(ref->getIdentity(), object);
- }
-
- cached = objectCached || endpointsCached;
- }
+ if(!ref->getAdapterId().empty())
+ {
+ if(!_table->getAdapterEndpoints(ref->getAdapterId(), ttl, endpoints))
+ {
+ cached = false;
+
+ if(ref->getInstance()->traceLevels()->location >= 1)
+ {
+ Trace out(ref->getInstance()->initializationData().logger,
+ ref->getInstance()->traceLevels()->locationCat);
+ out << "searching for adapter by id" << "\n";
+ out << "adapter = " << ref->getAdapterId();
+ }
+
+ object = _locator->findAdapterById(ref->getAdapterId());
+ if(object)
+ {
+ endpoints = object->__reference()->getEndpoints();
+ _table->addAdapterEndpoints(ref->getAdapterId(), endpoints);
+ }
+ }
+ }
+ else
+ {
+ bool objectCached = true;
+ if(!_table->getProxy(ref->getIdentity(), ttl, object))
+ {
+ if(ref->getInstance()->traceLevels()->location >= 1)
+ {
+ Trace out(ref->getInstance()->initializationData().logger,
+ ref->getInstance()->traceLevels()->locationCat);
+ out << "searching for object by id" << "\n";
+ out << "object = " << ref->getInstance()->identityToString(ref->getIdentity());
+ }
+
+ objectCached = false;
+ object = _locator->findObjectById(ref->getIdentity());
+ }
+
+ bool endpointsCached = true;
+ if(object)
+ {
+ DirectReferencePtr odr = DirectReferencePtr::dynamicCast(object->__reference());
+ if(odr)
+ {
+ endpointsCached = false;
+ endpoints = odr->getEndpoints();
+ }
+ else
+ {
+ IndirectReferencePtr oir = IndirectReferencePtr::dynamicCast(object->__reference());
+ assert(oir);
+ if(!oir->getAdapterId().empty())
+ {
+ endpoints = getEndpoints(oir, ttl, endpointsCached);
+ }
+ }
+ }
+
+ if(!objectCached && !endpoints.empty())
+ {
+ _table->addProxy(ref->getIdentity(), object);
+ }
+
+ cached = objectCached || endpointsCached;
+ }
}
catch(const AdapterNotFoundException&)
{
- if(ref->getInstance()->traceLevels()->location >= 1)
- {
- Trace out(ref->getInstance()->initializationData().logger,
- ref->getInstance()->traceLevels()->locationCat);
- out << "adapter not found" << "\n";
- out << "adapter = " << ref->getAdapterId();
+ if(ref->getInstance()->traceLevels()->location >= 1)
+ {
+ Trace out(ref->getInstance()->initializationData().logger,
+ ref->getInstance()->traceLevels()->locationCat);
+ out << "adapter not found" << "\n";
+ out << "adapter = " << ref->getAdapterId();
}
- NotRegisteredException ex(__FILE__, __LINE__);
- ex.kindOfObject = "object adapter";
- ex.id = ref->getAdapterId();
- throw ex;
+ NotRegisteredException ex(__FILE__, __LINE__);
+ ex.kindOfObject = "object adapter";
+ ex.id = ref->getAdapterId();
+ throw ex;
}
catch(const ObjectNotFoundException&)
{
- if(ref->getInstance()->traceLevels()->location >= 1)
- {
- Trace out(ref->getInstance()->initializationData().logger,
- ref->getInstance()->traceLevels()->locationCat);
- out << "object not found" << "\n";
- out << "object = " << ref->getInstance()->identityToString(ref->getIdentity());
+ if(ref->getInstance()->traceLevels()->location >= 1)
+ {
+ Trace out(ref->getInstance()->initializationData().logger,
+ ref->getInstance()->traceLevels()->locationCat);
+ out << "object not found" << "\n";
+ out << "object = " << ref->getInstance()->identityToString(ref->getIdentity());
}
- NotRegisteredException ex(__FILE__, __LINE__);
- ex.kindOfObject = "object";
- ex.id = ref->getInstance()->identityToString(ref->getIdentity());
- throw ex;
+ NotRegisteredException ex(__FILE__, __LINE__);
+ ex.kindOfObject = "object";
+ ex.id = ref->getInstance()->identityToString(ref->getIdentity());
+ throw ex;
}
catch(const NotRegisteredException&)
{
- throw;
+ throw;
}
catch(const LocalException& ex)
{
- if(ref->getInstance()->traceLevels()->location >= 1)
- {
- Trace out(ref->getInstance()->initializationData().logger,
- ref->getInstance()->traceLevels()->locationCat);
- out << "couldn't contact the locator to retrieve adapter endpoints\n";
- if(ref->getAdapterId().empty())
- {
- out << "object = " << ref->getInstance()->identityToString(ref->getIdentity()) << "\n";
- }
- else
- {
- out << "adapter = " << ref->getAdapterId() << "\n";
- }
- out << "reason = " << ex;
- }
- throw;
+ if(ref->getInstance()->traceLevels()->location >= 1)
+ {
+ Trace out(ref->getInstance()->initializationData().logger,
+ ref->getInstance()->traceLevels()->locationCat);
+ out << "couldn't contact the locator to retrieve adapter endpoints\n";
+ if(ref->getAdapterId().empty())
+ {
+ out << "object = " << ref->getInstance()->identityToString(ref->getIdentity()) << "\n";
+ }
+ else
+ {
+ out << "adapter = " << ref->getAdapterId() << "\n";
+ }
+ out << "reason = " << ex;
+ }
+ throw;
}
if(ref->getInstance()->traceLevels()->location >= 1)
{
if(!endpoints.empty())
- {
- if(cached)
- {
- trace("found endpoints in locator table", ref, endpoints);
- }
- else
- {
- trace("retrieved endpoints from locator, adding to locator table", ref, endpoints);
- }
- }
- else
- {
- Trace out(ref->getInstance()->initializationData().logger, ref->getInstance()->traceLevels()->locationCat);
- out << "no endpoints configured for ";
- if(ref->getAdapterId().empty())
- {
- out << "object\n";
- out << "object = " << ref->getInstance()->identityToString(ref->getIdentity());
- }
- else
- {
- out << "adapter\n";
- out << "adapter = " << ref->getAdapterId();
- }
- }
+ {
+ if(cached)
+ {
+ trace("found endpoints in locator table", ref, endpoints);
+ }
+ else
+ {
+ trace("retrieved endpoints from locator, adding to locator table", ref, endpoints);
+ }
+ }
+ else
+ {
+ Trace out(ref->getInstance()->initializationData().logger, ref->getInstance()->traceLevels()->locationCat);
+ out << "no endpoints configured for ";
+ if(ref->getAdapterId().empty())
+ {
+ out << "object\n";
+ out << "object = " << ref->getInstance()->identityToString(ref->getIdentity());
+ }
+ else
+ {
+ out << "adapter\n";
+ out << "adapter = " << ref->getAdapterId();
+ }
+ }
}
return endpoints;
@@ -472,25 +472,25 @@ IceInternal::LocatorInfo::clearObjectCache(const IndirectReferencePtr& ref)
{
if(ref->getAdapterId().empty())
{
- ObjectPrx object = _table->removeProxy(ref->getIdentity());
- if(object)
- {
- IndirectReferencePtr oir = IndirectReferencePtr::dynamicCast(object->__reference());
- if(oir)
- {
- if(!oir->getAdapterId().empty())
- {
- clearCache(oir);
- }
- }
- else
- {
- if(ref->getInstance()->traceLevels()->location >= 2)
- {
- trace("removed endpoints from locator table", ref, object->__reference()->getEndpoints());
- }
- }
- }
+ ObjectPrx object = _table->removeProxy(ref->getIdentity());
+ if(object)
+ {
+ IndirectReferencePtr oir = IndirectReferencePtr::dynamicCast(object->__reference());
+ if(oir)
+ {
+ if(!oir->getAdapterId().empty())
+ {
+ clearCache(oir);
+ }
+ }
+ else
+ {
+ if(ref->getInstance()->traceLevels()->location >= 2)
+ {
+ trace("removed endpoints from locator table", ref, object->__reference()->getEndpoints());
+ }
+ }
+ }
}
}
@@ -499,56 +499,56 @@ IceInternal::LocatorInfo::clearCache(const IndirectReferencePtr& ref)
{
if(!ref->getAdapterId().empty())
{
- vector<EndpointIPtr> endpoints = _table->removeAdapterEndpoints(ref->getAdapterId());
+ vector<EndpointIPtr> endpoints = _table->removeAdapterEndpoints(ref->getAdapterId());
- if(!endpoints.empty() && ref->getInstance()->traceLevels()->location >= 2)
- {
- trace("removed endpoints from locator table", ref, endpoints);
- }
+ if(!endpoints.empty() && ref->getInstance()->traceLevels()->location >= 2)
+ {
+ trace("removed endpoints from locator table", ref, endpoints);
+ }
}
else
{
- ObjectPrx object = _table->removeProxy(ref->getIdentity());
- if(object)
- {
- IndirectReferencePtr oir = IndirectReferencePtr::dynamicCast(object->__reference());
- if(oir)
- {
- if(!oir->getAdapterId().empty())
- {
- clearCache(oir);
- }
- }
- else
- {
- if(ref->getInstance()->traceLevels()->location >= 2)
- {
- trace("removed endpoints from locator table", ref, object->__reference()->getEndpoints());
- }
- }
- }
+ ObjectPrx object = _table->removeProxy(ref->getIdentity());
+ if(object)
+ {
+ IndirectReferencePtr oir = IndirectReferencePtr::dynamicCast(object->__reference());
+ if(oir)
+ {
+ if(!oir->getAdapterId().empty())
+ {
+ clearCache(oir);
+ }
+ }
+ else
+ {
+ if(ref->getInstance()->traceLevels()->location >= 2)
+ {
+ trace("removed endpoints from locator table", ref, object->__reference()->getEndpoints());
+ }
+ }
+ }
}
}
void
IceInternal::LocatorInfo::trace(const string& msg,
- const IndirectReferencePtr& ref,
- const vector<EndpointIPtr>& endpoints)
+ const IndirectReferencePtr& ref,
+ const vector<EndpointIPtr>& endpoints)
{
Trace out(ref->getInstance()->initializationData().logger, ref->getInstance()->traceLevels()->locationCat);
out << msg << '\n';
if(!ref->getAdapterId().empty())
{
- out << "adapter = " << ref->getAdapterId() << '\n';
+ out << "adapter = " << ref->getAdapterId() << '\n';
}
else
{
- out << "object = " << ref->getInstance()->identityToString(ref->getIdentity()) << '\n';
+ out << "object = " << ref->getInstance()->identityToString(ref->getIdentity()) << '\n';
}
const char* sep = endpoints.size() > 1 ? ":" : "";
ostringstream o;
transform(endpoints.begin(), endpoints.end(), ostream_iterator<string>(o, sep),
- Ice::constMemFun(&Endpoint::toString));
+ Ice::constMemFun(&Endpoint::toString));
out << "endpoints = " << o.str();
}
diff --git a/cpp/src/Ice/LoggerI.cpp b/cpp/src/Ice/LoggerI.cpp
index d347e221d91..8e4aef6f8fa 100644
--- a/cpp/src/Ice/LoggerI.cpp
+++ b/cpp/src/Ice/LoggerI.cpp
@@ -21,7 +21,7 @@ Ice::LoggerI::LoggerI(const string& prefix)
{
if(!prefix.empty())
{
- _prefix = prefix + ": ";
+ _prefix = prefix + ": ";
}
}
@@ -46,8 +46,8 @@ Ice::LoggerI::trace(const string& category, const string& message)
string::size_type idx = 0;
while((idx = s.find("\n", idx)) != string::npos)
{
- s.insert(idx + 1, " ");
- ++idx;
+ s.insert(idx + 1, " ");
+ ++idx;
}
IceUtil::StaticMutex::Lock sync(outputMutex);
diff --git a/cpp/src/Ice/LoggerUtil.cpp b/cpp/src/Ice/LoggerUtil.cpp
index ca888e23688..6d6f907ee61 100644
--- a/cpp/src/Ice/LoggerUtil.cpp
+++ b/cpp/src/Ice/LoggerUtil.cpp
@@ -30,7 +30,7 @@ Ice::Print::flush()
string s = _str.str();
if(!s.empty())
{
- _logger->print(s);
+ _logger->print(s);
}
_str.str("");
}
@@ -64,7 +64,7 @@ Ice::Warning::flush()
string s = _str.str();
if(!s.empty())
{
- _logger->warning(s);
+ _logger->warning(s);
}
_str.str("");
}
@@ -98,7 +98,7 @@ Ice::Error::flush()
string s = _str.str();
if(!s.empty())
{
- _logger->error(s);
+ _logger->error(s);
}
_str.str("");
}
@@ -133,7 +133,7 @@ Ice::Trace::flush()
string s = _str.str();
if(!s.empty())
{
- _logger->trace(_category, s);
+ _logger->trace(_category, s);
}
_str.str("");
}
diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp
index 9cc42da481c..737f2f3f148 100644
--- a/cpp/src/Ice/Network.cpp
+++ b/cpp/src/Ice/Network.cpp
@@ -73,7 +73,7 @@ IceInternal::acceptInterrupted()
{
if(interrupted())
{
- return true;
+ return true;
}
#ifdef _WIN32
@@ -168,7 +168,7 @@ IceInternal::connectionLost()
errno == ENOTCONN ||
errno == ESHUTDOWN ||
errno == ECONNABORTED ||
- errno == EPIPE;
+ errno == EPIPE;
#endif
}
@@ -200,24 +200,24 @@ IceInternal::createSocket(bool udp)
if(udp)
{
- fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
}
else
{
- fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
+ fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
}
if(fd == INVALID_SOCKET)
{
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
if(!udp)
{
- setTcpNoDelay(fd);
- setKeepAlive(fd);
+ setTcpNoDelay(fd);
+ setKeepAlive(fd);
}
return fd;
@@ -230,18 +230,18 @@ IceInternal::closeSocket(SOCKET fd)
int error = WSAGetLastError();
if(closesocket(fd) == SOCKET_ERROR)
{
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
WSASetLastError(error);
#else
int error = errno;
if(close(fd) == SOCKET_ERROR)
{
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
errno = error;
#endif
@@ -266,29 +266,29 @@ IceInternal::shutdownSocketWrite(SOCKET fd)
{
if(shutdown(fd, SHUT_WR) == SOCKET_ERROR)
{
- //
- // Ignore errors indicating that we are shutdown already.
- //
+ //
+ // Ignore errors indicating that we are shutdown already.
+ //
#if defined(_WIN32)
- int error = WSAGetLastError();
- if(error == WSAENOTCONN)
- {
- return;
- }
+ int error = WSAGetLastError();
+ if(error == WSAENOTCONN)
+ {
+ return;
+ }
#elif defined(__APPLE__)
- if(errno == ENOTCONN || errno == EINVAL)
- {
- return;
- }
+ if(errno == ENOTCONN || errno == EINVAL)
+ {
+ return;
+ }
#else
- if(errno == ENOTCONN)
- {
- return;
- }
+ if(errno == ENOTCONN)
+ {
+ return;
+ }
#endif
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
}
@@ -297,30 +297,30 @@ IceInternal::shutdownSocketReadWrite(SOCKET fd)
{
if(shutdown(fd, SHUT_RDWR) == SOCKET_ERROR)
{
- //
- // Ignore errors indicating that we are shutdown already.
- //
+ //
+ // Ignore errors indicating that we are shutdown already.
+ //
#if defined(_WIN32)
- int error = WSAGetLastError();
- if(error == WSAENOTCONN)
- {
- return;
- }
+ int error = WSAGetLastError();
+ if(error == WSAENOTCONN)
+ {
+ return;
+ }
#elif defined(__APPLE__)
- if(errno == ENOTCONN || errno == EINVAL)
- {
- return;
- }
+ if(errno == ENOTCONN || errno == EINVAL)
+ {
+ return;
+ }
#else
- if(errno == ENOTCONN)
- {
- return;
- }
+ if(errno == ENOTCONN)
+ {
+ return;
+ }
#endif
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
}
@@ -330,47 +330,47 @@ IceInternal::setBlock(SOCKET fd, bool block)
if(block)
{
#ifdef _WIN32
- unsigned long arg = 0;
- if(ioctlsocket(fd, FIONBIO, &arg) == SOCKET_ERROR)
- {
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = WSAGetLastError();
- throw ex;
- }
+ unsigned long arg = 0;
+ if(ioctlsocket(fd, FIONBIO, &arg) == SOCKET_ERROR)
+ {
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = WSAGetLastError();
+ throw ex;
+ }
#else
- int flags = fcntl(fd, F_GETFL);
- flags &= ~O_NONBLOCK;
- if(fcntl(fd, F_SETFL, flags) == SOCKET_ERROR)
- {
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = errno;
- throw ex;
- }
+ int flags = fcntl(fd, F_GETFL);
+ flags &= ~O_NONBLOCK;
+ if(fcntl(fd, F_SETFL, flags) == SOCKET_ERROR)
+ {
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = errno;
+ throw ex;
+ }
#endif
}
else
{
#ifdef _WIN32
- unsigned long arg = 1;
- if(ioctlsocket(fd, FIONBIO, &arg) == SOCKET_ERROR)
- {
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = WSAGetLastError();
- throw ex;
- }
+ unsigned long arg = 1;
+ if(ioctlsocket(fd, FIONBIO, &arg) == SOCKET_ERROR)
+ {
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = WSAGetLastError();
+ throw ex;
+ }
#else
- int flags = fcntl(fd, F_GETFL);
- flags |= O_NONBLOCK;
- if(fcntl(fd, F_SETFL, flags) == SOCKET_ERROR)
- {
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = errno;
- throw ex;
- }
+ int flags = fcntl(fd, F_GETFL);
+ flags |= O_NONBLOCK;
+ if(fcntl(fd, F_SETFL, flags) == SOCKET_ERROR)
+ {
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = errno;
+ throw ex;
+ }
#endif
}
}
@@ -381,10 +381,10 @@ IceInternal::setTcpNoDelay(SOCKET fd)
int flag = 1;
if(setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char*)&flag, int(sizeof(int))) == SOCKET_ERROR)
{
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
}
@@ -394,10 +394,10 @@ IceInternal::setKeepAlive(SOCKET fd)
int flag = 1;
if(setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (char*)&flag, int(sizeof(int))) == SOCKET_ERROR)
{
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
}
@@ -406,10 +406,10 @@ IceInternal::setSendBufferSize(SOCKET fd, int sz)
{
if(setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char*)&sz, int(sizeof(int))) == SOCKET_ERROR)
{
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
}
@@ -420,10 +420,10 @@ IceInternal::getSendBufferSize(SOCKET fd)
socklen_t len = sizeof(sz);
if(getsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char*)&sz, &len) == SOCKET_ERROR || len != sizeof(sz))
{
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
return sz;
}
@@ -433,10 +433,10 @@ IceInternal::setRecvBufferSize(SOCKET fd, int sz)
{
if(setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char*)&sz, int(sizeof(int))) == SOCKET_ERROR)
{
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
}
@@ -447,10 +447,10 @@ IceInternal::getRecvBufferSize(SOCKET fd)
socklen_t len = sizeof(sz);
if(getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char*)&sz, &len) == SOCKET_ERROR || len != sizeof(sz))
{
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
return sz;
}
@@ -462,19 +462,19 @@ IceInternal::doBind(SOCKET fd, struct sockaddr_in& addr)
int flag = 1;
if(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char*)&flag, int(sizeof(int))) == SOCKET_ERROR)
{
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
#endif
if(bind(fd, reinterpret_cast<struct sockaddr*>(&addr), int(sizeof(addr))) == SOCKET_ERROR)
{
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
socklen_t len = static_cast<socklen_t>(sizeof(addr));
@@ -492,15 +492,15 @@ IceInternal::doListen(SOCKET fd, int backlog)
repeatListen:
if(::listen(fd, backlog) == SOCKET_ERROR)
{
- if(interrupted())
- {
- goto repeatListen;
- }
-
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ if(interrupted())
+ {
+ goto repeatListen;
+ }
+
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
}
@@ -522,173 +522,173 @@ IceInternal::doConnect(SOCKET fd, struct sockaddr_in& addr, int timeout)
WSAEVENT event = WSACreateEvent();
if(event == 0)
{
- closeSocketNoThrow(fd);
+ closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = WSAGetLastError();
- throw ex;
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = WSAGetLastError();
+ throw ex;
}
if(WSAEventSelect(fd, event, FD_CONNECT) == SOCKET_ERROR)
{
- int error = WSAGetLastError();
+ int error = WSAGetLastError();
- WSACloseEvent(event);
- closeSocketNoThrow(fd);
+ WSACloseEvent(event);
+ closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = error;
- throw ex;
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = error;
+ throw ex;
}
#endif
repeatConnect:
if(::connect(fd, reinterpret_cast<struct sockaddr*>(&addr), int(sizeof(addr))) == SOCKET_ERROR)
{
- if(interrupted())
- {
- goto repeatConnect;
- }
-
- if(connectInProgress())
- {
- int val;
+ if(interrupted())
+ {
+ goto repeatConnect;
+ }
+
+ if(connectInProgress())
+ {
+ int val;
#ifdef _WIN32
- WSAEVENT events[1];
- events[0] = event;
- long tout = (timeout >= 0) ? timeout : WSA_INFINITE;
- DWORD rc = WSAWaitForMultipleEvents(1, events, FALSE, tout, FALSE);
- if(rc == WSA_WAIT_FAILED)
- {
- int error = WSAGetLastError();
-
- WSACloseEvent(event);
- closeSocketNoThrow(fd);
-
- SocketException ex(__FILE__, __LINE__);
- ex.error = error;
- throw ex;
- }
-
- if(rc == WSA_WAIT_TIMEOUT)
- {
- WSACloseEvent(event);
- closeSocketNoThrow(fd);
-
- assert(timeout >= 0);
- throw ConnectTimeoutException(__FILE__, __LINE__);
- }
- assert(rc == WSA_WAIT_EVENT_0);
-
- WSANETWORKEVENTS nevents;
- if(WSAEnumNetworkEvents(fd, event, &nevents) == SOCKET_ERROR)
- {
- int error = WSAGetLastError();
- WSACloseEvent(event);
- closeSocketNoThrow(fd);
-
- SocketException ex(__FILE__, __LINE__);
- ex.error = error;
- throw ex;
- }
-
- //
- // Now we close the event, because we're finished and
- // this code be repeated.
- //
- WSACloseEvent(event);
-
- assert(nevents.lNetworkEvents & FD_CONNECT);
- val = nevents.iErrorCode[FD_CONNECT_BIT];
+ WSAEVENT events[1];
+ events[0] = event;
+ long tout = (timeout >= 0) ? timeout : WSA_INFINITE;
+ DWORD rc = WSAWaitForMultipleEvents(1, events, FALSE, tout, FALSE);
+ if(rc == WSA_WAIT_FAILED)
+ {
+ int error = WSAGetLastError();
+
+ WSACloseEvent(event);
+ closeSocketNoThrow(fd);
+
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = error;
+ throw ex;
+ }
+
+ if(rc == WSA_WAIT_TIMEOUT)
+ {
+ WSACloseEvent(event);
+ closeSocketNoThrow(fd);
+
+ assert(timeout >= 0);
+ throw ConnectTimeoutException(__FILE__, __LINE__);
+ }
+ assert(rc == WSA_WAIT_EVENT_0);
+
+ WSANETWORKEVENTS nevents;
+ if(WSAEnumNetworkEvents(fd, event, &nevents) == SOCKET_ERROR)
+ {
+ int error = WSAGetLastError();
+ WSACloseEvent(event);
+ closeSocketNoThrow(fd);
+
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = error;
+ throw ex;
+ }
+
+ //
+ // Now we close the event, because we're finished and
+ // this code be repeated.
+ //
+ WSACloseEvent(event);
+
+ assert(nevents.lNetworkEvents & FD_CONNECT);
+ val = nevents.iErrorCode[FD_CONNECT_BIT];
#else
- repeatPoll:
- struct pollfd pollFd[1];
- pollFd[0].fd = fd;
- pollFd[0].events = POLLOUT;
- int ret = ::poll(pollFd, 1, timeout);
- if(ret == 0)
- {
- closeSocketNoThrow(fd);
- throw ConnectTimeoutException(__FILE__, __LINE__);
- }
- else if(ret == SOCKET_ERROR)
- {
- if(interrupted())
- {
- goto repeatPoll;
- }
-
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
-
- //
- // Strange windows bug: The following call to Sleep() is
- // necessary, otherwise no error is reported through
- // getsockopt.
- //
- //Sleep(0);
- socklen_t len = static_cast<socklen_t>(sizeof(int));
- if(getsockopt(fd, SOL_SOCKET, SO_ERROR, reinterpret_cast<char*>(&val), &len) == SOCKET_ERROR)
- {
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
+ repeatPoll:
+ struct pollfd pollFd[1];
+ pollFd[0].fd = fd;
+ pollFd[0].events = POLLOUT;
+ int ret = ::poll(pollFd, 1, timeout);
+ if(ret == 0)
+ {
+ closeSocketNoThrow(fd);
+ throw ConnectTimeoutException(__FILE__, __LINE__);
+ }
+ else if(ret == SOCKET_ERROR)
+ {
+ if(interrupted())
+ {
+ goto repeatPoll;
+ }
+
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+
+ //
+ // Strange windows bug: The following call to Sleep() is
+ // necessary, otherwise no error is reported through
+ // getsockopt.
+ //
+ //Sleep(0);
+ socklen_t len = static_cast<socklen_t>(sizeof(int));
+ if(getsockopt(fd, SOL_SOCKET, SO_ERROR, reinterpret_cast<char*>(&val), &len) == SOCKET_ERROR)
+ {
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
#endif
-
- if(val > 0)
- {
- closeSocketNoThrow(fd);
+
+ if(val > 0)
+ {
+ closeSocketNoThrow(fd);
#ifdef _WIN32
- WSASetLastError(val);
+ WSASetLastError(val);
#else
- errno = val;
+ errno = val;
#endif
- if(connectionRefused())
- {
- ConnectionRefusedException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
- else if(connectFailed())
- {
- ConnectFailedException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
- else
- {
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
- }
-
- return;
- }
+ if(connectionRefused())
+ {
+ ConnectionRefusedException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+ else if(connectFailed())
+ {
+ ConnectFailedException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+ else
+ {
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+ }
+
+ return;
+ }
- closeSocketNoThrow(fd);
- if(connectionRefused())
- {
- ConnectionRefusedException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
- else if(connectFailed())
- {
- ConnectFailedException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
- else
- {
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
+ closeSocketNoThrow(fd);
+ if(connectionRefused())
+ {
+ ConnectionRefusedException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+ else if(connectFailed())
+ {
+ ConnectFailedException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+ else
+ {
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
}
}
@@ -704,60 +704,60 @@ IceInternal::doAccept(SOCKET fd, int timeout)
repeatAccept:
if((ret = ::accept(fd, 0, 0)) == INVALID_SOCKET)
{
- if(acceptInterrupted())
- {
- goto repeatAccept;
- }
-
- if(wouldBlock())
- {
- repeatSelect:
- int rs;
+ if(acceptInterrupted())
+ {
+ goto repeatAccept;
+ }
+
+ if(wouldBlock())
+ {
+ repeatSelect:
+ int rs;
#ifdef _WIN32
- fd_set fdSet;
- FD_ZERO(&fdSet);
- FD_SET(fd, &fdSet);
- if(timeout >= 0)
- {
- struct timeval tv;
- tv.tv_sec = timeout / 1000;
- tv.tv_usec = (timeout - tv.tv_sec * 1000) * 1000;
- rs = ::select(static_cast<int>(fd + 1), &fdSet, 0, 0, &tv);
- }
- else
- {
- rs = ::select(static_cast<int>(fd + 1), &fdSet, 0, 0, 0);
- }
+ fd_set fdSet;
+ FD_ZERO(&fdSet);
+ FD_SET(fd, &fdSet);
+ if(timeout >= 0)
+ {
+ struct timeval tv;
+ tv.tv_sec = timeout / 1000;
+ tv.tv_usec = (timeout - tv.tv_sec * 1000) * 1000;
+ rs = ::select(static_cast<int>(fd + 1), &fdSet, 0, 0, &tv);
+ }
+ else
+ {
+ rs = ::select(static_cast<int>(fd + 1), &fdSet, 0, 0, 0);
+ }
#else
- struct pollfd pollFd[1];
- pollFd[0].fd = fd;
- pollFd[0].events = POLLIN;
- rs = ::poll(pollFd, 1, timeout);
+ struct pollfd pollFd[1];
+ pollFd[0].fd = fd;
+ pollFd[0].events = POLLIN;
+ rs = ::poll(pollFd, 1, timeout);
#endif
-
- if(rs == SOCKET_ERROR)
- {
- if(interrupted())
- {
- goto repeatSelect;
- }
-
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
-
- if(rs == 0)
- {
- throw TimeoutException(__FILE__, __LINE__);
- }
-
- goto repeatAccept;
- }
-
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+
+ if(rs == SOCKET_ERROR)
+ {
+ if(interrupted())
+ {
+ goto repeatSelect;
+ }
+
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+
+ if(rs == 0)
+ {
+ throw TimeoutException(__FILE__, __LINE__);
+ }
+
+ goto repeatAccept;
+ }
+
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
setTcpNoDelay(ret);
@@ -786,59 +786,59 @@ IceInternal::getAddress(const string& host, int port, struct sockaddr_in& addr)
{
#ifdef _WIN32
- //
- // Windows XP has getaddrinfo(), but we don't want to require XP to run Ice.
- //
-
- //
- // gethostbyname() is thread safe on Windows, with a separate hostent per thread
- //
- struct hostent* entry;
- int retry = 5;
- do
- {
- entry = gethostbyname(host.c_str());
- }
- while(entry == 0 && WSAGetLastError() == WSATRY_AGAIN && --retry >= 0);
-
- if(entry == 0)
- {
- DNSException ex(__FILE__, __LINE__);
-
- ex.error = WSAGetLastError();
- ex.host = host;
- throw ex;
- }
- memcpy(&addr.sin_addr, entry->h_addr, entry->h_length);
+ //
+ // Windows XP has getaddrinfo(), but we don't want to require XP to run Ice.
+ //
+
+ //
+ // gethostbyname() is thread safe on Windows, with a separate hostent per thread
+ //
+ struct hostent* entry;
+ int retry = 5;
+ do
+ {
+ entry = gethostbyname(host.c_str());
+ }
+ while(entry == 0 && WSAGetLastError() == WSATRY_AGAIN && --retry >= 0);
+
+ if(entry == 0)
+ {
+ DNSException ex(__FILE__, __LINE__);
+
+ ex.error = WSAGetLastError();
+ ex.host = host;
+ throw ex;
+ }
+ memcpy(&addr.sin_addr, entry->h_addr, entry->h_length);
#else
- struct addrinfo* info = 0;
- int retry = 5;
-
- struct addrinfo hints = { 0 };
- hints.ai_family = PF_INET;
-
- int rs = 0;
- do
- {
- rs = getaddrinfo(host.c_str(), 0, &hints, &info);
- }
- while(info == 0 && rs == EAI_AGAIN && --retry >= 0);
-
- if(rs != 0)
- {
- DNSException ex(__FILE__, __LINE__);
- ex.error = rs;
- ex.host = host;
- throw ex;
- }
-
- assert(info->ai_family == PF_INET);
- struct sockaddr_in* sin = reinterpret_cast<sockaddr_in*>(info->ai_addr);
-
- addr.sin_addr.s_addr = sin->sin_addr.s_addr;
- freeaddrinfo(info);
+ struct addrinfo* info = 0;
+ int retry = 5;
+
+ struct addrinfo hints = { 0 };
+ hints.ai_family = PF_INET;
+
+ int rs = 0;
+ do
+ {
+ rs = getaddrinfo(host.c_str(), 0, &hints, &info);
+ }
+ while(info == 0 && rs == EAI_AGAIN && --retry >= 0);
+
+ if(rs != 0)
+ {
+ DNSException ex(__FILE__, __LINE__);
+ ex.error = rs;
+ ex.host = host;
+ throw ex;
+ }
+
+ assert(info->ai_family == PF_INET);
+ struct sockaddr_in* sin = reinterpret_cast<sockaddr_in*>(info->ai_addr);
+
+ addr.sin_addr.s_addr = sin->sin_addr.s_addr;
+ freeaddrinfo(info);
#endif
}
@@ -871,12 +871,12 @@ IceInternal::createPipe(SOCKET fds[2])
try
{
- fds[0] = createSocket(false);
+ fds[0] = createSocket(false);
}
catch(...)
{
- ::closesocket(fd);
- throw;
+ ::closesocket(fd);
+ throw;
}
try
@@ -886,19 +886,19 @@ IceInternal::createPipe(SOCKET fds[2])
}
catch(...)
{
- ::closesocket(fd);
- throw;
+ ::closesocket(fd);
+ throw;
}
try
{
- fds[1] = doAccept(fd, -1);
+ fds[1] = doAccept(fd, -1);
}
catch(...)
{
- ::closesocket(fds[0]);
- ::closesocket(fd);
- throw;
+ ::closesocket(fds[0]);
+ ::closesocket(fd);
+ throw;
}
::closesocket(fd);
@@ -909,18 +909,18 @@ IceInternal::createPipe(SOCKET fds[2])
}
catch(...)
{
- ::closesocket(fds[0]);
- ::closesocket(fd);
- throw;
+ ::closesocket(fds[0]);
+ ::closesocket(fd);
+ throw;
}
#else
if(::pipe(fds) != 0)
{
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
}
try
@@ -929,8 +929,8 @@ IceInternal::createPipe(SOCKET fds[2])
}
catch(...)
{
- closeSocketNoThrow(fds[1]);
- throw;
+ closeSocketNoThrow(fds[1]);
+ throw;
}
try
@@ -939,8 +939,8 @@ IceInternal::createPipe(SOCKET fds[2])
}
catch(...)
{
- closeSocketNoThrow(fds[0]);
- throw;
+ closeSocketNoThrow(fds[0]);
+ throw;
}
#endif
@@ -953,196 +953,196 @@ IceInternal::errorToString(int error)
{
if(error < WSABASEERR)
{
- LPVOID lpMsgBuf = 0;
- DWORD ok = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- error,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
- (LPTSTR)&lpMsgBuf,
- 0,
- NULL);
- if(ok)
- {
- LPCTSTR msg = (LPCTSTR)lpMsgBuf;
- assert(msg && strlen((const char*)msg) > 0);
- string result = (const char*)msg;
- if(result[result.length() - 1] == '\n')
- {
- result = result.substr(0, result.length() - 2);
- }
- LocalFree(lpMsgBuf);
- return result;
- }
- else
- {
- ostringstream os;
- os << "unknown error: " << error;
- return os.str();
- }
+ LPVOID lpMsgBuf = 0;
+ DWORD ok = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ error,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
+ (LPTSTR)&lpMsgBuf,
+ 0,
+ NULL);
+ if(ok)
+ {
+ LPCTSTR msg = (LPCTSTR)lpMsgBuf;
+ assert(msg && strlen((const char*)msg) > 0);
+ string result = (const char*)msg;
+ if(result[result.length() - 1] == '\n')
+ {
+ result = result.substr(0, result.length() - 2);
+ }
+ LocalFree(lpMsgBuf);
+ return result;
+ }
+ else
+ {
+ ostringstream os;
+ os << "unknown error: " << error;
+ return os.str();
+ }
}
switch(error)
{
case WSAEINTR:
- return "WSAEINTR";
-
+ return "WSAEINTR";
+
case WSAEBADF:
- return "WSAEBADF";
-
+ return "WSAEBADF";
+
case WSAEACCES:
- return "WSAEACCES";
-
+ return "WSAEACCES";
+
case WSAEFAULT:
- return "WSAEFAULT";
-
+ return "WSAEFAULT";
+
case WSAEINVAL:
- return "WSAEINVAL";
-
+ return "WSAEINVAL";
+
case WSAEMFILE:
- return "WSAEMFILE";
-
+ return "WSAEMFILE";
+
case WSAEWOULDBLOCK:
- return "WSAEWOULDBLOCK";
-
+ return "WSAEWOULDBLOCK";
+
case WSAEINPROGRESS:
- return "WSAEINPROGRESS";
-
+ return "WSAEINPROGRESS";
+
case WSAEALREADY:
- return "WSAEALREADY";
-
+ return "WSAEALREADY";
+
case WSAENOTSOCK:
- return "WSAENOTSOCK";
-
+ return "WSAENOTSOCK";
+
case WSAEDESTADDRREQ:
- return "WSAEDESTADDRREQ";
-
+ return "WSAEDESTADDRREQ";
+
case WSAEMSGSIZE:
- return "WSAEMSGSIZE";
-
+ return "WSAEMSGSIZE";
+
case WSAEPROTOTYPE:
- return "WSAEPROTOTYPE";
-
+ return "WSAEPROTOTYPE";
+
case WSAENOPROTOOPT:
- return "WSAENOPROTOOPT";
-
+ return "WSAENOPROTOOPT";
+
case WSAEPROTONOSUPPORT:
- return "WSAEPROTONOSUPPORT";
-
+ return "WSAEPROTONOSUPPORT";
+
case WSAESOCKTNOSUPPORT:
- return "WSAESOCKTNOSUPPORT";
-
+ return "WSAESOCKTNOSUPPORT";
+
case WSAEOPNOTSUPP:
- return "WSAEOPNOTSUPP";
-
+ return "WSAEOPNOTSUPP";
+
case WSAEPFNOSUPPORT:
- return "WSAEPFNOSUPPORT";
-
+ return "WSAEPFNOSUPPORT";
+
case WSAEAFNOSUPPORT:
- return "WSAEAFNOSUPPORT";
-
+ return "WSAEAFNOSUPPORT";
+
case WSAEADDRINUSE:
- return "WSAEADDRINUSE";
-
+ return "WSAEADDRINUSE";
+
case WSAEADDRNOTAVAIL:
- return "WSAEADDRNOTAVAIL";
-
+ return "WSAEADDRNOTAVAIL";
+
case WSAENETDOWN:
- return "WSAENETDOWN";
-
+ return "WSAENETDOWN";
+
case WSAENETUNREACH:
- return "WSAENETUNREACH";
-
+ return "WSAENETUNREACH";
+
case WSAENETRESET:
- return "WSAENETRESET";
-
+ return "WSAENETRESET";
+
case WSAECONNABORTED:
- return "WSAECONNABORTED";
-
+ return "WSAECONNABORTED";
+
case WSAECONNRESET:
- return "WSAECONNRESET";
-
+ return "WSAECONNRESET";
+
case WSAENOBUFS:
- return "WSAENOBUFS";
-
+ return "WSAENOBUFS";
+
case WSAEISCONN:
- return "WSAEISCONN";
-
+ return "WSAEISCONN";
+
case WSAENOTCONN:
- return "WSAENOTCONN";
-
+ return "WSAENOTCONN";
+
case WSAESHUTDOWN:
- return "WSAESHUTDOWN";
-
+ return "WSAESHUTDOWN";
+
case WSAETOOMANYREFS:
- return "WSAETOOMANYREFS";
-
+ return "WSAETOOMANYREFS";
+
case WSAETIMEDOUT:
- return "WSAETIMEDOUT";
-
+ return "WSAETIMEDOUT";
+
case WSAECONNREFUSED:
- return "WSAECONNREFUSED";
-
+ return "WSAECONNREFUSED";
+
case WSAELOOP:
- return "WSAELOOP";
-
+ return "WSAELOOP";
+
case WSAENAMETOOLONG:
- return "WSAENAMETOOLONG";
-
+ return "WSAENAMETOOLONG";
+
case WSAEHOSTDOWN:
- return "WSAEHOSTDOWN";
-
+ return "WSAEHOSTDOWN";
+
case WSAEHOSTUNREACH:
- return "WSAEHOSTUNREACH";
-
+ return "WSAEHOSTUNREACH";
+
case WSAENOTEMPTY:
- return "WSAENOTEMPTY";
-
+ return "WSAENOTEMPTY";
+
case WSAEPROCLIM:
- return "WSAEPROCLIM";
-
+ return "WSAEPROCLIM";
+
case WSAEUSERS:
- return "WSAEUSERS";
-
+ return "WSAEUSERS";
+
case WSAEDQUOT:
- return "WSAEDQUOT";
-
+ return "WSAEDQUOT";
+
case WSAESTALE:
- return "WSAESTALE";
-
+ return "WSAESTALE";
+
case WSAEREMOTE:
- return "WSAEREMOTE";
-
+ return "WSAEREMOTE";
+
case WSAEDISCON:
- return "WSAEDISCON";
-
+ return "WSAEDISCON";
+
case WSASYSNOTREADY:
- return "WSASYSNOTREADY";
-
+ return "WSASYSNOTREADY";
+
case WSAVERNOTSUPPORTED:
- return "WSAVERNOTSUPPORTED";
-
+ return "WSAVERNOTSUPPORTED";
+
case WSANOTINITIALISED:
- return "WSANOTINITIALISED";
-
+ return "WSANOTINITIALISED";
+
case WSAHOST_NOT_FOUND:
- return "WSAHOST_NOT_FOUND";
-
+ return "WSAHOST_NOT_FOUND";
+
case WSATRY_AGAIN:
- return "WSATRY_AGAIN";
-
+ return "WSATRY_AGAIN";
+
case WSANO_RECOVERY:
- return "WSANO_RECOVERY";
-
+ return "WSANO_RECOVERY";
+
case WSANO_DATA:
- return "WSANO_DATA";
+ return "WSANO_DATA";
default:
{
- ostringstream os;
- os << "unknown socket error: " << error;
- return os.str();
+ ostringstream os;
+ os << "unknown socket error: " << error;
+ return os.str();
}
}
}
@@ -1184,7 +1184,7 @@ IceInternal::fdToString(SOCKET fd)
{
if(fd == INVALID_SOCKET)
{
- return "<closed>";
+ return "<closed>";
}
struct sockaddr_in localAddr;
@@ -1197,11 +1197,11 @@ IceInternal::fdToString(SOCKET fd)
s << "local address = " << addrToString(localAddr);
if(peerConnected)
{
- s << "\nremote address = " << addrToString(remoteAddr);
+ s << "\nremote address = " << addrToString(remoteAddr);
}
else
{
- s << "\nremote address = <not connected>";
+ s << "\nremote address = <not connected>";
}
return s.str();
}
@@ -1212,10 +1212,10 @@ IceInternal::fdToLocalAddress(SOCKET fd, struct sockaddr_in& addr)
socklen_t len = static_cast<socklen_t>(sizeof(struct sockaddr_in));
if(getsockname(fd, reinterpret_cast<struct sockaddr*>(&addr), &len) == SOCKET_ERROR)
{
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
}
@@ -1225,17 +1225,17 @@ IceInternal::fdToRemoteAddress(SOCKET fd, struct sockaddr_in& addr)
socklen_t len = static_cast<socklen_t>(sizeof(struct sockaddr_in));
if(getpeername(fd, reinterpret_cast<struct sockaddr*>(&addr), &len) == SOCKET_ERROR)
{
- if(notConnected())
- {
- return false;
- }
- else
- {
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
+ if(notConnected())
+ {
+ return false;
+ }
+ else
+ {
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
}
return true;
@@ -1275,10 +1275,10 @@ IceInternal::getLocalHosts()
if(curr->ifa_addr && curr->ifa_addr->sa_family == AF_INET)
{
struct sockaddr_in* addr = reinterpret_cast<struct sockaddr_in*>(curr->ifa_addr);
- if(addr->sin_addr.s_addr != 0)
- {
- result.push_back(inetAddrToString((*addr).sin_addr));
- }
+ if(addr->sin_addr.s_addr != 0)
+ {
+ result.push_back(inetAddrToString((*addr).sin_addr));
+ }
}
curr = curr->ifa_next;
@@ -1312,17 +1312,17 @@ IceInternal::getLocalHosts()
int rs = ioctl(fd, cmd, &ifc);
if(rs == SOCKET_ERROR)
{
- free(ifc.ifc_buf);
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ free(ifc.ifc_buf);
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
else if(ifc.ifc_len == old_ifc_len)
{
//
- // Returned same length twice in a row, finished.
- //
+ // Returned same length twice in a row, finished.
+ //
break;
}
else
@@ -1341,10 +1341,10 @@ IceInternal::getLocalHosts()
if(ifr[i].ifr_addr.sa_family == AF_INET)
{
struct sockaddr_in* addr = reinterpret_cast<struct sockaddr_in*>(&ifr[i].ifr_addr);
- if(addr->sin_addr.s_addr != 0)
- {
- result.push_back(inetAddrToString((*addr).sin_addr));
- }
+ if(addr->sin_addr.s_addr != 0)
+ {
+ result.push_back(inetAddrToString((*addr).sin_addr));
+ }
}
}
@@ -1368,8 +1368,8 @@ IceInternal::getLocalAddresses()
buffer.resize(1024);
unsigned long len = 0;
DWORD rs = WSAIoctl(fd, SIO_ADDRESS_LIST_QUERY, 0, 0,
- &buffer[0], static_cast<DWORD>(buffer.size()),
- &len, 0, 0);
+ &buffer[0], static_cast<DWORD>(buffer.size()),
+ &len, 0, 0);
if(rs == SOCKET_ERROR)
{
//
@@ -1380,8 +1380,8 @@ IceInternal::getLocalAddresses()
{
buffer.resize(len);
rs = WSAIoctl(fd, SIO_ADDRESS_LIST_QUERY, 0, 0,
- &buffer[0], static_cast<DWORD>(buffer.size()),
- &len, 0, 0);
+ &buffer[0], static_cast<DWORD>(buffer.size()),
+ &len, 0, 0);
}
if(rs == SOCKET_ERROR)
@@ -1433,17 +1433,17 @@ IceInternal::isLocalAddress(const struct sockaddr_in& addr)
vector<struct sockaddr_in> localAddrs = getLocalAddresses();
for(vector<struct sockaddr_in>::const_iterator p = localAddrs.begin(); p != localAddrs.end(); ++p)
{
- if(compareAddress(addr0, *p))
- {
- return true;
- }
+ if(compareAddress(addr0, *p))
+ {
+ return true;
+ }
}
}
catch(const Ice::LocalException&)
{
- //
- // TODO: Warning?
- //
+ //
+ // TODO: Warning?
+ //
}
return false;
}
@@ -1455,17 +1455,17 @@ IceInternal::isPeerLocal(SOCKET fd)
struct sockaddr_in remoteAddr;
if(getpeername(fd, reinterpret_cast<struct sockaddr*>(&remoteAddr), &remoteLen) == SOCKET_ERROR)
{
- if(notConnected())
- {
- return false;
- }
- else
- {
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
+ if(notConnected())
+ {
+ return false;
+ }
+ else
+ {
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
}
return isLocalAddress(remoteAddr);
}
diff --git a/cpp/src/Ice/Object.cpp b/cpp/src/Ice/Object.cpp
index dd6a5d86cd9..34e00c0cae8 100644
--- a/cpp/src/Ice/Object.cpp
+++ b/cpp/src/Ice/Object.cpp
@@ -152,31 +152,31 @@ DispatchStatus
Ice::Object::__dispatch(Incoming& in, const Current& current)
{
pair<string*, string*> r =
- equal_range(__all, __all + sizeof(__all) / sizeof(string), current.operation);
+ equal_range(__all, __all + sizeof(__all) / sizeof(string), current.operation);
if(r.first == r.second)
{
- return DispatchOperationNotExist;
- }
+ return DispatchOperationNotExist;
+ }
switch(r.first - __all)
{
case 0:
{
- return ___ice_id(in, current);
+ return ___ice_id(in, current);
}
case 1:
{
- return ___ice_ids(in, current);
+ return ___ice_ids(in, current);
}
case 2:
- {
- return ___ice_isA(in, current);
- }
- case 3:
- {
- return ___ice_ping(in, current);
- }
+ {
+ return ___ice_isA(in, current);
+ }
+ case 3:
+ {
+ return ___ice_ping(in, current);
+ }
}
assert(false);
@@ -197,8 +197,8 @@ Ice::Object::__read(BasicStream* __is, bool __rid)
{
if(__rid)
{
- string myId;
- __is->readTypeId(myId);
+ string myId;
+ __is->readTypeId(myId);
}
__is->startReadSlice();
@@ -208,7 +208,7 @@ Ice::Object::__read(BasicStream* __is, bool __rid)
__is->readSize(sz);
if(sz != 0)
{
- throw Ice::MarshalException(__FILE__, __LINE__);
+ throw Ice::MarshalException(__FILE__, __LINE__);
}
__is->endReadSlice();
@@ -228,7 +228,7 @@ Ice::Object::__read(const InputStreamPtr& __inS, bool __rid)
{
if(__rid)
{
- __inS->readTypeId();
+ __inS->readTypeId();
}
__inS->startSlice();
@@ -237,7 +237,7 @@ Ice::Object::__read(const InputStreamPtr& __inS, bool __rid)
Int sz = __inS->readSize();
if(sz != 0)
{
- throw Ice::MarshalException(__FILE__, __LINE__);
+ throw Ice::MarshalException(__FILE__, __LINE__);
}
__inS->endSlice();
@@ -256,13 +256,13 @@ operationModeToString(OperationMode mode)
switch(mode)
{
case Normal:
- return "::Ice::Normal";
+ return "::Ice::Normal";
case Nonmutating:
- return "::Ice::Nonmutating";
+ return "::Ice::Nonmutating";
case Idempotent:
- return "::Ice::Idempotent";
+ return "::Ice::Idempotent";
}
ostringstream os;
@@ -275,29 +275,29 @@ Ice::Object::__checkMode(OperationMode expected, OperationMode received)
{
if(expected != received)
{
- if(expected == Idempotent && received == Nonmutating)
- {
- //
- // Fine: typically an old client still using the deprecated nonmutating keyword
- //
-
- //
- // Note that expected == Nonmutating and received == Idempotent is not ok:
- // the server may still use the deprecated nonmutating keyword to detect updates
- // and the client should not break this (deprecated) feature.
- //
- }
- else
- {
- Ice::MarshalException ex(__FILE__, __LINE__);
- std::ostringstream __reason;
- __reason << "unexpected operation mode. expected = "
- << operationModeToString(expected)
- << " received = "
- << operationModeToString(received);
- ex.reason = __reason.str();
- throw ex;
- }
+ if(expected == Idempotent && received == Nonmutating)
+ {
+ //
+ // Fine: typically an old client still using the deprecated nonmutating keyword
+ //
+
+ //
+ // Note that expected == Nonmutating and received == Idempotent is not ok:
+ // the server may still use the deprecated nonmutating keyword to detect updates
+ // and the client should not break this (deprecated) feature.
+ //
+ }
+ else
+ {
+ Ice::MarshalException ex(__FILE__, __LINE__);
+ std::ostringstream __reason;
+ __reason << "unexpected operation mode. expected = "
+ << operationModeToString(expected)
+ << " received = "
+ << operationModeToString(received);
+ ex.reason = __reason.str();
+ throw ex;
+ }
}
}
@@ -312,11 +312,11 @@ Ice::Blobject::__dispatch(Incoming& in, const Current& current)
in.os()->writeBlob(outParams);
if(ok)
{
- return DispatchOK;
+ return DispatchOK;
}
else
{
- return DispatchUserException;
+ return DispatchUserException;
}
}
@@ -332,11 +332,11 @@ Ice::BlobjectArray::__dispatch(Incoming& in, const Current& current)
in.os()->writeBlob(outParams);
if(ok)
{
- return DispatchOK;
+ return DispatchOK;
}
else
{
- return DispatchUserException;
+ return DispatchUserException;
}
}
@@ -349,19 +349,19 @@ Ice::BlobjectAsync::__dispatch(Incoming& in, const Current& current)
AMD_Object_ice_invokePtr cb = new ::IceAsync::Ice::AMD_Object_ice_invoke(in);
try
{
- ice_invoke_async(cb, inParams, current);
+ ice_invoke_async(cb, inParams, current);
}
catch(const Exception& ex)
{
- cb->ice_exception(ex);
+ cb->ice_exception(ex);
}
catch(const ::std::exception& ex)
{
- cb->ice_exception(ex);
+ cb->ice_exception(ex);
}
catch(...)
{
- cb->ice_exception();
+ cb->ice_exception();
}
return DispatchAsync;
}
@@ -376,19 +376,19 @@ Ice::BlobjectArrayAsync::__dispatch(Incoming& in, const Current& current)
AMD_Array_Object_ice_invokePtr cb = new ::IceAsync::Ice::AMD_Array_Object_ice_invoke(in);
try
{
- ice_invoke_async(cb, inParams, current);
+ ice_invoke_async(cb, inParams, current);
}
catch(const Exception& ex)
{
- cb->ice_exception(ex);
+ cb->ice_exception(ex);
}
catch(const ::std::exception& ex)
{
- cb->ice_exception(ex);
+ cb->ice_exception(ex);
}
catch(...)
{
- cb->ice_exception();
+ cb->ice_exception();
}
return DispatchAsync;
}
diff --git a/cpp/src/Ice/ObjectAdapterFactory.cpp b/cpp/src/Ice/ObjectAdapterFactory.cpp
index 8f93caf12a8..334be027f82 100644
--- a/cpp/src/Ice/ObjectAdapterFactory.cpp
+++ b/cpp/src/Ice/ObjectAdapterFactory.cpp
@@ -26,23 +26,23 @@ IceInternal::ObjectAdapterFactory::shutdown()
map<string, ObjectAdapterIPtr> adapters;
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
-
- //
- // Ignore shutdown requests if the object adapter factory has
- // already been shut down.
- //
- if(!_instance)
- {
- return;
- }
-
- adapters = _adapters;
-
- _instance = 0;
- _communicator = 0;
-
- notifyAll();
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+
+ //
+ // Ignore shutdown requests if the object adapter factory has
+ // already been shut down.
+ //
+ if(!_instance)
+ {
+ return;
+ }
+
+ adapters = _adapters;
+
+ _instance = 0;
+ _communicator = 0;
+
+ notifyAll();
}
//
@@ -50,48 +50,48 @@ IceInternal::ObjectAdapterFactory::shutdown()
// deadlocks.
//
for_each(adapters.begin(), adapters.end(),
- IceUtil::secondVoidMemFun<const string, ObjectAdapterI>(&ObjectAdapter::deactivate));
+ IceUtil::secondVoidMemFun<const string, ObjectAdapterI>(&ObjectAdapter::deactivate));
}
void
IceInternal::ObjectAdapterFactory::waitForShutdown()
{
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
-
- //
- // First we wait for the shutdown of the factory itself.
- //
- while(_instance)
- {
- wait();
- }
-
- //
- // If some other thread is currently shutting down, we wait
- // until this thread is finished.
- //
- while(_waitForShutdown)
- {
- wait();
- }
- _waitForShutdown = true;
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+
+ //
+ // First we wait for the shutdown of the factory itself.
+ //
+ while(_instance)
+ {
+ wait();
+ }
+
+ //
+ // If some other thread is currently shutting down, we wait
+ // until this thread is finished.
+ //
+ while(_waitForShutdown)
+ {
+ wait();
+ }
+ _waitForShutdown = true;
}
//
// Now we wait for deactivation of each object adapter.
//
for_each(_adapters.begin(), _adapters.end(),
- IceUtil::secondVoidMemFun<const string, ObjectAdapterI>(&ObjectAdapter::waitForDeactivate));
+ IceUtil::secondVoidMemFun<const string, ObjectAdapterI>(&ObjectAdapter::waitForDeactivate));
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
- //
- // Signal that waiting is complete.
- //
- _waitForShutdown = false;
- notifyAll();
+ //
+ // Signal that waiting is complete.
+ //
+ _waitForShutdown = false;
+ notifyAll();
}
}
@@ -114,41 +114,41 @@ IceInternal::ObjectAdapterFactory::destroy()
map<string, ObjectAdapterIPtr> adapters;
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
- adapters = _adapters;
- _adapters.clear();
+ adapters = _adapters;
+ _adapters.clear();
}
//
// Now we destroy each object adapter.
//
for_each(adapters.begin(), adapters.end(),
- IceUtil::secondVoidMemFun<const string, ObjectAdapterI>(&ObjectAdapter::destroy));
+ IceUtil::secondVoidMemFun<const string, ObjectAdapterI>(&ObjectAdapter::destroy));
}
ObjectAdapterPtr
IceInternal::ObjectAdapterFactory::createObjectAdapter(const string& name, const string& endpoints,
- const RouterPrx& router)
+ const RouterPrx& router)
{
IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
if(!_instance)
{
- throw ObjectAdapterDeactivatedException(__FILE__, __LINE__);
+ throw ObjectAdapterDeactivatedException(__FILE__, __LINE__);
}
map<string, ObjectAdapterIPtr>::iterator p = _adapters.find(name);
if(p != _adapters.end())
{
- throw AlreadyRegisteredException(__FILE__, __LINE__, "object adapter", name);
+ throw AlreadyRegisteredException(__FILE__, __LINE__, "object adapter", name);
}
if(name.empty() && (!endpoints.empty() || router != 0))
{
InitializationException ex(__FILE__, __LINE__);
- ex.reason = "Cannot configure endpoints or router with nameless object adapter";
- throw ex;
+ ex.reason = "Cannot configure endpoints or router with nameless object adapter";
+ throw ex;
}
ObjectAdapterIPtr adapter;
@@ -156,7 +156,7 @@ IceInternal::ObjectAdapterFactory::createObjectAdapter(const string& name, const
{
string uuid = IceUtil::generateUUID();
adapter = new ObjectAdapterI(_instance, _communicator, this, uuid, "", 0, true);
- _adapters.insert(make_pair(uuid, adapter));
+ _adapters.insert(make_pair(uuid, adapter));
}
else
{
@@ -173,22 +173,22 @@ IceInternal::ObjectAdapterFactory::findObjectAdapter(const ObjectPrx& proxy)
if(!_instance)
{
- return 0;
+ return 0;
}
for(map<string, ObjectAdapterIPtr>::iterator p = _adapters.begin(); p != _adapters.end(); ++p)
{
- try
- {
- if(p->second->isLocal(proxy))
- {
- return p->second;
- }
- }
- catch(const ObjectAdapterDeactivatedException&)
- {
- // Ignore.
- }
+ try
+ {
+ if(p->second->isLocal(proxy))
+ {
+ return p->second;
+ }
+ }
+ catch(const ObjectAdapterDeactivatedException&)
+ {
+ // Ignore.
+ }
}
return 0;
@@ -213,7 +213,7 @@ struct FlushAdapter
{
void operator() (ObjectAdapterIPtr p)
{
- p->flushBatchRequests();
+ p->flushBatchRequests();
}
};
@@ -224,18 +224,18 @@ IceInternal::ObjectAdapterFactory::flushBatchRequests() const
{
list<ObjectAdapterIPtr> a;
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
- for(map<string, ObjectAdapterIPtr>::const_iterator p = _adapters.begin(); p != _adapters.end(); ++p)
- {
- a.push_back(p->second);
- }
+ for(map<string, ObjectAdapterIPtr>::const_iterator p = _adapters.begin(); p != _adapters.end(); ++p)
+ {
+ a.push_back(p->second);
+ }
}
for_each(a.begin(), a.end(), FlushAdapter());
}
IceInternal::ObjectAdapterFactory::ObjectAdapterFactory(const InstancePtr& instance,
- const CommunicatorPtr& communicator) :
+ const CommunicatorPtr& communicator) :
_instance(instance),
_communicator(communicator),
_waitForShutdown(false)
diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp
index 483ad0542a3..b05a9697500 100644
--- a/cpp/src/Ice/ObjectAdapterI.cpp
+++ b/cpp/src/Ice/ObjectAdapterI.cpp
@@ -74,84 +74,84 @@ Ice::ObjectAdapterI::activate()
bool printAdapterReady = false;
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
-
- checkForDeactivation();
-
- //
- // If the one off initializations of the adapter are already
- // done, we just need to activate the incoming connection
- // factories and we're done.
- //
- if(_activateOneOffDone)
- {
- for_each(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(),
- Ice::voidMemFun(&IncomingConnectionFactory::activate));
- return;
- }
-
- //
- // One off initializations of the adapter: update the locator
- // registry and print the "adapter ready" message. We set the
- // _waitForActivate flag to prevent deactivation from other
- // threads while these one off initializations are done.
- //
- _waitForActivate = true;
-
- locatorInfo = _locatorInfo;
- if(!_noConfig)
- {
- PropertiesPtr properties = _instance->initializationData().properties;
- printAdapterReady = properties->getPropertyAsInt("Ice.PrintAdapterReady") > 0;
- //
- // DEPREACTED PROPERTY: Remove extra code in future release
- //
- registerProcess = properties->getPropertyAsIntWithDefault(_propertyPrefix + _name + ".RegisterProcess",
- properties->getPropertyAsInt(_name + ".RegisterProcess")) > 0;
- }
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+
+ checkForDeactivation();
+
+ //
+ // If the one off initializations of the adapter are already
+ // done, we just need to activate the incoming connection
+ // factories and we're done.
+ //
+ if(_activateOneOffDone)
+ {
+ for_each(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(),
+ Ice::voidMemFun(&IncomingConnectionFactory::activate));
+ return;
+ }
+
+ //
+ // One off initializations of the adapter: update the locator
+ // registry and print the "adapter ready" message. We set the
+ // _waitForActivate flag to prevent deactivation from other
+ // threads while these one off initializations are done.
+ //
+ _waitForActivate = true;
+
+ locatorInfo = _locatorInfo;
+ if(!_noConfig)
+ {
+ PropertiesPtr properties = _instance->initializationData().properties;
+ printAdapterReady = properties->getPropertyAsInt("Ice.PrintAdapterReady") > 0;
+ //
+ // DEPREACTED PROPERTY: Remove extra code in future release
+ //
+ registerProcess = properties->getPropertyAsIntWithDefault(_propertyPrefix + _name + ".RegisterProcess",
+ properties->getPropertyAsInt(_name + ".RegisterProcess")) > 0;
+ }
}
try
{
- Ice::Identity dummy;
- dummy.name = "dummy";
- updateLocatorRegistry(locatorInfo, createDirectProxy(dummy), registerProcess);
+ Ice::Identity dummy;
+ dummy.name = "dummy";
+ updateLocatorRegistry(locatorInfo, createDirectProxy(dummy), registerProcess);
}
catch(const Ice::LocalException&)
{
- //
- // If we couldn't update the locator registry, we let the
- // exception go through and don't activate the adapter to
- // allow to user code to retry activating the adapter
- // later.
- //
- {
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
- _waitForActivate = false;
- notifyAll();
- }
- throw;
+ //
+ // If we couldn't update the locator registry, we let the
+ // exception go through and don't activate the adapter to
+ // allow to user code to retry activating the adapter
+ // later.
+ //
+ {
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+ _waitForActivate = false;
+ notifyAll();
+ }
+ throw;
}
if(printAdapterReady)
{
- cout << _name << " ready" << endl;
+ cout << _name << " ready" << endl;
}
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
- assert(!_deactivated); // Not possible if _waitForActivate = true;
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+ assert(!_deactivated); // Not possible if _waitForActivate = true;
- //
- // Signal threads waiting for the activation.
- //
- _waitForActivate = false;
- notifyAll();
+ //
+ // Signal threads waiting for the activation.
+ //
+ _waitForActivate = false;
+ notifyAll();
- _activateOneOffDone = true;
+ _activateOneOffDone = true;
- for_each(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(),
- Ice::voidMemFun(&IncomingConnectionFactory::activate));
+ for_each(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(),
+ Ice::voidMemFun(&IncomingConnectionFactory::activate));
}
}
@@ -161,9 +161,9 @@ Ice::ObjectAdapterI::hold()
IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
checkForDeactivation();
-
+
for_each(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(),
- Ice::voidMemFun(&IncomingConnectionFactory::hold));
+ Ice::voidMemFun(&IncomingConnectionFactory::hold));
}
void
@@ -174,7 +174,7 @@ Ice::ObjectAdapterI::waitForHold()
checkForDeactivation();
for_each(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(),
- Ice::constVoidMemFun(&IncomingConnectionFactory::waitUntilHolding));
+ Ice::constVoidMemFun(&IncomingConnectionFactory::waitUntilHolding));
}
void
@@ -184,58 +184,58 @@ Ice::ObjectAdapterI::deactivate()
OutgoingConnectionFactoryPtr outgoingConnectionFactory;
LocatorInfoPtr locatorInfo;
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
-
- //
- // Ignore deactivation requests if the object adapter has already
- // been deactivated.
- //
- if(_deactivated)
- {
- return;
- }
-
- //
- // Wait for activation to complete. This is necessary to not
- // get out of order locator updates.
- //
- while(_waitForActivate)
- {
- wait();
- }
-
- if(_routerInfo)
- {
- //
- // Remove entry from the router manager.
- //
- _instance->routerManager()->erase(_routerInfo->getRouter());
-
- //
- // Clear this object adapter with the router.
- //
- _routerInfo->setAdapter(0);
- }
-
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+
+ //
+ // Ignore deactivation requests if the object adapter has already
+ // been deactivated.
+ //
+ if(_deactivated)
+ {
+ return;
+ }
+
+ //
+ // Wait for activation to complete. This is necessary to not
+ // get out of order locator updates.
+ //
+ while(_waitForActivate)
+ {
+ wait();
+ }
+
+ if(_routerInfo)
+ {
+ //
+ // Remove entry from the router manager.
+ //
+ _instance->routerManager()->erase(_routerInfo->getRouter());
+
+ //
+ // Clear this object adapter with the router.
+ //
+ _routerInfo->setAdapter(0);
+ }
+
incomingConnectionFactories = _incomingConnectionFactories;
- outgoingConnectionFactory = _instance->outgoingConnectionFactory();
- locatorInfo = _locatorInfo;
+ outgoingConnectionFactory = _instance->outgoingConnectionFactory();
+ locatorInfo = _locatorInfo;
- _deactivated = true;
+ _deactivated = true;
- notifyAll();
+ notifyAll();
}
try
{
- updateLocatorRegistry(locatorInfo, 0, false);
+ updateLocatorRegistry(locatorInfo, 0, false);
}
catch(const Ice::LocalException&)
{
- //
- // We can't throw exceptions in deactivate so we ignore
- // failures to update the locator registry.
- //
+ //
+ // We can't throw exceptions in deactivate so we ignore
+ // failures to update the locator registry.
+ //
}
//
@@ -244,7 +244,7 @@ Ice::ObjectAdapterI::deactivate()
// message.
//
for_each(incomingConnectionFactories.begin(), incomingConnectionFactories.end(),
- Ice::voidMemFun(&IncomingConnectionFactory::destroy));
+ Ice::voidMemFun(&IncomingConnectionFactory::destroy));
//
// Must be called outside the thread synchronization, because
@@ -260,23 +260,23 @@ Ice::ObjectAdapterI::waitForDeactivate()
vector<IceInternal::IncomingConnectionFactoryPtr> incomingConnectionFactories;
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
-
- if(_destroyed)
- {
- return;
- }
-
- //
- // Wait for deactivation of the adapter itself, and for
- // the return of all direct method calls using this adapter.
- //
- while(!_deactivated || _directCount > 0)
- {
- wait();
- }
-
- incomingConnectionFactories = _incomingConnectionFactories;
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+
+ if(_destroyed)
+ {
+ return;
+ }
+
+ //
+ // Wait for deactivation of the adapter itself, and for
+ // the return of all direct method calls using this adapter.
+ //
+ while(!_deactivated || _directCount > 0)
+ {
+ wait();
+ }
+
+ incomingConnectionFactories = _incomingConnectionFactories;
}
//
@@ -284,7 +284,7 @@ Ice::ObjectAdapterI::waitForDeactivate()
// finished.
//
for_each(incomingConnectionFactories.begin(), incomingConnectionFactories.end(),
- Ice::voidMemFun(&IncomingConnectionFactory::waitUntilFinished));
+ Ice::voidMemFun(&IncomingConnectionFactory::waitUntilFinished));
}
bool
@@ -299,26 +299,26 @@ void
Ice::ObjectAdapterI::destroy()
{
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
-
- //
- // Another thread is in the process of destroying the object
- // adapter. Wait for it to finish.
- //
- while(_destroying)
- {
- wait();
- }
-
- //
- // Object adpater is already destroyed.
- //
- if(_destroyed)
- {
- return;
- }
-
- _destroying = true;
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+
+ //
+ // Another thread is in the process of destroying the object
+ // adapter. Wait for it to finish.
+ //
+ while(_destroying)
+ {
+ wait();
+ }
+
+ //
+ // Object adpater is already destroyed.
+ //
+ if(_destroyed)
+ {
+ return;
+ }
+
+ _destroying = true;
}
//
@@ -338,41 +338,41 @@ Ice::ObjectAdapterI::destroy()
//
if(_threadPool)
{
- _threadPool->destroy();
- _threadPool->joinWithAllThreads();
+ _threadPool->destroy();
+ _threadPool->joinWithAllThreads();
}
ObjectAdapterFactoryPtr objectAdapterFactory;
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
-
- //
- // Signal that destroy is complete.
- //
- _destroying = false;
- _destroyed = true;
- notifyAll();
-
- //
- // We're done, now we can throw away all incoming connection
- // factories.
- //
- _incomingConnectionFactories.clear();
-
- //
- // Remove object references (some of them cyclic).
- //
- _instance = 0;
- _threadPool = 0;
- _communicator = 0;
- _routerEndpoints.clear();
- _routerInfo = 0;
- _publishedEndpoints.clear();
- _locatorInfo = 0;
-
- objectAdapterFactory = _objectAdapterFactory;
- _objectAdapterFactory = 0;
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+
+ //
+ // Signal that destroy is complete.
+ //
+ _destroying = false;
+ _destroyed = true;
+ notifyAll();
+
+ //
+ // We're done, now we can throw away all incoming connection
+ // factories.
+ //
+ _incomingConnectionFactories.clear();
+
+ //
+ // Remove object references (some of them cyclic).
+ //
+ _instance = 0;
+ _threadPool = 0;
+ _communicator = 0;
+ _routerEndpoints.clear();
+ _routerInfo = 0;
+ _publishedEndpoints.clear();
+ _locatorInfo = 0;
+
+ objectAdapterFactory = _objectAdapterFactory;
+ _objectAdapterFactory = 0;
}
if(objectAdapterFactory)
@@ -549,8 +549,8 @@ Ice::ObjectAdapterI::createReverseProxy(const Identity& ident) const
vector<IncomingConnectionFactoryPtr>::const_iterator p;
for(p = _incomingConnectionFactories.begin(); p != _incomingConnectionFactories.end(); ++p)
{
- list<ConnectionIPtr> cons = (*p)->connections();
- copy(cons.begin(), cons.end(), back_inserter(connections));
+ list<ConnectionIPtr> cons = (*p)->connections();
+ copy(cons.begin(), cons.end(), back_inserter(connections));
}
//
@@ -558,7 +558,7 @@ Ice::ObjectAdapterI::createReverseProxy(const Identity& ident) const
// reference.
//
ReferencePtr ref = _instance->referenceFactory()->create(ident, _instance->getDefaultContext(),
- "", Reference::ModeTwoway, connections);
+ "", Reference::ModeTwoway, connections);
return _instance->proxyFactory()->referenceToProxy(ref);
}
@@ -582,32 +582,32 @@ Ice::ObjectAdapterI::isLocal(const ObjectPrx& proxy) const
IndirectReferencePtr ir = IndirectReferencePtr::dynamicCast(ref);
if(ir)
{
- if(!ir->getAdapterId().empty())
- {
- //
- // Proxy is local if the reference adapter id matches this
- // adapter id.
- //
- return ir->getAdapterId() == _id;
- }
-
- //
- // Get Locator endpoint information for indirect references.
- //
- LocatorInfoPtr info = ir->getLocatorInfo();
- if(info)
- {
- bool isCached;
- endpoints = info->getEndpoints(ir, ir->getLocatorCacheTimeout(), isCached);
- }
- else
- {
- return false;
- }
+ if(!ir->getAdapterId().empty())
+ {
+ //
+ // Proxy is local if the reference adapter id matches this
+ // adapter id.
+ //
+ return ir->getAdapterId() == _id;
+ }
+
+ //
+ // Get Locator endpoint information for indirect references.
+ //
+ LocatorInfoPtr info = ir->getLocatorInfo();
+ if(info)
+ {
+ bool isCached;
+ endpoints = info->getEndpoints(ir, ir->getLocatorCacheTimeout(), isCached);
+ }
+ else
+ {
+ return false;
+ }
}
else
{
- endpoints = ref->getEndpoints();
+ endpoints = ref->getEndpoints();
}
IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
@@ -620,14 +620,14 @@ Ice::ObjectAdapterI::isLocal(const ObjectPrx& proxy) const
//
for(p = endpoints.begin(); p != endpoints.end(); ++p)
{
- vector<IncomingConnectionFactoryPtr>::const_iterator q;
- for(q = _incomingConnectionFactories.begin(); q != _incomingConnectionFactories.end(); ++q)
- {
- if((*q)->equivalent(*p))
- {
- return true;
- }
- }
+ vector<IncomingConnectionFactoryPtr>::const_iterator q;
+ for(q = _incomingConnectionFactories.begin(); q != _incomingConnectionFactories.end(); ++q)
+ {
+ if((*q)->equivalent(*p))
+ {
+ return true;
+ }
+ }
}
//
@@ -639,10 +639,10 @@ Ice::ObjectAdapterI::isLocal(const ObjectPrx& proxy) const
{
for(p = endpoints.begin(); p != endpoints.end(); ++p)
{
- if(binary_search(_routerEndpoints.begin(), _routerEndpoints.end(), *p)) // _routerEndpoints is sorted.
- {
- return true;
- }
+ if(binary_search(_routerEndpoints.begin(), _routerEndpoints.end(), *p)) // _routerEndpoints is sorted.
+ {
+ return true;
+ }
}
}
@@ -654,8 +654,8 @@ Ice::ObjectAdapterI::flushBatchRequests()
{
vector<IncomingConnectionFactoryPtr> f;
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
- f = _incomingConnectionFactories;
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+ f = _incomingConnectionFactories;
}
for_each(f.begin(), f.end(), Ice::voidMemFun(&IncomingConnectionFactory::flushBatchRequests));
}
@@ -683,7 +683,7 @@ Ice::ObjectAdapterI::decDirectCount()
assert(_directCount > 0);
if(--_directCount == 0)
{
- notifyAll();
+ notifyAll();
}
}
@@ -700,11 +700,11 @@ Ice::ObjectAdapterI::getThreadPool() const
if(_threadPool)
{
- return _threadPool;
+ return _threadPool;
}
else
{
- return _instance->serverThreadPool();
+ return _instance->serverThreadPool();
}
}
@@ -736,8 +736,8 @@ Ice::ObjectAdapterI::getThreadPerConnectionStackSize() const
}
Ice::ObjectAdapterI::ObjectAdapterI(const InstancePtr& instance, const CommunicatorPtr& communicator,
- const ObjectAdapterFactoryPtr& objectAdapterFactory, const string& name,
- const string& endpointInfo, const RouterPrx& router, bool noConfig) :
+ const ObjectAdapterFactoryPtr& objectAdapterFactory, const string& name,
+ const string& endpointInfo, const RouterPrx& router, bool noConfig) :
_deactivated(false),
_instance(instance),
_communicator(communicator),
@@ -769,28 +769,28 @@ Ice::ObjectAdapterI::ObjectAdapterI(const InstancePtr& instance, const Communica
{
StringSeq props = filterProperties(_propertyPrefix + _name + ".");
if(oldProps.size() == 0 && props.size() == 0)
- {
+ {
InitializationException ex(__FILE__, __LINE__);
- ex.reason = "object adapter \"" + _name + "\" requires configuration.";
- throw ex;
+ ex.reason = "object adapter \"" + _name + "\" requires configuration.";
+ throw ex;
}
}
if(oldProps.size() != 0)
{
- Warning out(_instance->initializationData().logger);
- out << "The following properties have been deprecated, please prepend \"Ice.OA.\":";
- for(unsigned int i = 0; i < oldProps.size(); ++i)
- {
- out << "\n " << oldProps[i];
- }
+ Warning out(_instance->initializationData().logger);
+ out << "The following properties have been deprecated, please prepend \"Ice.OA.\":";
+ for(unsigned int i = 0; i < oldProps.size(); ++i)
+ {
+ out << "\n " << oldProps[i];
+ }
}
const_cast<string&>(_id) = properties->getPropertyWithDefault(_propertyPrefix + _name + ".AdapterId",
- properties->getProperty(_name + ".AdapterId"));
+ properties->getProperty(_name + ".AdapterId"));
const_cast<string&>(_replicaGroupId) =
- properties->getPropertyWithDefault(_propertyPrefix + _name + ".ReplicaGroupId",
- properties->getProperty(_name + ".ReplicaGroupId"));
+ properties->getPropertyWithDefault(_propertyPrefix + _name + ".ReplicaGroupId",
+ properties->getProperty(_name + ".ReplicaGroupId"));
__setNoDelete(true);
try
@@ -811,7 +811,7 @@ Ice::ObjectAdapterI::ObjectAdapterI(const InstancePtr& instance, const Communica
if(_threadPerConnection && (threadPoolSize > 0 || threadPoolSizeMax > 0))
{
InitializationException ex(__FILE__, __LINE__);
- ex.reason = "object adapter \"" + _name + "\" cannot be configured for both\n"
+ ex.reason = "object adapter \"" + _name + "\" cannot be configured for both\n"
"thread pool and thread per connection";
throw ex;
}
@@ -832,138 +832,138 @@ Ice::ObjectAdapterI::ObjectAdapterI(const InstancePtr& instance, const Communica
// Create the per-adapter thread pool, if necessary. This is done before the creation of the incoming
// connection factory as the thread pool is needed during creation for the call to incFdsInUse.
//
- if(threadPoolSize > 0 || threadPoolSizeMax > 0)
- {
- if(!properties->getProperty(_propertyPrefix + _name + ".ThreadPool.Size").empty() ||
- !properties->getProperty(_propertyPrefix + _name + ".ThreadPool.SizeMax").empty())
- {
+ if(threadPoolSize > 0 || threadPoolSizeMax > 0)
+ {
+ if(!properties->getProperty(_propertyPrefix + _name + ".ThreadPool.Size").empty() ||
+ !properties->getProperty(_propertyPrefix + _name + ".ThreadPool.SizeMax").empty())
+ {
_threadPool = new ThreadPool(_instance, _propertyPrefix + _name + ".ThreadPool", 0);
- }
- else
- {
+ }
+ else
+ {
_threadPool = new ThreadPool(_instance, _name + ".ThreadPool", 0);
- }
- }
-
- if(!router)
- {
- const_cast<RouterPrx&>(router) = RouterPrx::uncheckedCast(
- _instance->proxyFactory()->propertyToProxy(_propertyPrefix + _name + ".Router"));
- if(!router)
- {
- const_cast<RouterPrx&>(router) = RouterPrx::uncheckedCast(
- _instance->proxyFactory()->propertyToProxy(_name + ".Router"));
- }
- }
- if(router)
- {
+ }
+ }
+
+ if(!router)
+ {
+ const_cast<RouterPrx&>(router) = RouterPrx::uncheckedCast(
+ _instance->proxyFactory()->propertyToProxy(_propertyPrefix + _name + ".Router"));
+ if(!router)
+ {
+ const_cast<RouterPrx&>(router) = RouterPrx::uncheckedCast(
+ _instance->proxyFactory()->propertyToProxy(_name + ".Router"));
+ }
+ }
+ if(router)
+ {
_routerInfo = _instance->routerManager()->get(router);
if(_routerInfo)
{
- //
- // Make sure this router is not already registered with another adapter.
- //
- if(_routerInfo->getAdapter())
- {
- throw AlreadyRegisteredException(__FILE__, __LINE__, "object adapter with router",
- _instance->identityToString(router->ice_getIdentity()));
- }
-
- //
- // Add the router's server proxy endpoints to this object
- // adapter.
- //
- vector<EndpointIPtr> endpoints = _routerInfo->getServerEndpoints();
- copy(endpoints.begin(), endpoints.end(), back_inserter(_routerEndpoints));
- sort(_routerEndpoints.begin(), _routerEndpoints.end()); // Must be sorted.
- _routerEndpoints.erase(unique(_routerEndpoints.begin(), _routerEndpoints.end()),
- _routerEndpoints.end());
-
- //
- // Associate this object adapter with the router. This way,
- // new outgoing connections to the router's client proxy will
- // use this object adapter for callbacks.
- //
- _routerInfo->setAdapter(this);
-
- //
- // Also modify all existing outgoing connections to the
- // router's client proxy to use this object adapter for
- // callbacks.
- //
- _instance->outgoingConnectionFactory()->setRouterInfo(_routerInfo);
+ //
+ // Make sure this router is not already registered with another adapter.
+ //
+ if(_routerInfo->getAdapter())
+ {
+ throw AlreadyRegisteredException(__FILE__, __LINE__, "object adapter with router",
+ _instance->identityToString(router->ice_getIdentity()));
+ }
+
+ //
+ // Add the router's server proxy endpoints to this object
+ // adapter.
+ //
+ vector<EndpointIPtr> endpoints = _routerInfo->getServerEndpoints();
+ copy(endpoints.begin(), endpoints.end(), back_inserter(_routerEndpoints));
+ sort(_routerEndpoints.begin(), _routerEndpoints.end()); // Must be sorted.
+ _routerEndpoints.erase(unique(_routerEndpoints.begin(), _routerEndpoints.end()),
+ _routerEndpoints.end());
+
+ //
+ // Associate this object adapter with the router. This way,
+ // new outgoing connections to the router's client proxy will
+ // use this object adapter for callbacks.
+ //
+ _routerInfo->setAdapter(this);
+
+ //
+ // Also modify all existing outgoing connections to the
+ // router's client proxy to use this object adapter for
+ // callbacks.
+ //
+ _instance->outgoingConnectionFactory()->setRouterInfo(_routerInfo);
+ }
+ }
+ else
+ {
+ //
+ // Parse the endpoints, but don't store them in the adapter.
+ // The connection factory might change it, for example, to
+ // fill in the real port number.
+ //
+ vector<EndpointIPtr> endpoints;
+ if(endpointInfo.empty())
+ {
+ endpoints = parseEndpoints(properties->getPropertyWithDefault(_propertyPrefix + _name + ".Endpoints",
+ properties->getProperty(_name + ".Endpoints")));
}
- }
- else
- {
- //
- // Parse the endpoints, but don't store them in the adapter.
- // The connection factory might change it, for example, to
- // fill in the real port number.
- //
- vector<EndpointIPtr> endpoints;
- if(endpointInfo.empty())
- {
- endpoints = parseEndpoints(properties->getPropertyWithDefault(_propertyPrefix + _name + ".Endpoints",
- properties->getProperty(_name + ".Endpoints")));
- }
- else
- {
- endpoints = parseEndpoints(endpointInfo);
- }
- for(vector<EndpointIPtr>::iterator p = endpoints.begin(); p != endpoints.end(); ++p)
- {
- _incomingConnectionFactories.push_back(new IncomingConnectionFactory(instance, *p, this, _name));
- }
- if(endpoints.empty())
- {
- TraceLevelsPtr tl = _instance->traceLevels();
- if(tl->network >= 2)
- {
- Trace out(_instance->initializationData().logger, tl->networkCat);
- out << "created adapter `" << name << "' without endpoints";
- }
- }
-
- //
- // Parse published endpoints. If set, these are used in proxies
- // instead of the connection factory endpoints.
- //
- string endpts = properties->getPropertyWithDefault(_propertyPrefix + _name + ".PublishedEndpoints",
- properties->getProperty(_name + ".PublishedEndpoints"));
- _publishedEndpoints = parseEndpoints(endpts);
- if(_publishedEndpoints.empty())
- {
- transform(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(),
- back_inserter(_publishedEndpoints), Ice::constMemFun(&IncomingConnectionFactory::endpoint));
- }
-
- //
- // Filter out any endpoints that are not meant to be published.
- //
- _publishedEndpoints.erase(remove_if(_publishedEndpoints.begin(), _publishedEndpoints.end(),
- not1(Ice::constMemFun(&EndpointI::publish))), _publishedEndpoints.end());
- }
-
- string locatorProperty = _propertyPrefix + _name + ".Locator";
- if(!properties->getProperty(locatorProperty).empty())
- {
- setLocator(LocatorPrx::uncheckedCast(_instance->proxyFactory()->propertyToProxy(locatorProperty)));
- }
- else if(!properties->getProperty(_name + ".Locator").empty())
- {
- setLocator(LocatorPrx::uncheckedCast(_instance->proxyFactory()->propertyToProxy(_name + ".Locator")));
- }
- else
- {
- setLocator(_instance->referenceFactory()->getDefaultLocator());
- }
+ else
+ {
+ endpoints = parseEndpoints(endpointInfo);
+ }
+ for(vector<EndpointIPtr>::iterator p = endpoints.begin(); p != endpoints.end(); ++p)
+ {
+ _incomingConnectionFactories.push_back(new IncomingConnectionFactory(instance, *p, this, _name));
+ }
+ if(endpoints.empty())
+ {
+ TraceLevelsPtr tl = _instance->traceLevels();
+ if(tl->network >= 2)
+ {
+ Trace out(_instance->initializationData().logger, tl->networkCat);
+ out << "created adapter `" << name << "' without endpoints";
+ }
+ }
+
+ //
+ // Parse published endpoints. If set, these are used in proxies
+ // instead of the connection factory endpoints.
+ //
+ string endpts = properties->getPropertyWithDefault(_propertyPrefix + _name + ".PublishedEndpoints",
+ properties->getProperty(_name + ".PublishedEndpoints"));
+ _publishedEndpoints = parseEndpoints(endpts);
+ if(_publishedEndpoints.empty())
+ {
+ transform(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(),
+ back_inserter(_publishedEndpoints), Ice::constMemFun(&IncomingConnectionFactory::endpoint));
+ }
+
+ //
+ // Filter out any endpoints that are not meant to be published.
+ //
+ _publishedEndpoints.erase(remove_if(_publishedEndpoints.begin(), _publishedEndpoints.end(),
+ not1(Ice::constMemFun(&EndpointI::publish))), _publishedEndpoints.end());
+ }
+
+ string locatorProperty = _propertyPrefix + _name + ".Locator";
+ if(!properties->getProperty(locatorProperty).empty())
+ {
+ setLocator(LocatorPrx::uncheckedCast(_instance->proxyFactory()->propertyToProxy(locatorProperty)));
+ }
+ else if(!properties->getProperty(_name + ".Locator").empty())
+ {
+ setLocator(LocatorPrx::uncheckedCast(_instance->proxyFactory()->propertyToProxy(_name + ".Locator")));
+ }
+ else
+ {
+ setLocator(_instance->referenceFactory()->getDefaultLocator());
+ }
}
catch(...)
{
- destroy();
- __setNoDelete(false);
- throw;
+ destroy();
+ __setNoDelete(false);
+ throw;
}
__setNoDelete(false);
}
@@ -972,22 +972,22 @@ Ice::ObjectAdapterI::~ObjectAdapterI()
{
if(!_deactivated)
{
- Warning out(_instance->initializationData().logger);
- out << "object adapter `" << getName() << "' has not been deactivated";
+ Warning out(_instance->initializationData().logger);
+ out << "object adapter `" << getName() << "' has not been deactivated";
}
else if(!_destroyed)
{
- Warning out(_instance->initializationData().logger);
- out << "object adapter `" << getName() << "' has not been destroyed";
+ Warning out(_instance->initializationData().logger);
+ out << "object adapter `" << getName() << "' has not been destroyed";
}
else
{
- //assert(!_servantManager); // We don't clear this reference, it needs to be immutable.
- assert(!_threadPool);
- assert(!_communicator);
- assert(_incomingConnectionFactories.empty());
- assert(_directCount == 0);
- assert(!_waitForActivate);
+ //assert(!_servantManager); // We don't clear this reference, it needs to be immutable.
+ assert(!_threadPool);
+ assert(!_communicator);
+ assert(_incomingConnectionFactories.empty());
+ assert(_directCount == 0);
+ assert(!_waitForActivate);
}
}
@@ -996,15 +996,15 @@ Ice::ObjectAdapterI::newProxy(const Identity& ident, const string& facet) const
{
if(_id.empty())
{
- return newDirectProxy(ident, facet);
+ return newDirectProxy(ident, facet);
}
else if(_replicaGroupId.empty())
{
- return newIndirectProxy(ident, facet, _id);
+ return newIndirectProxy(ident, facet, _id);
}
else
{
- return newIndirectProxy(ident, facet, _replicaGroupId);
+ return newIndirectProxy(ident, facet, _replicaGroupId);
}
}
@@ -1024,9 +1024,9 @@ Ice::ObjectAdapterI::newDirectProxy(const Identity& ident, const string& facet)
// Create a reference and return a proxy for this reference.
//
ReferencePtr ref = _instance->referenceFactory()->create(
- ident, _instance->getDefaultContext(), facet, Reference::ModeTwoway, false,
- _instance->defaultsAndOverrides()->defaultPreferSecure, endpoints, 0,
- _instance->defaultsAndOverrides()->defaultCollocationOptimization, true,
+ ident, _instance->getDefaultContext(), facet, Reference::ModeTwoway, false,
+ _instance->defaultsAndOverrides()->defaultPreferSecure, endpoints, 0,
+ _instance->defaultsAndOverrides()->defaultCollocationOptimization, true,
_instance->defaultsAndOverrides()->defaultEndpointSelection, _instance->threadPerConnection());
return _instance->proxyFactory()->referenceToProxy(ref);
@@ -1039,11 +1039,11 @@ Ice::ObjectAdapterI::newIndirectProxy(const Identity& ident, const string& facet
// Create an indirect reference with the given adapter id.
//
ReferencePtr ref = _instance->referenceFactory()->create(
- ident, _instance->getDefaultContext(), facet, Reference::ModeTwoway, false,
- _instance->defaultsAndOverrides()->defaultPreferSecure, id, 0,
- _locatorInfo, _instance->defaultsAndOverrides()->defaultCollocationOptimization, true,
+ ident, _instance->getDefaultContext(), facet, Reference::ModeTwoway, false,
+ _instance->defaultsAndOverrides()->defaultPreferSecure, id, 0,
+ _locatorInfo, _instance->defaultsAndOverrides()->defaultCollocationOptimization, true,
_instance->defaultsAndOverrides()->defaultEndpointSelection, _instance->threadPerConnection(),
- _instance->defaultsAndOverrides()->defaultLocatorCacheTimeout);
+ _instance->defaultsAndOverrides()->defaultLocatorCacheTimeout);
//
// Return a proxy for the reference.
@@ -1056,9 +1056,9 @@ Ice::ObjectAdapterI::checkForDeactivation() const
{
if(_deactivated)
{
- ObjectAdapterDeactivatedException ex(__FILE__, __LINE__);
- ex.name = getName();
- throw ex;
+ ObjectAdapterDeactivatedException ex(__FILE__, __LINE__);
+ ex.name = getName();
+ throw ex;
}
}
@@ -1085,38 +1085,38 @@ Ice::ObjectAdapterI::parseEndpoints(const string& str) const
vector<EndpointIPtr> endpoints;
while(end < endpts.length())
{
- const string delim = " \t\n\r";
-
- beg = endpts.find_first_not_of(delim, end);
- if(beg == string::npos)
- {
- break;
- }
-
- end = endpts.find(':', beg);
- if(end == string::npos)
- {
- end = endpts.length();
- }
-
- if(end == beg)
- {
- ++end;
- continue;
- }
-
- string s = endpts.substr(beg, end - beg);
- EndpointIPtr endp = _instance->endpointFactoryManager()->create(s);
- if(endp == 0)
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = s;
- throw ex;
- }
- vector<EndpointIPtr> endps = endp->expand(true);
- endpoints.insert(endpoints.end(), endps.begin(), endps.end());
-
- ++end;
+ const string delim = " \t\n\r";
+
+ beg = endpts.find_first_not_of(delim, end);
+ if(beg == string::npos)
+ {
+ break;
+ }
+
+ end = endpts.find(':', beg);
+ if(end == string::npos)
+ {
+ end = endpts.length();
+ }
+
+ if(end == beg)
+ {
+ ++end;
+ continue;
+ }
+
+ string s = endpts.substr(beg, end - beg);
+ EndpointIPtr endp = _instance->endpointFactoryManager()->create(s);
+ if(endp == 0)
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = s;
+ throw ex;
+ }
+ vector<EndpointIPtr> endps = endp->expand(true);
+ endpoints.insert(endpoints.end(), endps.begin(), endps.end());
+
+ ++end;
}
return endpoints;
@@ -1124,12 +1124,12 @@ Ice::ObjectAdapterI::parseEndpoints(const string& str) const
void
ObjectAdapterI::updateLocatorRegistry(const IceInternal::LocatorInfoPtr& locatorInfo,
- const Ice::ObjectPrx& proxy,
- bool registerProcess)
+ const Ice::ObjectPrx& proxy,
+ bool registerProcess)
{
if(!registerProcess && _id.empty())
{
- return; // Nothing to update.
+ return; // Nothing to update.
}
//
@@ -1147,76 +1147,76 @@ ObjectAdapterI::updateLocatorRegistry(const IceInternal::LocatorInfoPtr& locator
string serverId;
if(registerProcess)
{
- assert(_instance);
- serverId = _instance->initializationData().properties->getProperty("Ice.ServerId");
-
- if(!locatorRegistry)
- {
- Warning out(_instance->initializationData().logger);
- out << "object adapter `" << getName() << "' cannot register the process without a locator registry";
- }
- else if(serverId.empty())
- {
- Warning out(_instance->initializationData().logger);
- out << "object adapter `" << getName() << "' cannot register the process without a value for Ice.ServerId";
- }
+ assert(_instance);
+ serverId = _instance->initializationData().properties->getProperty("Ice.ServerId");
+
+ if(!locatorRegistry)
+ {
+ Warning out(_instance->initializationData().logger);
+ out << "object adapter `" << getName() << "' cannot register the process without a locator registry";
+ }
+ else if(serverId.empty())
+ {
+ Warning out(_instance->initializationData().logger);
+ out << "object adapter `" << getName() << "' cannot register the process without a value for Ice.ServerId";
+ }
}
if(!locatorRegistry)
{
- return;
+ return;
}
if(!_id.empty())
{
- try
- {
- if(_replicaGroupId.empty())
- {
- locatorRegistry->setAdapterDirectProxy(_id, proxy);
- }
- else
- {
- locatorRegistry->setReplicatedAdapterDirectProxy(_id, _replicaGroupId, proxy);
- }
- }
- catch(const AdapterNotFoundException&)
- {
- NotRegisteredException ex(__FILE__, __LINE__);
- ex.kindOfObject = "object adapter";
- ex.id = _id;
- throw ex;
- }
- catch(const InvalidReplicaGroupIdException&)
- {
- NotRegisteredException ex(__FILE__, __LINE__);
- ex.kindOfObject = "replica group";
- ex.id = _replicaGroupId;
- throw ex;
- }
- catch(const AdapterAlreadyActiveException&)
- {
- ObjectAdapterIdInUseException ex(__FILE__, __LINE__);
- ex.id = _id;
- throw ex;
- }
- }
+ try
+ {
+ if(_replicaGroupId.empty())
+ {
+ locatorRegistry->setAdapterDirectProxy(_id, proxy);
+ }
+ else
+ {
+ locatorRegistry->setReplicatedAdapterDirectProxy(_id, _replicaGroupId, proxy);
+ }
+ }
+ catch(const AdapterNotFoundException&)
+ {
+ NotRegisteredException ex(__FILE__, __LINE__);
+ ex.kindOfObject = "object adapter";
+ ex.id = _id;
+ throw ex;
+ }
+ catch(const InvalidReplicaGroupIdException&)
+ {
+ NotRegisteredException ex(__FILE__, __LINE__);
+ ex.kindOfObject = "replica group";
+ ex.id = _replicaGroupId;
+ throw ex;
+ }
+ catch(const AdapterAlreadyActiveException&)
+ {
+ ObjectAdapterIdInUseException ex(__FILE__, __LINE__);
+ ex.id = _id;
+ throw ex;
+ }
+ }
if(registerProcess && !serverId.empty())
{
- try
- {
- ProcessPtr servant = new ProcessI(_communicator);
- Ice::ObjectPrx process = createDirectProxy(addWithUUID(servant)->ice_getIdentity());
- locatorRegistry->setServerProcessProxy(serverId, ProcessPrx::uncheckedCast(process));
- }
- catch(const ServerNotFoundException&)
- {
- NotRegisteredException ex(__FILE__, __LINE__);
- ex.kindOfObject = "server";
- ex.id = serverId;
- throw ex;
- }
+ try
+ {
+ ProcessPtr servant = new ProcessI(_communicator);
+ Ice::ObjectPrx process = createDirectProxy(addWithUUID(servant)->ice_getIdentity());
+ locatorRegistry->setServerProcessProxy(serverId, ProcessPrx::uncheckedCast(process));
+ }
+ catch(const ServerNotFoundException&)
+ {
+ NotRegisteredException ex(__FILE__, __LINE__);
+ ex.kindOfObject = "server";
+ ex.id = serverId;
+ throw ex;
+ }
}
}
@@ -1225,17 +1225,17 @@ Ice::ObjectAdapterI::filterProperties(const string& prefix)
{
static const string suffixes[] =
{
- "AdapterId",
- "Endpoints",
- "Locator",
- "PublishedEndpoints",
- "RegisterProcess",
- "ReplicaGroupId",
- "Router",
- "ThreadPool.Size",
- "ThreadPool.SizeMax",
- "ThreadPool.SizeWarn",
- "ThreadPool.StackSize"
+ "AdapterId",
+ "Endpoints",
+ "Locator",
+ "PublishedEndpoints",
+ "RegisterProcess",
+ "ReplicaGroupId",
+ "Router",
+ "ThreadPool.Size",
+ "ThreadPool.SizeMax",
+ "ThreadPool.SizeWarn",
+ "ThreadPool.StackSize"
};
StringSeq propertySet;
@@ -1243,9 +1243,9 @@ Ice::ObjectAdapterI::filterProperties(const string& prefix)
for(unsigned int i = 0; i < sizeof(suffixes)/sizeof(*suffixes); ++i)
{
if(props.find(prefix + suffixes[i]) != props.end())
- {
- propertySet.push_back(prefix + suffixes[i]);
- }
+ {
+ propertySet.push_back(prefix + suffixes[i]);
+ }
}
return propertySet;
@@ -1267,15 +1267,15 @@ Ice::ObjectAdapterI::ProcessI::writeMessage(const string& message, Int fd, const
{
switch(fd)
{
- case 1:
- {
- cout << message << endl;
- break;
- }
- case 2:
- {
- cerr << message << endl;
- break;
- }
+ case 1:
+ {
+ cout << message << endl;
+ break;
+ }
+ case 2:
+ {
+ cerr << message << endl;
+ break;
+ }
}
}
diff --git a/cpp/src/Ice/ObjectAdapterI.h b/cpp/src/Ice/ObjectAdapterI.h
index e9b6fe0cb6f..b61b7e3e1a7 100644
--- a/cpp/src/Ice/ObjectAdapterI.h
+++ b/cpp/src/Ice/ObjectAdapterI.h
@@ -89,8 +89,8 @@ public:
private:
ObjectAdapterI(const IceInternal::InstancePtr&, const CommunicatorPtr&,
- const IceInternal::ObjectAdapterFactoryPtr&, const std::string&, const std::string&,
- const RouterPrx&, bool);
+ const IceInternal::ObjectAdapterFactoryPtr&, const std::string&, const std::string&,
+ const RouterPrx&, bool);
virtual ~ObjectAdapterI();
friend class IceInternal::ObjectAdapterFactory;
@@ -135,7 +135,7 @@ private:
ProcessI(const CommunicatorPtr&);
virtual void shutdown(const Current&);
- virtual void writeMessage(const std::string&, Int, const Current&);
+ virtual void writeMessage(const std::string&, Int, const Current&);
private:
diff --git a/cpp/src/Ice/ObjectFactoryManager.cpp b/cpp/src/Ice/ObjectFactoryManager.cpp
index c52894f4234..5ed3f2a7d38 100644
--- a/cpp/src/Ice/ObjectFactoryManager.cpp
+++ b/cpp/src/Ice/ObjectFactoryManager.cpp
@@ -28,10 +28,10 @@ IceInternal::ObjectFactoryManager::add(const ObjectFactoryPtr& factory, const st
if((_factoryMapHint != _factoryMap.end() && _factoryMapHint->first == id)
|| _factoryMap.find(id) != _factoryMap.end())
{
- AlreadyRegisteredException ex(__FILE__, __LINE__);
- ex.kindOfObject = "object factory";
- ex.id = id;
- throw ex;
+ AlreadyRegisteredException ex(__FILE__, __LINE__);
+ ex.kindOfObject = "object factory";
+ ex.id = id;
+ throw ex;
}
_factoryMapHint = _factoryMap.insert(_factoryMapHint, pair<const string, ObjectFactoryPtr>(id, factory));
@@ -42,41 +42,41 @@ IceInternal::ObjectFactoryManager::remove(const string& id)
{
ObjectFactoryPtr factory = 0;
{
- IceUtil::Mutex::Lock sync(*this);
-
- FactoryMap::iterator p = _factoryMap.end();
- if(_factoryMapHint != _factoryMap.end())
- {
- if(_factoryMapHint->first == id)
- {
- p = _factoryMapHint;
- }
- }
-
- if(p == _factoryMap.end())
- {
- p = _factoryMap.find(id);
- if(p == _factoryMap.end())
- {
- NotRegisteredException ex(__FILE__, __LINE__);
- ex.kindOfObject = "object factory";
- ex.id = id;
- throw ex;
- }
- }
- assert(p != _factoryMap.end());
-
- factory = p->second;
-
- if(p == _factoryMapHint)
- {
- _factoryMap.erase(p++);
- _factoryMapHint = p;
- }
- else
- {
- _factoryMap.erase(p);
- }
+ IceUtil::Mutex::Lock sync(*this);
+
+ FactoryMap::iterator p = _factoryMap.end();
+ if(_factoryMapHint != _factoryMap.end())
+ {
+ if(_factoryMapHint->first == id)
+ {
+ p = _factoryMapHint;
+ }
+ }
+
+ if(p == _factoryMap.end())
+ {
+ p = _factoryMap.find(id);
+ if(p == _factoryMap.end())
+ {
+ NotRegisteredException ex(__FILE__, __LINE__);
+ ex.kindOfObject = "object factory";
+ ex.id = id;
+ throw ex;
+ }
+ }
+ assert(p != _factoryMap.end());
+
+ factory = p->second;
+
+ if(p == _factoryMapHint)
+ {
+ _factoryMap.erase(p++);
+ _factoryMapHint = p;
+ }
+ else
+ {
+ _factoryMap.erase(p);
+ }
}
//
@@ -96,25 +96,25 @@ IceInternal::ObjectFactoryManager::find(const string& id) const
FactoryMap::iterator p = factoryMap.end();
if(_factoryMapHint != factoryMap.end())
{
- if(_factoryMapHint->first == id)
- {
- p = _factoryMapHint;
- }
+ if(_factoryMapHint->first == id)
+ {
+ p = _factoryMapHint;
+ }
}
if(p == factoryMap.end())
{
- p = factoryMap.find(id);
+ p = factoryMap.find(id);
}
if(p != factoryMap.end())
{
- _factoryMapHint = p;
- return p->second;
+ _factoryMapHint = p;
+ return p->second;
}
else
{
- return 0;
+ return 0;
}
}
@@ -128,14 +128,14 @@ IceInternal::ObjectFactoryManager::destroy()
{
FactoryMap oldMap;
{
- IceUtil::Mutex::Lock sync(*this);
- oldMap.swap(_factoryMap);
- _factoryMapHint = _factoryMap.end();
+ IceUtil::Mutex::Lock sync(*this);
+ oldMap.swap(_factoryMap);
+ _factoryMapHint = _factoryMap.end();
}
//
// Destroy all outside lock
//
for_each(oldMap.begin(), oldMap.end(),
- Ice::secondVoidMemFun<const string, ObjectFactory>(&ObjectFactory::destroy));
+ Ice::secondVoidMemFun<const string, ObjectFactory>(&ObjectFactory::destroy));
}
diff --git a/cpp/src/Ice/Outgoing.cpp b/cpp/src/Ice/Outgoing.cpp
index c16f5618c05..33a6fc3931a 100644
--- a/cpp/src/Ice/Outgoing.cpp
+++ b/cpp/src/Ice/Outgoing.cpp
@@ -46,7 +46,7 @@ IceInternal::LocalExceptionWrapper::retry() const
}
IceInternal::Outgoing::Outgoing(ConnectionI* connection, Reference* ref, const string& operation,
- OperationMode mode, const Context* context, bool compress) :
+ OperationMode mode, const Context* context, bool compress) :
_connection(connection),
_reference(ref),
_state(StateUnsent),
@@ -56,80 +56,80 @@ IceInternal::Outgoing::Outgoing(ConnectionI* connection, Reference* ref, const s
{
switch(_reference->getMode())
{
- case Reference::ModeTwoway:
- case Reference::ModeOneway:
- case Reference::ModeDatagram:
- {
- _os.writeBlob(requestHdr, sizeof(requestHdr));
- break;
- }
-
- case Reference::ModeBatchOneway:
- case Reference::ModeBatchDatagram:
- {
- _connection->prepareBatchRequest(&_os);
- break;
- }
+ case Reference::ModeTwoway:
+ case Reference::ModeOneway:
+ case Reference::ModeDatagram:
+ {
+ _os.writeBlob(requestHdr, sizeof(requestHdr));
+ break;
+ }
+
+ case Reference::ModeBatchOneway:
+ case Reference::ModeBatchDatagram:
+ {
+ _connection->prepareBatchRequest(&_os);
+ break;
+ }
}
try
{
- _reference->getIdentity().__write(&_os);
-
- //
- // For compatibility with the old FacetPath.
- //
- if(_reference->getFacet().empty())
- {
- _os.write(static_cast<string*>(0), static_cast<string*>(0));
- }
- else
- {
- string facet = _reference->getFacet();
- _os.write(&facet, &facet + 1);
- }
-
- _os.write(operation, false);
-
- _os.write(static_cast<Byte>(mode));
-
- if(context != 0)
- {
- //
- // Explicit context
- //
- __write(&_os, *context, __U__Context());
- }
- else
- {
- //
- // Implicit context
- //
- const ImplicitContextIPtr& implicitContext =
- _reference->getInstance()->getImplicitContext();
-
- const Context& prxContext = _reference->getContext()->getValue();
-
- if(implicitContext == 0)
- {
- __write(&_os, prxContext, __U__Context());
- }
- else
- {
- implicitContext->write(prxContext, &_os);
- }
- }
-
- //
- // Input and output parameters are always sent in an
- // encapsulation, which makes it possible to forward requests as
- // blobs.
- //
- _os.startWriteEncaps();
+ _reference->getIdentity().__write(&_os);
+
+ //
+ // For compatibility with the old FacetPath.
+ //
+ if(_reference->getFacet().empty())
+ {
+ _os.write(static_cast<string*>(0), static_cast<string*>(0));
+ }
+ else
+ {
+ string facet = _reference->getFacet();
+ _os.write(&facet, &facet + 1);
+ }
+
+ _os.write(operation, false);
+
+ _os.write(static_cast<Byte>(mode));
+
+ if(context != 0)
+ {
+ //
+ // Explicit context
+ //
+ __write(&_os, *context, __U__Context());
+ }
+ else
+ {
+ //
+ // Implicit context
+ //
+ const ImplicitContextIPtr& implicitContext =
+ _reference->getInstance()->getImplicitContext();
+
+ const Context& prxContext = _reference->getContext()->getValue();
+
+ if(implicitContext == 0)
+ {
+ __write(&_os, prxContext, __U__Context());
+ }
+ else
+ {
+ implicitContext->write(prxContext, &_os);
+ }
+ }
+
+ //
+ // Input and output parameters are always sent in an
+ // encapsulation, which makes it possible to forward requests as
+ // blobs.
+ //
+ _os.startWriteEncaps();
}
catch(const LocalException& ex)
{
- abort(ex);
+ abort(ex);
}
}
@@ -142,145 +142,145 @@ IceInternal::Outgoing::invoke()
switch(_reference->getMode())
{
- case Reference::ModeTwoway:
- {
- //
- // We let all exceptions raised by sending directly
- // propagate to the caller, because they can be retried
- // without violating "at-most-once". In case of such
- // exceptions, the connection object does not call back on
- // this object, so we don't need to lock the mutex, keep
- // track of state, or save exceptions.
- //
- _connection->sendRequest(&_os, this, _compress);
-
- //
- // Wait until the request has completed, or until the
- // request times out.
- //
-
- bool timedOut = false;
-
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor);
-
- //
+ case Reference::ModeTwoway:
+ {
+ //
+ // We let all exceptions raised by sending directly
+ // propagate to the caller, because they can be retried
+ // without violating "at-most-once". In case of such
+ // exceptions, the connection object does not call back on
+ // this object, so we don't need to lock the mutex, keep
+ // track of state, or save exceptions.
+ //
+ _connection->sendRequest(&_os, this, _compress);
+
+ //
+ // Wait until the request has completed, or until the
+ // request times out.
+ //
+
+ bool timedOut = false;
+
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor);
+
+ //
// It's possible that the request has already
// completed, due to a regular response, or because of
// an exception. So we only change the state to "in
// progress" if it is still "unsent".
- //
- if(_state == StateUnsent)
- {
- _state = StateInProgress;
- }
-
- Int timeout = _connection->timeout();
- while(_state == StateInProgress && !timedOut)
- {
- if(timeout >= 0)
- {
- _monitor.timedWait(IceUtil::Time::milliSeconds(timeout));
-
- if(_state == StateInProgress)
- {
- timedOut = true;
- }
- }
- else
- {
- _monitor.wait();
- }
- }
- }
-
- if(timedOut)
- {
- //
- // Must be called outside the synchronization of this
- // object.
- //
- _connection->exception(TimeoutException(__FILE__, __LINE__));
-
- //
- // We must wait until the exception set above has
- // propagated to this Outgoing object.
- //
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor);
-
- while(_state == StateInProgress)
- {
- _monitor.wait();
- }
- }
- }
-
- if(_exception.get())
- {
- //
- // A CloseConnectionException indicates graceful
- // server shutdown, and is therefore always repeatable
- // without violating "at-most-once". That's because by
- // sending a close connection message, the server
- // guarantees that all outstanding requests can safely
- // be repeated.
- //
- // An ObjectNotExistException can always be retried as
- // well without violating "at-most-once".
- //
- if(dynamic_cast<CloseConnectionException*>(_exception.get()) ||
- dynamic_cast<ObjectNotExistException*>(_exception.get()))
- {
- _exception->ice_throw();
- }
-
- //
- // Throw the exception wrapped in a
- // LocalExceptionWrapper, to indicate that the request
- // cannot be resent without potentially violating the
- // "at-most-once" principle.
- //
- throw LocalExceptionWrapper(*_exception.get(), false);
- }
-
- if(_state == StateUserException)
- {
- return false;
- }
-
- assert(_state == StateOK);
- break;
- }
-
- case Reference::ModeOneway:
- case Reference::ModeDatagram:
- {
- //
- // For oneway and datagram requests, the connection object
- // never calls back on this object. Therefore we don't
- // need to lock the mutex or save exceptions. We simply
- // let all exceptions from sending propagate to the
- // caller, because such exceptions can be retried without
- // violating "at-most-once".
- //
- _state = StateInProgress;
- _connection->sendRequest(&_os, 0, _compress);
- break;
- }
-
- case Reference::ModeBatchOneway:
- case Reference::ModeBatchDatagram:
- {
- //
- // For batch oneways and datagrams, the same rules as for
- // regular oneways and datagrams (see comment above)
- // apply.
- //
- _state = StateInProgress;
- _connection->finishBatchRequest(&_os, _compress);
- break;
- }
+ //
+ if(_state == StateUnsent)
+ {
+ _state = StateInProgress;
+ }
+
+ Int timeout = _connection->timeout();
+ while(_state == StateInProgress && !timedOut)
+ {
+ if(timeout >= 0)
+ {
+ _monitor.timedWait(IceUtil::Time::milliSeconds(timeout));
+
+ if(_state == StateInProgress)
+ {
+ timedOut = true;
+ }
+ }
+ else
+ {
+ _monitor.wait();
+ }
+ }
+ }
+
+ if(timedOut)
+ {
+ //
+ // Must be called outside the synchronization of this
+ // object.
+ //
+ _connection->exception(TimeoutException(__FILE__, __LINE__));
+
+ //
+ // We must wait until the exception set above has
+ // propagated to this Outgoing object.
+ //
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor);
+
+ while(_state == StateInProgress)
+ {
+ _monitor.wait();
+ }
+ }
+ }
+
+ if(_exception.get())
+ {
+ //
+ // A CloseConnectionException indicates graceful
+ // server shutdown, and is therefore always repeatable
+ // without violating "at-most-once". That's because by
+ // sending a close connection message, the server
+ // guarantees that all outstanding requests can safely
+ // be repeated.
+ //
+ // An ObjectNotExistException can always be retried as
+ // well without violating "at-most-once".
+ //
+ if(dynamic_cast<CloseConnectionException*>(_exception.get()) ||
+ dynamic_cast<ObjectNotExistException*>(_exception.get()))
+ {
+ _exception->ice_throw();
+ }
+
+ //
+ // Throw the exception wrapped in a
+ // LocalExceptionWrapper, to indicate that the request
+ // cannot be resent without potentially violating the
+ // "at-most-once" principle.
+ //
+ throw LocalExceptionWrapper(*_exception.get(), false);
+ }
+
+ if(_state == StateUserException)
+ {
+ return false;
+ }
+
+ assert(_state == StateOK);
+ break;
+ }
+
+ case Reference::ModeOneway:
+ case Reference::ModeDatagram:
+ {
+ //
+ // For oneway and datagram requests, the connection object
+ // never calls back on this object. Therefore we don't
+ // need to lock the mutex or save exceptions. We simply
+ // let all exceptions from sending propagate to the
+ // caller, because such exceptions can be retried without
+ // violating "at-most-once".
+ //
+ _state = StateInProgress;
+ _connection->sendRequest(&_os, 0, _compress);
+ break;
+ }
+
+ case Reference::ModeBatchOneway:
+ case Reference::ModeBatchDatagram:
+ {
+ //
+ // For batch oneways and datagrams, the same rules as for
+ // regular oneways and datagrams (see comment above)
+ // apply.
+ //
+ _state = StateInProgress;
+ _connection->finishBatchRequest(&_os, _compress);
+ break;
+ }
}
return true;
@@ -298,14 +298,14 @@ IceInternal::Outgoing::abort(const LocalException& ex)
//
if(_reference->getMode() == Reference::ModeBatchOneway || _reference->getMode() == Reference::ModeBatchDatagram)
{
- _connection->abortBatchRequest();
-
- //
- // If we abort a batch requests, we cannot retry, because not
- // only the batch request that caused the problem will be
- // aborted, but all other requests in the batch as well.
- //
- throw LocalExceptionWrapper(ex, false);
+ _connection->abortBatchRequest();
+
+ //
+ // If we abort a batch requests, we cannot retry, because not
+ // only the batch request that caused the problem will be
+ // aborted, but all other requests in the batch as well.
+ //
+ throw LocalExceptionWrapper(ex, false);
}
ex.ice_throw();
@@ -326,152 +326,152 @@ IceInternal::Outgoing::finished(BasicStream& is)
switch(static_cast<DispatchStatus>(status))
{
- case DispatchOK:
- {
- //
- // Input and output parameters are always sent in an
- // encapsulation, which makes it possible to forward
- // oneway requests as blobs.
- //
- _is.startReadEncaps();
- _state = StateOK; // The state must be set last, in case there is an exception.
- break;
- }
-
- case DispatchUserException:
- {
- //
- // Input and output parameters are always sent in an
- // encapsulation, which makes it possible to forward
- // oneway requests as blobs.
- //
- _is.startReadEncaps();
- _state = StateUserException; // The state must be set last, in case there is an exception.
- break;
- }
-
- case DispatchObjectNotExist:
- case DispatchFacetNotExist:
- case DispatchOperationNotExist:
- {
- //
- // Don't read the exception members directly into the
- // exception. Otherwise if reading fails and raises an
- // exception, you will have a memory leak.
- //
- Identity ident;
- ident.__read(&_is);
-
- //
- // For compatibility with the old FacetPath.
- //
- vector<string> facetPath;
- _is.read(facetPath);
- string facet;
- if(!facetPath.empty())
- {
- if(facetPath.size() > 1)
- {
- throw MarshalException(__FILE__, __LINE__);
- }
- facet.swap(facetPath[0]);
- }
-
- string operation;
- _is.read(operation, false);
-
- RequestFailedException* ex;
- switch(static_cast<DispatchStatus>(status))
- {
- case DispatchObjectNotExist:
- {
- ex = new ObjectNotExistException(__FILE__, __LINE__);
- break;
- }
-
- case DispatchFacetNotExist:
- {
- ex = new FacetNotExistException(__FILE__, __LINE__);
- break;
- }
-
- case DispatchOperationNotExist:
- {
- ex = new OperationNotExistException(__FILE__, __LINE__);
- break;
- }
-
- default:
- {
- ex = 0; // To keep the compiler from complaining.
- assert(false);
- break;
- }
- }
-
- ex->id = ident;
- ex->facet = facet;
- ex->operation = operation;
- _exception.reset(ex);
-
- _state = StateLocalException; // The state must be set last, in case there is an exception.
- break;
- }
-
- case DispatchUnknownException:
- case DispatchUnknownLocalException:
- case DispatchUnknownUserException:
- {
- //
- // Don't read the exception members directly into the
- // exception. Otherwise if reading fails and raises an
- // exception, you will have a memory leak.
- //
- string unknown;
- _is.read(unknown, false);
-
- UnknownException* ex;
- switch(static_cast<DispatchStatus>(status))
- {
- case DispatchUnknownException:
- {
- ex = new UnknownException(__FILE__, __LINE__);
- break;
- }
-
- case DispatchUnknownLocalException:
- {
- ex = new UnknownLocalException(__FILE__, __LINE__);
- break;
- }
-
- case DispatchUnknownUserException:
- {
- ex = new UnknownUserException(__FILE__, __LINE__);
- break;
- }
-
- default:
- {
- ex = 0; // To keep the compiler from complaining.
- assert(false);
- break;
- }
- }
-
- ex->unknown = unknown;
- _exception.reset(ex);
-
- _state = StateLocalException; // The state must be set last, in case there is an exception.
- break;
- }
-
- default:
- {
- _exception.reset(new UnknownReplyStatusException(__FILE__, __LINE__));
- _state = StateLocalException;
- break;
- }
+ case DispatchOK:
+ {
+ //
+ // Input and output parameters are always sent in an
+ // encapsulation, which makes it possible to forward
+ // oneway requests as blobs.
+ //
+ _is.startReadEncaps();
+ _state = StateOK; // The state must be set last, in case there is an exception.
+ break;
+ }
+
+ case DispatchUserException:
+ {
+ //
+ // Input and output parameters are always sent in an
+ // encapsulation, which makes it possible to forward
+ // oneway requests as blobs.
+ //
+ _is.startReadEncaps();
+ _state = StateUserException; // The state must be set last, in case there is an exception.
+ break;
+ }
+
+ case DispatchObjectNotExist:
+ case DispatchFacetNotExist:
+ case DispatchOperationNotExist:
+ {
+ //
+ // Don't read the exception members directly into the
+ // exception. Otherwise if reading fails and raises an
+ // exception, you will have a memory leak.
+ //
+ Identity ident;
+ ident.__read(&_is);
+
+ //
+ // For compatibility with the old FacetPath.
+ //
+ vector<string> facetPath;
+ _is.read(facetPath);
+ string facet;
+ if(!facetPath.empty())
+ {
+ if(facetPath.size() > 1)
+ {
+ throw MarshalException(__FILE__, __LINE__);
+ }
+ facet.swap(facetPath[0]);
+ }
+
+ string operation;
+ _is.read(operation, false);
+
+ RequestFailedException* ex;
+ switch(static_cast<DispatchStatus>(status))
+ {
+ case DispatchObjectNotExist:
+ {
+ ex = new ObjectNotExistException(__FILE__, __LINE__);
+ break;
+ }
+
+ case DispatchFacetNotExist:
+ {
+ ex = new FacetNotExistException(__FILE__, __LINE__);
+ break;
+ }
+
+ case DispatchOperationNotExist:
+ {
+ ex = new OperationNotExistException(__FILE__, __LINE__);
+ break;
+ }
+
+ default:
+ {
+ ex = 0; // To keep the compiler from complaining.
+ assert(false);
+ break;
+ }
+ }
+
+ ex->id = ident;
+ ex->facet = facet;
+ ex->operation = operation;
+ _exception.reset(ex);
+
+ _state = StateLocalException; // The state must be set last, in case there is an exception.
+ break;
+ }
+
+ case DispatchUnknownException:
+ case DispatchUnknownLocalException:
+ case DispatchUnknownUserException:
+ {
+ //
+ // Don't read the exception members directly into the
+ // exception. Otherwise if reading fails and raises an
+ // exception, you will have a memory leak.
+ //
+ string unknown;
+ _is.read(unknown, false);
+
+ UnknownException* ex;
+ switch(static_cast<DispatchStatus>(status))
+ {
+ case DispatchUnknownException:
+ {
+ ex = new UnknownException(__FILE__, __LINE__);
+ break;
+ }
+
+ case DispatchUnknownLocalException:
+ {
+ ex = new UnknownLocalException(__FILE__, __LINE__);
+ break;
+ }
+
+ case DispatchUnknownUserException:
+ {
+ ex = new UnknownUserException(__FILE__, __LINE__);
+ break;
+ }
+
+ default:
+ {
+ ex = 0; // To keep the compiler from complaining.
+ assert(false);
+ break;
+ }
+ }
+
+ ex->unknown = unknown;
+ _exception.reset(ex);
+
+ _state = StateLocalException; // The state must be set last, in case there is an exception.
+ break;
+ }
+
+ default:
+ {
+ _exception.reset(new UnknownReplyStatusException(__FILE__, __LINE__));
+ _state = StateLocalException;
+ break;
+ }
}
_monitor.notify();
diff --git a/cpp/src/Ice/OutgoingAsync.cpp b/cpp/src/Ice/OutgoingAsync.cpp
index e03c3b58d57..ad53705d9e9 100644
--- a/cpp/src/Ice/OutgoingAsync.cpp
+++ b/cpp/src/Ice/OutgoingAsync.cpp
@@ -56,148 +56,148 @@ IceInternal::OutgoingAsync::__finished(BasicStream& is)
try
{
- __is->swap(is);
-
- Byte b;
- __is->read(b);
- status = static_cast<DispatchStatus>(b);
-
- switch(status)
- {
- case DispatchOK:
- case DispatchUserException:
- {
- __is->startReadEncaps();
- break;
- }
-
- case DispatchObjectNotExist:
- case DispatchFacetNotExist:
- case DispatchOperationNotExist:
- {
- Identity ident;
- ident.__read(__is);
-
- //
- // For compatibility with the old FacetPath.
- //
- vector<string> facetPath;
- __is->read(facetPath);
- string facet;
- if(!facetPath.empty())
- {
- if(facetPath.size() > 1)
- {
- throw MarshalException(__FILE__, __LINE__);
- }
- facet.swap(facetPath[0]);
- }
-
- string operation;
- __is->read(operation, false);
-
- auto_ptr<RequestFailedException> ex;
- switch(static_cast<DispatchStatus>(status))
- {
- case DispatchObjectNotExist:
- {
- ex.reset(new ObjectNotExistException(__FILE__, __LINE__));
- break;
- }
-
- case DispatchFacetNotExist:
- {
- ex.reset(new FacetNotExistException(__FILE__, __LINE__));
- break;
- }
-
- case DispatchOperationNotExist:
- {
- ex.reset(new OperationNotExistException(__FILE__, __LINE__));
- break;
- }
-
- default:
- {
- assert(false);
- break;
- }
- }
-
- ex->id = ident;
- ex->facet = facet;
- ex->operation = operation;
- ex->ice_throw();
- }
-
- case DispatchUnknownException:
- case DispatchUnknownLocalException:
- case DispatchUnknownUserException:
- {
- string unknown;
- __is->read(unknown, false);
-
- auto_ptr<UnknownException> ex;
- switch(static_cast<DispatchStatus>(status))
- {
- case DispatchUnknownException:
- {
- ex.reset(new UnknownException(__FILE__, __LINE__));
- break;
- }
-
- case DispatchUnknownLocalException:
- {
- ex.reset(new UnknownLocalException(__FILE__, __LINE__));
- break;
- }
-
- case DispatchUnknownUserException:
- {
- ex.reset(new UnknownUserException(__FILE__, __LINE__));
- break;
- }
-
- default:
- {
- assert(false);
- break;
- }
- }
-
- ex->unknown = unknown;
- ex->ice_throw();
- }
-
- default:
- {
- throw UnknownReplyStatusException(__FILE__, __LINE__);
- }
- }
+ __is->swap(is);
+
+ Byte b;
+ __is->read(b);
+ status = static_cast<DispatchStatus>(b);
+
+ switch(status)
+ {
+ case DispatchOK:
+ case DispatchUserException:
+ {
+ __is->startReadEncaps();
+ break;
+ }
+
+ case DispatchObjectNotExist:
+ case DispatchFacetNotExist:
+ case DispatchOperationNotExist:
+ {
+ Identity ident;
+ ident.__read(__is);
+
+ //
+ // For compatibility with the old FacetPath.
+ //
+ vector<string> facetPath;
+ __is->read(facetPath);
+ string facet;
+ if(!facetPath.empty())
+ {
+ if(facetPath.size() > 1)
+ {
+ throw MarshalException(__FILE__, __LINE__);
+ }
+ facet.swap(facetPath[0]);
+ }
+
+ string operation;
+ __is->read(operation, false);
+
+ auto_ptr<RequestFailedException> ex;
+ switch(static_cast<DispatchStatus>(status))
+ {
+ case DispatchObjectNotExist:
+ {
+ ex.reset(new ObjectNotExistException(__FILE__, __LINE__));
+ break;
+ }
+
+ case DispatchFacetNotExist:
+ {
+ ex.reset(new FacetNotExistException(__FILE__, __LINE__));
+ break;
+ }
+
+ case DispatchOperationNotExist:
+ {
+ ex.reset(new OperationNotExistException(__FILE__, __LINE__));
+ break;
+ }
+
+ default:
+ {
+ assert(false);
+ break;
+ }
+ }
+
+ ex->id = ident;
+ ex->facet = facet;
+ ex->operation = operation;
+ ex->ice_throw();
+ }
+
+ case DispatchUnknownException:
+ case DispatchUnknownLocalException:
+ case DispatchUnknownUserException:
+ {
+ string unknown;
+ __is->read(unknown, false);
+
+ auto_ptr<UnknownException> ex;
+ switch(static_cast<DispatchStatus>(status))
+ {
+ case DispatchUnknownException:
+ {
+ ex.reset(new UnknownException(__FILE__, __LINE__));
+ break;
+ }
+
+ case DispatchUnknownLocalException:
+ {
+ ex.reset(new UnknownLocalException(__FILE__, __LINE__));
+ break;
+ }
+
+ case DispatchUnknownUserException:
+ {
+ ex.reset(new UnknownUserException(__FILE__, __LINE__));
+ break;
+ }
+
+ default:
+ {
+ assert(false);
+ break;
+ }
+ }
+
+ ex->unknown = unknown;
+ ex->ice_throw();
+ }
+
+ default:
+ {
+ throw UnknownReplyStatusException(__FILE__, __LINE__);
+ }
+ }
}
catch(const LocalException& ex)
{
- __finished(ex);
- return;
+ __finished(ex);
+ return;
}
assert(status == DispatchOK || status == DispatchUserException);
try
{
- __response(status == DispatchOK);
+ __response(status == DispatchOK);
}
catch(const Exception& ex)
{
- warning(ex);
+ warning(ex);
}
catch(const std::exception& ex)
{
- warning(ex);
+ warning(ex);
}
catch(...)
{
- warning();
+ warning();
}
cleanup();
@@ -210,48 +210,48 @@ IceInternal::OutgoingAsync::__finished(const LocalException& exc)
if(__os) // Don't retry if cleanup() was already called.
{
- //
- // A CloseConnectionException indicates graceful server
- // shutdown, and is therefore always repeatable without
- // violating "at-most-once". That's because by sending a close
- // connection message, the server guarantees that all
- // outstanding requests can safely be repeated. Otherwise, we
- // can also retry if the operation mode is Nonmutating or
- // Idempotent.
- //
- // An ObjectNotExistException can always be retried as
- // well without violating "at-most-once".
- //
- if(_mode == Nonmutating || _mode == Idempotent || dynamic_cast<const CloseConnectionException*>(&exc) ||
- dynamic_cast<const ObjectNotExistException*>(&exc))
- {
- try
- {
- _proxy->__handleException(_delegate, exc, _cnt);
- __send();
- return;
- }
- catch(const LocalException&)
- {
- }
- }
+ //
+ // A CloseConnectionException indicates graceful server
+ // shutdown, and is therefore always repeatable without
+ // violating "at-most-once". That's because by sending a close
+ // connection message, the server guarantees that all
+ // outstanding requests can safely be repeated. Otherwise, we
+ // can also retry if the operation mode is Nonmutating or
+ // Idempotent.
+ //
+ // An ObjectNotExistException can always be retried as
+ // well without violating "at-most-once".
+ //
+ if(_mode == Nonmutating || _mode == Idempotent || dynamic_cast<const CloseConnectionException*>(&exc) ||
+ dynamic_cast<const ObjectNotExistException*>(&exc))
+ {
+ try
+ {
+ _proxy->__handleException(_delegate, exc, _cnt);
+ __send();
+ return;
+ }
+ catch(const LocalException&)
+ {
+ }
+ }
}
try
{
- ice_exception(exc);
+ ice_exception(exc);
}
catch(const Exception& ex)
{
- warning(ex);
+ warning(ex);
}
catch(const std::exception& ex)
{
- warning(ex);
+ warning(ex);
}
catch(...)
{
- warning();
+ warning();
}
cleanup();
@@ -259,90 +259,90 @@ IceInternal::OutgoingAsync::__finished(const LocalException& exc)
void
IceInternal::OutgoingAsync::__prepare(const ObjectPrx& prx, const string& operation, OperationMode mode,
- const Context* context)
+ const Context* context)
{
IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(_monitor);
try
{
- //
- // We must first wait for other requests to finish.
- //
- while(__os)
- {
- _monitor.wait();
- }
-
- //
- // Can't call async via a oneway proxy.
- //
- prx->__checkTwowayOnly(operation);
-
- _proxy = prx;
+ //
+ // We must first wait for other requests to finish.
+ //
+ while(__os)
+ {
+ _monitor.wait();
+ }
+
+ //
+ // Can't call async via a oneway proxy.
+ //
+ prx->__checkTwowayOnly(operation);
+
+ _proxy = prx;
_delegate = 0;
- _cnt = 0;
- _mode = mode;
-
- ReferencePtr ref = _proxy->__reference();
- assert(!__is);
- __is = new BasicStream(ref->getInstance().get());
- assert(!__os);
- __os = new BasicStream(ref->getInstance().get());
-
- __os->writeBlob(requestHdr, sizeof(requestHdr));
-
- ref->getIdentity().__write(__os);
-
- //
- // For compatibility with the old FacetPath.
- //
- if(ref->getFacet().empty())
- {
- __os->write(static_cast<string*>(0), static_cast<string*>(0));
- }
- else
- {
- string facet = ref->getFacet();
- __os->write(&facet, &facet + 1);
- }
-
- __os->write(operation, false);
-
- __os->write(static_cast<Byte>(_mode));
-
- if(context != 0)
- {
- //
- // Explicit context
- //
- __write(__os, *context, __U__Context());
- }
- else
- {
- //
- // Implicit context
- //
- const ImplicitContextIPtr& implicitContext =
- ref->getInstance()->getImplicitContext();
-
- const Context& prxContext = ref->getContext()->getValue();
-
- if(implicitContext == 0)
- {
- __write(__os, prxContext, __U__Context());
- }
- else
- {
- implicitContext->write(prxContext, __os);
- }
- }
-
- __os->startWriteEncaps();
+ _cnt = 0;
+ _mode = mode;
+
+ ReferencePtr ref = _proxy->__reference();
+ assert(!__is);
+ __is = new BasicStream(ref->getInstance().get());
+ assert(!__os);
+ __os = new BasicStream(ref->getInstance().get());
+
+ __os->writeBlob(requestHdr, sizeof(requestHdr));
+
+ ref->getIdentity().__write(__os);
+
+ //
+ // For compatibility with the old FacetPath.
+ //
+ if(ref->getFacet().empty())
+ {
+ __os->write(static_cast<string*>(0), static_cast<string*>(0));
+ }
+ else
+ {
+ string facet = ref->getFacet();
+ __os->write(&facet, &facet + 1);
+ }
+
+ __os->write(operation, false);
+
+ __os->write(static_cast<Byte>(_mode));
+
+ if(context != 0)
+ {
+ //
+ // Explicit context
+ //
+ __write(__os, *context, __U__Context());
+ }
+ else
+ {
+ //
+ // Implicit context
+ //
+ const ImplicitContextIPtr& implicitContext =
+ ref->getInstance()->getImplicitContext();
+
+ const Context& prxContext = ref->getContext()->getValue();
+
+ if(implicitContext == 0)
+ {
+ __write(__os, prxContext, __U__Context());
+ }
+ else
+ {
+ implicitContext->write(prxContext, __os);
+ }
+ }
+
+ __os->startWriteEncaps();
}
catch(const LocalException& ex)
{
- cleanup();
- ex.ice_throw();
+ cleanup();
+ ex.ice_throw();
}
}
@@ -353,37 +353,37 @@ IceInternal::OutgoingAsync::__send()
try
{
- while(true)
- {
- bool compress;
- _delegate = _proxy->__getDelegate();
- Ice::ConnectionIPtr connection = _delegate->__getConnection(compress);
- try
- {
- connection->sendAsyncRequest(__os, this, compress);
-
- //
- // Don't do anything after sendAsyncRequest() returned
- // without an exception. I such case, there will be
- // callbacks, i.e., calls to the __finished()
- // functions. Since there is no mutex protection, we
- // cannot modify state here and in such callbacks.
- //
- return;
- }
- catch(const LocalExceptionWrapper& ex)
- {
- _proxy->__handleExceptionWrapper(_delegate, ex);
- }
- catch(const LocalException& ex)
- {
- _proxy->__handleException(_delegate, ex, _cnt);
- }
- }
+ while(true)
+ {
+ bool compress;
+ _delegate = _proxy->__getDelegate();
+ Ice::ConnectionIPtr connection = _delegate->__getConnection(compress);
+ try
+ {
+ connection->sendAsyncRequest(__os, this, compress);
+
+ //
+ // Don't do anything after sendAsyncRequest() returned
+ // without an exception. I such case, there will be
+ // callbacks, i.e., calls to the __finished()
+ // functions. Since there is no mutex protection, we
+ // cannot modify state here and in such callbacks.
+ //
+ return;
+ }
+ catch(const LocalExceptionWrapper& ex)
+ {
+ _proxy->__handleExceptionWrapper(_delegate, ex);
+ }
+ catch(const LocalException& ex)
+ {
+ _proxy->__handleException(_delegate, ex, _cnt);
+ }
+ }
}
catch(const LocalException& ex)
{
- __finished(ex);
+ __finished(ex);
}
}
@@ -392,13 +392,13 @@ IceInternal::OutgoingAsync::warning(const Exception& ex) const
{
if(__os) // Don't print anything if cleanup() was already called.
{
- ReferencePtr ref = _proxy->__reference();
- if(ref->getInstance()->initializationData().properties->
- getPropertyAsIntWithDefault("Ice.Warn.AMICallback", 1) > 0)
- {
- Warning out(ref->getInstance()->initializationData().logger);
- out << "Ice::Exception raised by AMI callback:\n" << ex;
- }
+ ReferencePtr ref = _proxy->__reference();
+ if(ref->getInstance()->initializationData().properties->
+ getPropertyAsIntWithDefault("Ice.Warn.AMICallback", 1) > 0)
+ {
+ Warning out(ref->getInstance()->initializationData().logger);
+ out << "Ice::Exception raised by AMI callback:\n" << ex;
+ }
}
}
@@ -407,13 +407,13 @@ IceInternal::OutgoingAsync::warning(const std::exception& ex) const
{
if(__os) // Don't print anything if cleanup() was already called.
{
- ReferencePtr ref = _proxy->__reference();
- if(ref->getInstance()->initializationData().properties->
- getPropertyAsIntWithDefault("Ice.Warn.AMICallback", 1) > 0)
- {
- Warning out(ref->getInstance()->initializationData().logger);
- out << "std::exception raised by AMI callback:\n" << ex.what();
- }
+ ReferencePtr ref = _proxy->__reference();
+ if(ref->getInstance()->initializationData().properties->
+ getPropertyAsIntWithDefault("Ice.Warn.AMICallback", 1) > 0)
+ {
+ Warning out(ref->getInstance()->initializationData().logger);
+ out << "std::exception raised by AMI callback:\n" << ex.what();
+ }
}
}
@@ -422,13 +422,13 @@ IceInternal::OutgoingAsync::warning() const
{
if(__os) // Don't print anything if cleanup() was already called.
{
- ReferencePtr ref = _proxy->__reference();
- if(ref->getInstance()->initializationData().properties->
- getPropertyAsIntWithDefault("Ice.Warn.AMICallback", 1) > 0)
- {
- Warning out(ref->getInstance()->initializationData().logger);
- out << "unknown exception raised by AMI callback";
- }
+ ReferencePtr ref = _proxy->__reference();
+ if(ref->getInstance()->initializationData().properties->
+ getPropertyAsIntWithDefault("Ice.Warn.AMICallback", 1) > 0)
+ {
+ Warning out(ref->getInstance()->initializationData().logger);
+ out << "unknown exception raised by AMI callback";
+ }
}
}
@@ -445,18 +445,18 @@ IceInternal::OutgoingAsync::cleanup()
void
Ice::AMI_Object_ice_invoke::__invoke(const ObjectPrx& prx, const string& operation, OperationMode mode,
- const vector<Byte>& inParams, const Context* context)
+ const vector<Byte>& inParams, const Context* context)
{
try
{
- __prepare(prx, operation, mode, context);
- __os->writeBlob(inParams);
- __os->endWriteEncaps();
+ __prepare(prx, operation, mode, context);
+ __os->writeBlob(inParams);
+ __os->endWriteEncaps();
}
catch(const LocalException& ex)
{
- __finished(ex);
- return;
+ __finished(ex);
+ return;
}
__send();
}
@@ -467,31 +467,31 @@ Ice::AMI_Object_ice_invoke::__response(bool ok) // ok == true means no user exce
vector<Byte> outParams;
try
{
- Int sz = __is->getReadEncapsSize();
- __is->readBlob(outParams, sz);
+ Int sz = __is->getReadEncapsSize();
+ __is->readBlob(outParams, sz);
}
catch(const LocalException& ex)
{
- __finished(ex);
- return;
+ __finished(ex);
+ return;
}
ice_response(ok, outParams);
}
void
Ice::AMI_Array_Object_ice_invoke::__invoke(const ObjectPrx& prx, const string& operation, OperationMode mode,
- const pair<const Byte*, const Byte*>& inParams, const Context* context)
+ const pair<const Byte*, const Byte*>& inParams, const Context* context)
{
try
{
- __prepare(prx, operation, mode, context);
- __os->writeBlob(inParams.first, static_cast<Int>(inParams.second - inParams.first));
- __os->endWriteEncaps();
+ __prepare(prx, operation, mode, context);
+ __os->writeBlob(inParams.first, static_cast<Int>(inParams.second - inParams.first));
+ __os->endWriteEncaps();
}
catch(const LocalException& ex)
{
- __finished(ex);
- return;
+ __finished(ex);
+ return;
}
__send();
}
@@ -502,14 +502,14 @@ Ice::AMI_Array_Object_ice_invoke::__response(bool ok) // ok == true means no use
pair<const Byte*, const Byte*> outParams;
try
{
- Int sz = __is->getReadEncapsSize();
- __is->readBlob(outParams.first, sz);
- outParams.second = outParams.first + sz;
+ Int sz = __is->getReadEncapsSize();
+ __is->readBlob(outParams.first, sz);
+ outParams.second = outParams.first + sz;
}
catch(const LocalException& ex)
{
- __finished(ex);
- return;
+ __finished(ex);
+ return;
}
ice_response(ok, outParams);
}
diff --git a/cpp/src/Ice/PluginManagerI.cpp b/cpp/src/Ice/PluginManagerI.cpp
index b199954e938..123c74c0be8 100644
--- a/cpp/src/Ice/PluginManagerI.cpp
+++ b/cpp/src/Ice/PluginManagerI.cpp
@@ -29,9 +29,9 @@ Ice::PluginManagerI::initializePlugins()
{
if(_initialized)
{
- InitializationException ex(__FILE__, __LINE__);
- ex.reason = "plugins already initialized";
- throw ex;
+ InitializationException ex(__FILE__, __LINE__);
+ ex.reason = "plugins already initialized";
+ throw ex;
}
//
@@ -40,30 +40,30 @@ Ice::PluginManagerI::initializePlugins()
vector<PluginPtr> initializedPlugins;
try
{
- for(vector<PluginPtr>::iterator p = _initOrder.begin(); p != _initOrder.end(); ++p)
- {
- (*p)->initialize();
- initializedPlugins.push_back(*p);
- }
+ for(vector<PluginPtr>::iterator p = _initOrder.begin(); p != _initOrder.end(); ++p)
+ {
+ (*p)->initialize();
+ initializedPlugins.push_back(*p);
+ }
}
catch(...)
{
- //
- // Destroy the plugins that have been successfully initialized, in the
- // reverse order.
- //
- for(vector<PluginPtr>::reverse_iterator p = initializedPlugins.rbegin(); p != initializedPlugins.rend(); ++p)
- {
- try
- {
- (*p)->destroy();
- }
- catch(...)
- {
- // Ignore.
- }
- }
- throw;
+ //
+ // Destroy the plugins that have been successfully initialized, in the
+ // reverse order.
+ //
+ for(vector<PluginPtr>::reverse_iterator p = initializedPlugins.rbegin(); p != initializedPlugins.rend(); ++p)
+ {
+ try
+ {
+ (*p)->destroy();
+ }
+ catch(...)
+ {
+ // Ignore.
+ }
+ }
+ throw;
}
_initialized = true;
@@ -76,7 +76,7 @@ Ice::PluginManagerI::getPlugin(const string& name)
if(!_communicator)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
map<string, PluginPtr>::const_iterator r = _plugins.find(name);
@@ -98,16 +98,16 @@ Ice::PluginManagerI::addPlugin(const string& name, const PluginPtr& plugin)
if(!_communicator)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
map<string, PluginPtr>::const_iterator r = _plugins.find(name);
if(r != _plugins.end())
{
AlreadyRegisteredException ex(__FILE__, __LINE__);
- ex.kindOfObject = _kindOfObject;
- ex.id = name;
- throw ex;
+ ex.kindOfObject = _kindOfObject;
+ ex.id = name;
+ throw ex;
}
_plugins[name] = plugin;
}
@@ -119,15 +119,15 @@ Ice::PluginManagerI::destroy()
if(_communicator)
{
- map<string, PluginPtr>::iterator r;
- for(r = _plugins.begin(); r != _plugins.end(); ++r)
- {
- r->second->destroy();
- r->second = 0;
- }
-
- _logger = 0;
- _communicator = 0;
+ map<string, PluginPtr>::iterator r;
+ for(r = _plugins.begin(); r != _plugins.end(); ++r)
+ {
+ r->second->destroy();
+ r->second = 0;
+ }
+
+ _logger = 0;
+ _communicator = 0;
}
_libraries = 0;
@@ -166,44 +166,44 @@ Ice::PluginManagerI::loadPlugins(int& argc, char* argv[])
string::size_type beg = 0;
if(!loadOrder.empty())
{
- const string delim = ", \t\n";
- beg = loadOrder.find_first_not_of(delim, beg);
- while(beg != string::npos)
- {
- string name;
- string::size_type end = loadOrder.find_first_of(delim, beg);
- if(end == string::npos)
- {
- name = loadOrder.substr(beg);
- beg = end;
- }
- else
- {
- name = loadOrder.substr(beg, end - beg);
- beg = loadOrder.find_first_not_of(delim, end);
- }
-
- map<string, PluginPtr>::iterator p = _plugins.find(name);
- if(p != _plugins.end())
- {
- PluginInitializationException ex(__FILE__, __LINE__);
- ex.reason = "plugin `" + name + "' already loaded";
- throw ex;
- }
-
- PropertyDict::iterator q = plugins.find("Ice.Plugin." + name);
- if(q != plugins.end())
- {
- loadPlugin(name, q->second, cmdArgs, false);
- plugins.erase(q);
- }
- else
- {
- PluginInitializationException ex(__FILE__, __LINE__);
- ex.reason = "plugin `" + name + "' not defined";
- throw ex;
- }
- }
+ const string delim = ", \t\n";
+ beg = loadOrder.find_first_not_of(delim, beg);
+ while(beg != string::npos)
+ {
+ string name;
+ string::size_type end = loadOrder.find_first_of(delim, beg);
+ if(end == string::npos)
+ {
+ name = loadOrder.substr(beg);
+ beg = end;
+ }
+ else
+ {
+ name = loadOrder.substr(beg, end - beg);
+ beg = loadOrder.find_first_not_of(delim, end);
+ }
+
+ map<string, PluginPtr>::iterator p = _plugins.find(name);
+ if(p != _plugins.end())
+ {
+ PluginInitializationException ex(__FILE__, __LINE__);
+ ex.reason = "plugin `" + name + "' already loaded";
+ throw ex;
+ }
+
+ PropertyDict::iterator q = plugins.find("Ice.Plugin." + name);
+ if(q != plugins.end())
+ {
+ loadPlugin(name, q->second, cmdArgs, false);
+ plugins.erase(q);
+ }
+ else
+ {
+ PluginInitializationException ex(__FILE__, __LINE__);
+ ex.reason = "plugin `" + name + "' not defined";
+ throw ex;
+ }
+ }
}
//
@@ -213,7 +213,7 @@ Ice::PluginManagerI::loadPlugins(int& argc, char* argv[])
for(p = plugins.begin(); p != plugins.end(); ++p)
{
string name = p->first.substr(prefix.size());
- loadPlugin(name, p->second, cmdArgs, false);
+ loadPlugin(name, p->second, cmdArgs, false);
}
string loggerStr = properties->getProperty("Ice.LoggerPlugin");
@@ -231,7 +231,7 @@ Ice::PluginManagerI::loadPlugins(int& argc, char* argv[])
//
if(properties->getPropertyAsIntWithDefault("Ice.InitPlugins", 1) > 0)
{
- initializePlugins();
+ initializePlugins();
}
}
@@ -249,26 +249,26 @@ Ice::PluginManagerI::loadPlugin(const string& name, const string& pluginSpec, St
string::size_type pos = pluginSpec.find_first_of(delim);
if(pos == string::npos)
{
- entryPoint = pluginSpec;
+ entryPoint = pluginSpec;
}
else
{
- entryPoint = pluginSpec.substr(0, pos);
- string::size_type beg = pluginSpec.find_first_not_of(delim, pos);
- while(beg != string::npos)
- {
- string::size_type end = pluginSpec.find_first_of(delim, beg);
- if(end == string::npos)
- {
- args.push_back(pluginSpec.substr(beg));
- beg = end;
- }
- else
- {
- args.push_back(pluginSpec.substr(beg, end - beg));
- beg = pluginSpec.find_first_not_of(delim, end);
- }
- }
+ entryPoint = pluginSpec.substr(0, pos);
+ string::size_type beg = pluginSpec.find_first_not_of(delim, pos);
+ while(beg != string::npos)
+ {
+ string::size_type end = pluginSpec.find_first_of(delim, beg);
+ if(end == string::npos)
+ {
+ args.push_back(pluginSpec.substr(beg));
+ beg = end;
+ }
+ else
+ {
+ args.push_back(pluginSpec.substr(beg, end - beg));
+ beg = pluginSpec.find_first_not_of(delim, end);
+ }
+ }
}
//
@@ -307,15 +307,15 @@ Ice::PluginManagerI::loadPlugin(const string& name, const string& pluginSpec, St
if(isLogger)
{
LOGGER_FACTORY factory = (LOGGER_FACTORY)sym;
- _logger = factory(_communicator, args);
- if(!_logger)
- {
+ _logger = factory(_communicator, args);
+ if(!_logger)
+ {
PluginInitializationException e(__FILE__, __LINE__);
ostringstream out;
out << "failure in entry point `" << entryPoint << "'";
e.reason = out.str();
throw e;
- }
+ }
}
else
{
diff --git a/cpp/src/Ice/PropertiesI.cpp b/cpp/src/Ice/PropertiesI.cpp
index 84b0f29bce3..86ddccf7cae 100644
--- a/cpp/src/Ice/PropertiesI.cpp
+++ b/cpp/src/Ice/PropertiesI.cpp
@@ -28,11 +28,11 @@ Ice::PropertiesI::getProperty(const string& key)
map<string, string>::const_iterator p = _properties.find(key);
if(p != _properties.end())
{
- return p->second;
+ return p->second;
}
else
{
- return string();
+ return string();
}
}
@@ -44,11 +44,11 @@ Ice::PropertiesI::getPropertyWithDefault(const string& key, const string& value)
map<string, string>::const_iterator p = _properties.find(key);
if(p != _properties.end())
{
- return p->second;
+ return p->second;
}
else
{
- return value;
+ return value;
}
}
@@ -66,11 +66,11 @@ Ice::PropertiesI::getPropertyAsIntWithDefault(const string& key, Int value)
map<string, string>::const_iterator p = _properties.find(key);
if(p != _properties.end())
{
- istringstream v(p->second);
- if(!(v >> value) || !v.eof())
- {
- return 0;
- }
+ istringstream v(p->second);
+ if(!(v >> value) || !v.eof())
+ {
+ return 0;
+ }
}
return value;
@@ -99,7 +99,7 @@ Ice::PropertiesI::setProperty(const string& key, const string& value)
{
if(key.empty())
{
- return;
+ return;
}
//
@@ -109,28 +109,28 @@ Ice::PropertiesI::setProperty(const string& key, const string& value)
string::size_type dotPos = key.find('.');
if(dotPos != string::npos)
{
- string prefix = key.substr(0, dotPos);
- for(const char* const** i = IceInternal::PropertyNames::validProps; *i != 0; ++i)
- {
- string pattern(*i[0]);
- dotPos = pattern.find('.');
- assert(dotPos != string::npos);
- string propPrefix = pattern.substr(0, dotPos);
- if(propPrefix != prefix)
- {
- continue;
- }
-
- bool found = false;
- for(const char* const* j = *i; *j != 0 && !found; ++j)
- {
- found = IceUtil::match(key, *j);
- }
- if(!found)
- {
- logger->warning("unknown property: " + key);
- }
- }
+ string prefix = key.substr(0, dotPos);
+ for(const char* const** i = IceInternal::PropertyNames::validProps; *i != 0; ++i)
+ {
+ string pattern(*i[0]);
+ dotPos = pattern.find('.');
+ assert(dotPos != string::npos);
+ string propPrefix = pattern.substr(0, dotPos);
+ if(propPrefix != prefix)
+ {
+ continue;
+ }
+
+ bool found = false;
+ for(const char* const* j = *i; *j != 0 && !found; ++j)
+ {
+ found = IceUtil::match(key, *j);
+ }
+ if(!found)
+ {
+ logger->warning("unknown property: " + key);
+ }
+ }
}
IceUtil::Mutex::Lock sync(*this);
@@ -140,11 +140,11 @@ Ice::PropertiesI::setProperty(const string& key, const string& value)
//
if(!value.empty())
{
- _properties[key] = value;
+ _properties[key] = value;
}
else
{
- _properties.erase(key);
+ _properties.erase(key);
}
}
@@ -158,7 +158,7 @@ Ice::PropertiesI::getCommandLineOptions()
map<string, string>::const_iterator p;
for(p = _properties.begin(); p != _properties.end(); ++p)
{
- result.push_back("--" + p->first + "=" + p->second);
+ result.push_back("--" + p->first + "=" + p->second);
}
return result;
}
@@ -169,7 +169,7 @@ Ice::PropertiesI::parseCommandLineOptions(const string& prefix, const StringSeq&
string pfx = prefix;
if(!pfx.empty() && pfx[pfx.size() - 1] != '.')
{
- pfx += '.';
+ pfx += '.';
}
pfx = "--" + pfx;
@@ -215,7 +215,7 @@ Ice::PropertiesI::load(const std::string& file)
if(!in)
{
FileException ex(__FILE__, __LINE__);
- ex.path = file;
+ ex.path = file;
ex.error = getSystemErrno();
throw ex;
}
@@ -223,7 +223,7 @@ Ice::PropertiesI::load(const std::string& file)
char line[1024];
while(in.getline(line, 1024))
{
- parseLine(line, _converter);
+ parseLine(line, _converter);
}
}
@@ -250,24 +250,24 @@ Ice::PropertiesI::PropertiesI(StringSeq& args, const PropertiesPtr& defaults, co
{
if(defaults != 0)
{
- _properties = defaults->getPropertiesForPrefix("");
+ _properties = defaults->getPropertiesForPrefix("");
}
StringSeq::iterator q = args.begin();
if(_properties.find("Ice.ProgramName") == _properties.end())
{
- if(q != args.end())
- {
- //
- // Use the first argument as the value for Ice.ProgramName. Replace
- // any backslashes in this value with forward slashes, in case this
- // value is used by the event logger.
- //
- string name = *q;
- replace(name.begin(), name.end(), '\\', '/');
- setProperty("Ice.ProgramName", name);
- }
+ if(q != args.end())
+ {
+ //
+ // Use the first argument as the value for Ice.ProgramName. Replace
+ // any backslashes in this value with forward slashes, in case this
+ // value is used by the event logger.
+ //
+ string name = *q;
+ replace(name.begin(), name.end(), '\\', '/');
+ setProperty("Ice.ProgramName", name);
+ }
}
StringSeq tmp;
@@ -283,27 +283,27 @@ Ice::PropertiesI::PropertiesI(StringSeq& args, const PropertiesPtr& defaults, co
s += "=1";
}
parseLine(s.substr(2), 0);
- loadConfigFiles = true;
+ loadConfigFiles = true;
}
else
{
- tmp.push_back(s);
+ tmp.push_back(s);
}
- ++q;
+ ++q;
}
args = tmp;
if(!loadConfigFiles)
{
- //
- // If Ice.Config is not set, load from ICE_CONFIG (if set)
- //
- loadConfigFiles = (_properties.find("Ice.Config") == _properties.end());
+ //
+ // If Ice.Config is not set, load from ICE_CONFIG (if set)
+ //
+ loadConfigFiles = (_properties.find("Ice.Config") == _properties.end());
}
if(loadConfigFiles)
{
- loadConfig();
+ loadConfig();
}
args = parseIceCommandLineOptions(args);
@@ -319,25 +319,25 @@ Ice::PropertiesI::parseLine(const string& line, const StringConverterPtr& conver
string::size_type idx = s.find('#');
if(idx != string::npos)
{
- s.erase(idx);
+ s.erase(idx);
}
idx = s.find_last_not_of(delim);
if(idx != string::npos && idx + 1 < s.length())
{
- s.erase(idx + 1);
+ s.erase(idx + 1);
}
string::size_type beg = s.find_first_not_of(delim);
if(beg == string::npos)
{
- return;
+ return;
}
string::size_type end = s.find_first_of(delim + "=", beg);
if(end == string::npos)
{
- return;
+ return;
}
string key = s.substr(beg, end - beg);
@@ -345,7 +345,7 @@ Ice::PropertiesI::parseLine(const string& line, const StringConverterPtr& conver
end = s.find('=', end);
if(end == string::npos)
{
- return;
+ return;
}
++end;
@@ -353,20 +353,20 @@ Ice::PropertiesI::parseLine(const string& line, const StringConverterPtr& conver
beg = s.find_first_not_of(delim, end);
if(beg != string::npos)
{
- end = s.length();
- value = s.substr(beg, end - beg);
+ end = s.length();
+ value = s.substr(beg, end - beg);
}
if(converter)
{
string tmp;
- converter->fromUTF8(reinterpret_cast<const Byte*>(key.data()),
- reinterpret_cast<const Byte*>(key.data() + key.size()), tmp);
- key.swap(tmp);
+ converter->fromUTF8(reinterpret_cast<const Byte*>(key.data()),
+ reinterpret_cast<const Byte*>(key.data() + key.size()), tmp);
+ key.swap(tmp);
- converter->fromUTF8(reinterpret_cast<const Byte*>(value.data()),
- reinterpret_cast<const Byte*>(value.data() + value.size()), tmp);
- value.swap(tmp);
+ converter->fromUTF8(reinterpret_cast<const Byte*>(value.data()),
+ reinterpret_cast<const Byte*>(value.data() + value.size()), tmp);
+ value.swap(tmp);
}
setProperty(key, value);
diff --git a/cpp/src/Ice/Protocol.cpp b/cpp/src/Ice/Protocol.cpp
index 793748dbae2..fbe3f832934 100644
--- a/cpp/src/Ice/Protocol.cpp
+++ b/cpp/src/Ice/Protocol.cpp
@@ -12,7 +12,7 @@
namespace IceInternal
{
-const Ice::Byte magic[] = { 0x49, 0x63, 0x65, 0x50 }; // 'I', 'c', 'e', 'P'
+const Ice::Byte magic[] = { 0x49, 0x63, 0x65, 0x50 }; // 'I', 'c', 'e', 'P'
#ifdef __BCPLUSPLUS__
const Ice::Byte requestHdr[headerSize + sizeof(Ice::Int)] =
diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp
index eb20297fb6a..2ad7d17e5da 100644
--- a/cpp/src/Ice/Proxy.cpp
+++ b/cpp/src/Ice/Proxy.cpp
@@ -56,23 +56,23 @@ IceInternal::checkedCastImpl(const ObjectPrx& b, const string& f, const string&
if(b)
{
- ObjectPrx bb = b->ice_facet(f);
- try
- {
- if(context == 0 ? bb->ice_isA(typeId) : bb->ice_isA(typeId, *context))
- {
- return bb;
- }
+ ObjectPrx bb = b->ice_facet(f);
+ try
+ {
+ if(context == 0 ? bb->ice_isA(typeId) : bb->ice_isA(typeId, *context))
+ {
+ return bb;
+ }
#ifndef NDEBUG
- else
- {
- assert(typeId != "::Ice::Object");
- }
+ else
+ {
+ assert(typeId != "::Ice::Object");
+ }
#endif
- }
- catch(const FacetNotExistException&)
- {
- }
+ }
+ catch(const FacetNotExistException&)
+ {
+ }
}
return 0;
}
@@ -132,21 +132,21 @@ IceProxy::Ice::Object::ice_isA(const string& typeId, const Context* context)
int __cnt = 0;
while(true)
{
- Handle< ::IceDelegate::Ice::Object> __del;
- try
- {
- __checkTwowayOnly("ice_isA");
- __del = __getDelegate();
- return __del->ice_isA(typeId, context);
- }
- catch(const LocalExceptionWrapper& __ex)
- {
- __handleExceptionWrapperRelaxed(__del, __ex, __cnt);
- }
- catch(const LocalException& __ex)
- {
- __handleException(__del, __ex, __cnt);
- }
+ Handle< ::IceDelegate::Ice::Object> __del;
+ try
+ {
+ __checkTwowayOnly("ice_isA");
+ __del = __getDelegate();
+ return __del->ice_isA(typeId, context);
+ }
+ catch(const LocalExceptionWrapper& __ex)
+ {
+ __handleExceptionWrapperRelaxed(__del, __ex, __cnt);
+ }
+ catch(const LocalException& __ex)
+ {
+ __handleException(__del, __ex, __cnt);
+ }
}
}
@@ -156,21 +156,21 @@ IceProxy::Ice::Object::ice_ping(const Context* context)
int __cnt = 0;
while(true)
{
- Handle< ::IceDelegate::Ice::Object> __del;
- try
- {
- __del = __getDelegate();
- __del->ice_ping(context);
- return;
- }
- catch(const LocalExceptionWrapper& __ex)
- {
- __handleExceptionWrapperRelaxed(__del, __ex, __cnt);
- }
- catch(const LocalException& __ex)
- {
- __handleException(__del, __ex, __cnt);
- }
+ Handle< ::IceDelegate::Ice::Object> __del;
+ try
+ {
+ __del = __getDelegate();
+ __del->ice_ping(context);
+ return;
+ }
+ catch(const LocalExceptionWrapper& __ex)
+ {
+ __handleExceptionWrapperRelaxed(__del, __ex, __cnt);
+ }
+ catch(const LocalException& __ex)
+ {
+ __handleException(__del, __ex, __cnt);
+ }
}
}
@@ -180,21 +180,21 @@ IceProxy::Ice::Object::ice_ids(const Context* context)
int __cnt = 0;
while(true)
{
- Handle< ::IceDelegate::Ice::Object> __del;
- try
- {
- __checkTwowayOnly("ice_ids");
- __del = __getDelegate();
- return __del->ice_ids(context);
- }
- catch(const LocalExceptionWrapper& __ex)
- {
- __handleExceptionWrapperRelaxed(__del, __ex, __cnt);
- }
- catch(const LocalException& __ex)
- {
- __handleException(__del, __ex, __cnt);
- }
+ Handle< ::IceDelegate::Ice::Object> __del;
+ try
+ {
+ __checkTwowayOnly("ice_ids");
+ __del = __getDelegate();
+ return __del->ice_ids(context);
+ }
+ catch(const LocalExceptionWrapper& __ex)
+ {
+ __handleExceptionWrapperRelaxed(__del, __ex, __cnt);
+ }
+ catch(const LocalException& __ex)
+ {
+ __handleException(__del, __ex, __cnt);
+ }
}
}
@@ -204,31 +204,31 @@ IceProxy::Ice::Object::ice_id(const Context* context)
int __cnt = 0;
while(true)
{
- Handle< ::IceDelegate::Ice::Object> __del;
- try
- {
- __checkTwowayOnly("ice_id");
- __del = __getDelegate();
- return __del->ice_id(context);
- }
- catch(const LocalExceptionWrapper& __ex)
- {
- __handleExceptionWrapperRelaxed(__del, __ex, __cnt);
- }
- catch(const LocalException& __ex)
- {
- __handleException(__del, __ex, __cnt);
- }
+ Handle< ::IceDelegate::Ice::Object> __del;
+ try
+ {
+ __checkTwowayOnly("ice_id");
+ __del = __getDelegate();
+ return __del->ice_id(context);
+ }
+ catch(const LocalExceptionWrapper& __ex)
+ {
+ __handleExceptionWrapperRelaxed(__del, __ex, __cnt);
+ }
+ catch(const LocalException& __ex)
+ {
+ __handleException(__del, __ex, __cnt);
+ }
}
}
bool
IceProxy::Ice::Object::ice_invoke(const string& operation,
- OperationMode mode,
- const vector<Byte>& inParams,
- vector<Byte>& outParams,
- const Context* context)
+ OperationMode mode,
+ const vector<Byte>& inParams,
+ vector<Byte>& outParams,
+ const Context* context)
{
pair<const Byte*, const Byte*> inPair;
if(inParams.size() == 0)
@@ -238,7 +238,7 @@ IceProxy::Ice::Object::ice_invoke(const string& operation,
else
{
inPair.first = &inParams[0];
- inPair.second = inPair.first + inParams.size();
+ inPair.second = inPair.first + inParams.size();
}
return ice_invoke(operation, mode, inPair, outParams, context);
}
@@ -246,73 +246,73 @@ IceProxy::Ice::Object::ice_invoke(const string& operation,
bool
IceProxy::Ice::Object::ice_invoke(const string& operation,
- OperationMode mode,
- const pair<const Byte*, const Byte*>& inParams,
- vector<Byte>& outParams,
- const Context* context)
+ OperationMode mode,
+ const pair<const Byte*, const Byte*>& inParams,
+ vector<Byte>& outParams,
+ const Context* context)
{
int __cnt = 0;
while(true)
{
- Handle< ::IceDelegate::Ice::Object> __del;
- try
- {
- __del = __getDelegate();
- return __del->ice_invoke(operation, mode, inParams, outParams, context);
- }
- catch(const LocalExceptionWrapper& __ex)
- {
- bool canRetry = mode == Nonmutating || mode == Idempotent;
- if(canRetry)
- {
- __handleExceptionWrapperRelaxed(__del, __ex, __cnt);
- }
- else
- {
- __handleExceptionWrapper(__del, __ex);
- }
- }
- catch(const LocalException& __ex)
- {
- __handleException(__del, __ex, __cnt);
- }
+ Handle< ::IceDelegate::Ice::Object> __del;
+ try
+ {
+ __del = __getDelegate();
+ return __del->ice_invoke(operation, mode, inParams, outParams, context);
+ }
+ catch(const LocalExceptionWrapper& __ex)
+ {
+ bool canRetry = mode == Nonmutating || mode == Idempotent;
+ if(canRetry)
+ {
+ __handleExceptionWrapperRelaxed(__del, __ex, __cnt);
+ }
+ else
+ {
+ __handleExceptionWrapper(__del, __ex);
+ }
+ }
+ catch(const LocalException& __ex)
+ {
+ __handleException(__del, __ex, __cnt);
+ }
}
}
void
IceProxy::Ice::Object::ice_invoke_async(const AMI_Object_ice_invokePtr& cb,
- const string& operation,
- OperationMode mode,
- const vector<Byte>& inParams)
+ const string& operation,
+ OperationMode mode,
+ const vector<Byte>& inParams)
{
cb->__invoke(this, operation, mode, inParams, 0);
}
void
IceProxy::Ice::Object::ice_invoke_async(const AMI_Object_ice_invokePtr& cb,
- const string& operation,
- OperationMode mode,
- const vector<Byte>& inParams,
- const Context& context)
+ const string& operation,
+ OperationMode mode,
+ const vector<Byte>& inParams,
+ const Context& context)
{
cb->__invoke(this, operation, mode, inParams, &context);
}
void
IceProxy::Ice::Object::ice_invoke_async(const AMI_Array_Object_ice_invokePtr& cb,
- const string& operation,
- OperationMode mode,
- const pair<const Byte*, const Byte*>& inParams)
+ const string& operation,
+ OperationMode mode,
+ const pair<const Byte*, const Byte*>& inParams)
{
cb->__invoke(this, operation, mode, inParams, 0);
}
void
IceProxy::Ice::Object::ice_invoke_async(const AMI_Array_Object_ice_invokePtr& cb,
- const string& operation,
- OperationMode mode,
- const pair<const Byte*, const Byte*>& inParams,
- const Context& context)
+ const string& operation,
+ OperationMode mode,
+ const pair<const Byte*, const Byte*>& inParams,
+ const Context& context)
{
cb->__invoke(this, operation, mode, inParams, &context);
}
@@ -332,13 +332,13 @@ IceProxy::Ice::Object::ice_identity(const Identity& newIdentity) const
}
if(newIdentity == _reference->getIdentity())
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->changeIdentity(newIdentity));
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->changeIdentity(newIdentity));
+ return proxy;
}
}
@@ -387,13 +387,13 @@ IceProxy::Ice::Object::ice_facet(const string& newFacet) const
{
if(newFacet == _reference->getFacet())
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->changeFacet(newFacet));
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->changeFacet(newFacet));
+ return proxy;
}
}
@@ -414,13 +414,13 @@ IceProxy::Ice::Object::ice_adapterId(const string& newAdapterId) const
{
if(newAdapterId == _reference->getAdapterId())
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->changeAdapterId(newAdapterId));
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->changeAdapterId(newAdapterId));
+ return proxy;
}
}
@@ -437,7 +437,7 @@ IceProxy::Ice::Object::ice_getEndpoints() const
EndpointSeq retSeq;
for(vector<EndpointIPtr>::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p)
{
- retSeq.push_back(EndpointPtr::dynamicCast(*p));
+ retSeq.push_back(EndpointPtr::dynamicCast(*p));
}
return retSeq;
}
@@ -448,18 +448,18 @@ IceProxy::Ice::Object::ice_endpoints(const EndpointSeq& newEndpoints) const
vector<EndpointIPtr> endpoints;
for(EndpointSeq::const_iterator p = newEndpoints.begin(); p != newEndpoints.end(); ++p)
{
- endpoints.push_back(EndpointIPtr::dynamicCast(*p));
+ endpoints.push_back(EndpointIPtr::dynamicCast(*p));
}
if(endpoints == _reference->getEndpoints())
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->changeEndpoints(endpoints));
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->changeEndpoints(endpoints));
+ return proxy;
}
}
@@ -480,13 +480,13 @@ IceProxy::Ice::Object::ice_locatorCacheTimeout(Int newTimeout) const
{
if(newTimeout == _reference->getLocatorCacheTimeout())
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->changeLocatorCacheTimeout(newTimeout));
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->changeLocatorCacheTimeout(newTimeout));
+ return proxy;
}
}
@@ -501,13 +501,13 @@ IceProxy::Ice::Object::ice_connectionCached(bool newCache) const
{
if(newCache == _reference->getCacheConnection())
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->changeCacheConnection(newCache));
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->changeCacheConnection(newCache));
+ return proxy;
}
}
@@ -522,13 +522,13 @@ IceProxy::Ice::Object::ice_endpointSelection(EndpointSelectionType newType) cons
{
if(newType == _reference->getEndpointSelection())
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->changeEndpointSelection(newType));
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->changeEndpointSelection(newType));
+ return proxy;
}
}
@@ -543,13 +543,13 @@ IceProxy::Ice::Object::ice_secure(bool b) const
{
if(b == _reference->getSecure())
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->changeSecure(b));
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->changeSecure(b));
+ return proxy;
}
}
@@ -564,13 +564,13 @@ IceProxy::Ice::Object::ice_preferSecure(bool b) const
{
if(b == _reference->getPreferSecure())
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->changePreferSecure(b));
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->changePreferSecure(b));
+ return proxy;
}
}
@@ -587,13 +587,13 @@ IceProxy::Ice::Object::ice_router(const RouterPrx& router) const
ReferencePtr ref = _reference->changeRouter(router);
if(ref == _reference)
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(ref);
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(ref);
+ return proxy;
}
}
@@ -610,13 +610,13 @@ IceProxy::Ice::Object::ice_locator(const LocatorPrx& locator) const
ReferencePtr ref = _reference->changeLocator(locator);
if(ref == _reference)
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(ref);
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(ref);
+ return proxy;
}
}
@@ -637,13 +637,13 @@ IceProxy::Ice::Object::ice_collocationOptimized(bool b) const
{
if(b == _reference->getCollocationOptimization())
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->changeCollocationOptimization(b));
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->changeCollocationOptimization(b));
+ return proxy;
}
}
@@ -652,13 +652,13 @@ IceProxy::Ice::Object::ice_twoway() const
{
if(_reference->getMode() == Reference::ModeTwoway)
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->changeMode(Reference::ModeTwoway));
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->changeMode(Reference::ModeTwoway));
+ return proxy;
}
}
@@ -673,13 +673,13 @@ IceProxy::Ice::Object::ice_oneway() const
{
if(_reference->getMode() == Reference::ModeOneway)
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->changeMode(Reference::ModeOneway));
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->changeMode(Reference::ModeOneway));
+ return proxy;
}
}
@@ -694,13 +694,13 @@ IceProxy::Ice::Object::ice_batchOneway() const
{
if(_reference->getMode() == Reference::ModeBatchOneway)
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->changeMode(Reference::ModeBatchOneway));
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->changeMode(Reference::ModeBatchOneway));
+ return proxy;
}
}
@@ -715,13 +715,13 @@ IceProxy::Ice::Object::ice_datagram() const
{
if(_reference->getMode() == Reference::ModeDatagram)
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->changeMode(Reference::ModeDatagram));
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->changeMode(Reference::ModeDatagram));
+ return proxy;
}
}
@@ -736,13 +736,13 @@ IceProxy::Ice::Object::ice_batchDatagram() const
{
if(_reference->getMode() == Reference::ModeBatchDatagram)
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->changeMode(Reference::ModeBatchDatagram));
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->changeMode(Reference::ModeBatchDatagram));
+ return proxy;
}
}
@@ -758,13 +758,13 @@ IceProxy::Ice::Object::ice_compress(bool b) const
ReferencePtr ref = _reference->changeCompress(b);
if(ref == _reference)
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(ref);
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(ref);
+ return proxy;
}
}
@@ -774,13 +774,13 @@ IceProxy::Ice::Object::ice_timeout(int t) const
ReferencePtr ref = _reference->changeTimeout(t);
if(ref == _reference)
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(ref);
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(ref);
+ return proxy;
}
}
@@ -790,13 +790,13 @@ IceProxy::Ice::Object::ice_connectionId(const string& id) const
ReferencePtr ref = _reference->changeConnectionId(id);
if(ref == _reference)
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(ref);
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(ref);
+ return proxy;
}
}
@@ -834,17 +834,17 @@ IceProxy::Ice::Object::ice_getConnection()
int __cnt = 0;
while(true)
{
- Handle< ::IceDelegate::Ice::Object> __del;
- try
- {
- __del = __getDelegate();
- bool compress;
- return __del->__getConnection(compress);
- }
- catch(const LocalException& __ex)
- {
- __handleException(__del, __ex, __cnt);
- }
+ Handle< ::IceDelegate::Ice::Object> __del;
+ try
+ {
+ __del = __getDelegate();
+ bool compress;
+ return __del->__getConnection(compress);
+ }
+ catch(const LocalException& __ex)
+ {
+ __handleException(__del, __ex, __cnt);
+ }
}
}
@@ -853,20 +853,20 @@ IceProxy::Ice::Object::ice_getCachedConnection() const
{
Handle< ::IceDelegate::Ice::Object> __del;
{
- IceUtil::Mutex::Lock sync(*this);
- __del = _delegate;
+ IceUtil::Mutex::Lock sync(*this);
+ __del = _delegate;
}
if(__del)
{
- try
- {
- bool compress;
- return __del->__getConnection(compress);
- }
- catch(const CollocationOptimizationException&)
- {
- }
+ try
+ {
+ bool compress;
+ return __del->__getConnection(compress);
+ }
+ catch(const CollocationOptimizationException&)
+ {
+ }
}
return 0;
}
@@ -885,11 +885,11 @@ IceProxy::Ice::Object::__copyFrom(const ObjectPrx& from)
Handle< ::IceDelegateM::Ice::Object> delegateM;
{
- IceUtil::Mutex::Lock sync(*from.get());
+ IceUtil::Mutex::Lock sync(*from.get());
- ref = from->_reference;
- delegateD = dynamic_cast< ::IceDelegateD::Ice::Object*>(from->_delegate.get());
- delegateM = dynamic_cast< ::IceDelegateM::Ice::Object*>(from->_delegate.get());
+ ref = from->_reference;
+ delegateD = dynamic_cast< ::IceDelegateD::Ice::Object*>(from->_delegate.get());
+ delegateM = dynamic_cast< ::IceDelegateM::Ice::Object*>(from->_delegate.get());
}
//
@@ -904,31 +904,31 @@ IceProxy::Ice::Object::__copyFrom(const ObjectPrx& from)
if(_reference->getCacheConnection())
{
- //
- // The _delegate attribute is only used if "cache connection"
- // is enabled. If it's not enabled, we don't keep track of the
- // delegate -- a new delegate is created for each invocations.
- //
+ //
+ // The _delegate attribute is only used if "cache connection"
+ // is enabled. If it's not enabled, we don't keep track of the
+ // delegate -- a new delegate is created for each invocations.
+ //
- if(delegateD)
- {
- Handle< ::IceDelegateD::Ice::Object> delegate = __createDelegateD();
- delegate->__copyFrom(delegateD);
- _delegate = delegate;
- }
- else if(delegateM)
- {
- Handle< ::IceDelegateM::Ice::Object> delegate = __createDelegateM();
- delegate->__copyFrom(delegateM);
- _delegate = delegate;
- }
+ if(delegateD)
+ {
+ Handle< ::IceDelegateD::Ice::Object> delegate = __createDelegateD();
+ delegate->__copyFrom(delegateD);
+ _delegate = delegate;
+ }
+ else if(delegateM)
+ {
+ Handle< ::IceDelegateM::Ice::Object> delegate = __createDelegateM();
+ delegate->__copyFrom(delegateM);
+ _delegate = delegate;
+ }
}
}
void
IceProxy::Ice::Object::__handleException(const ::IceInternal::Handle< ::IceDelegate::Ice::Object>& delegate,
- const LocalException& ex,
- int& cnt)
+ const LocalException& ex,
+ int& cnt)
{
//
// Only _delegate needs to be mutex protected here.
@@ -936,7 +936,7 @@ IceProxy::Ice::Object::__handleException(const ::IceInternal::Handle< ::IceDeleg
IceUtil::Mutex::Lock sync(*this);
if(delegate.get() == _delegate.get())
{
- _delegate = 0;
+ _delegate = 0;
}
ProxyFactoryPtr proxyFactory;
@@ -946,9 +946,9 @@ IceProxy::Ice::Object::__handleException(const ::IceInternal::Handle< ::IceDeleg
}
catch(const CommunicatorDestroyedException&)
{
- //
- // The communicator is already destroyed, so we cannot retry.
- //
+ //
+ // The communicator is already destroyed, so we cannot retry.
+ //
ex.ice_throw();
}
@@ -958,37 +958,37 @@ IceProxy::Ice::Object::__handleException(const ::IceInternal::Handle< ::IceDeleg
void
IceProxy::Ice::Object::__handleExceptionWrapper(const ::IceInternal::Handle< ::IceDelegate::Ice::Object>& delegate,
- const LocalExceptionWrapper& ex)
+ const LocalExceptionWrapper& ex)
{
{
- IceUtil::Mutex::Lock sync(*this);
- if(delegate.get() == _delegate.get())
- {
- _delegate = 0;
- }
+ IceUtil::Mutex::Lock sync(*this);
+ if(delegate.get() == _delegate.get())
+ {
+ _delegate = 0;
+ }
}
if(!ex.retry())
{
- ex.get()->ice_throw();
+ ex.get()->ice_throw();
}
}
void
IceProxy::Ice::Object::__handleExceptionWrapperRelaxed(const ::IceInternal::Handle< ::IceDelegate::Ice::Object>& del,
- const LocalExceptionWrapper& ex, int& cnt)
+ const LocalExceptionWrapper& ex, int& cnt)
{
if(!ex.retry())
{
- __handleException(del, *ex.get(), cnt);
+ __handleException(del, *ex.get(), cnt);
}
else
{
- IceUtil::Mutex::Lock sync(*this);
- if(del.get() == _delegate.get())
- {
- _delegate = 0;
- }
+ IceUtil::Mutex::Lock sync(*this);
+ if(del.get() == _delegate.get())
+ {
+ _delegate = 0;
+ }
}
}
@@ -1009,8 +1009,8 @@ IceProxy::Ice::Object::__checkTwowayOnly(const char* name) const
if(!ice_isTwoway())
{
TwowayOnlyException ex(__FILE__, __LINE__);
- ex.operation = name;
- throw ex;
+ ex.operation = name;
+ throw ex;
}
}
@@ -1025,8 +1025,8 @@ IceProxy::Ice::Object::__checkTwowayOnly(const string& name) const
if(!ice_isTwoway())
{
TwowayOnlyException ex(__FILE__, __LINE__);
- ex.operation = name;
- throw ex;
+ ex.operation = name;
+ throw ex;
}
}
@@ -1043,47 +1043,47 @@ IceProxy::Ice::Object::__getDelegate()
if(_delegate)
{
- return _delegate;
+ return _delegate;
}
Handle< ::IceDelegate::Ice::Object> delegate;
if(_reference->getCollocationOptimization())
{
- ObjectAdapterPtr adapter = _reference->getInstance()->objectAdapterFactory()->findObjectAdapter(this);
- if(adapter)
- {
- Handle< ::IceDelegateD::Ice::Object> d = __createDelegateD();
- d->setup(_reference, adapter);
- delegate = d;
- }
+ ObjectAdapterPtr adapter = _reference->getInstance()->objectAdapterFactory()->findObjectAdapter(this);
+ if(adapter)
+ {
+ Handle< ::IceDelegateD::Ice::Object> d = __createDelegateD();
+ d->setup(_reference, adapter);
+ delegate = d;
+ }
}
if(!delegate)
{
- Handle< ::IceDelegateM::Ice::Object> d = __createDelegateM();
- d->setup(_reference);
- delegate = d;
-
- //
- // If this proxy is for a non-local object, and we are
- // using a router, then add this proxy to the router info
- // object.
- //
- RouterInfoPtr ri = _reference->getRouterInfo();
- if(ri)
- {
- ri->addProxy(this);
- }
+ Handle< ::IceDelegateM::Ice::Object> d = __createDelegateM();
+ d->setup(_reference);
+ delegate = d;
+
+ //
+ // If this proxy is for a non-local object, and we are
+ // using a router, then add this proxy to the router info
+ // object.
+ //
+ RouterInfoPtr ri = _reference->getRouterInfo();
+ if(ri)
+ {
+ ri->addProxy(this);
+ }
}
if(_reference->getCacheConnection())
{
- //
- // The _delegate attribute is only used if "cache connection"
- // is enabled. If it's not enabled, we don't keep track of the
- // delegate -- a new delegate is created for each invocations.
- //
- _delegate = delegate;
+ //
+ // The _delegate attribute is only used if "cache connection"
+ // is enabled. If it's not enabled, we don't keep track of the
+ // delegate -- a new delegate is created for each invocations.
+ //
+ _delegate = delegate;
}
return delegate;
@@ -1126,34 +1126,34 @@ IceDelegateM::Ice::Object::ice_isA(const string& __id, const Context* context)
Outgoing __og(__connection.get(), __reference.get(), __operation, ::Ice::Nonmutating, context, __compress);
try
{
- BasicStream* __os = __og.os();
- __os->write(__id, false);
+ BasicStream* __os = __og.os();
+ __os->write(__id, false);
}
catch(const ::Ice::LocalException& __ex)
{
- __og.abort(__ex);
+ __og.abort(__ex);
}
bool __ret;
bool __ok = __og.invoke();
try
{
- BasicStream* __is = __og.is();
- if(!__ok)
- {
- try
- {
- __is->throwException();
- }
- catch(const ::Ice::UserException& __ex)
- {
- throw ::Ice::UnknownUserException(__FILE__, __LINE__, __ex.ice_name());
- }
- }
+ BasicStream* __is = __og.is();
+ if(!__ok)
+ {
+ try
+ {
+ __is->throwException();
+ }
+ catch(const ::Ice::UserException& __ex)
+ {
+ throw ::Ice::UnknownUserException(__FILE__, __LINE__, __ex.ice_name());
+ }
+ }
__is->read(__ret);
}
catch(const ::Ice::LocalException& __ex)
{
- throw ::IceInternal::LocalExceptionWrapper(__ex, false);
+ throw ::IceInternal::LocalExceptionWrapper(__ex, false);
}
return __ret;
}
@@ -1166,22 +1166,22 @@ IceDelegateM::Ice::Object::ice_ping(const Context* context)
bool __ok = __og.invoke();
try
{
- BasicStream* __is = __og.is();
- if(!__ok)
- {
- try
- {
- __is->throwException();
- }
- catch(const ::Ice::UserException& __ex)
- {
- throw ::Ice::UnknownUserException(__FILE__, __LINE__, __ex.ice_name());
- }
- }
+ BasicStream* __is = __og.is();
+ if(!__ok)
+ {
+ try
+ {
+ __is->throwException();
+ }
+ catch(const ::Ice::UserException& __ex)
+ {
+ throw ::Ice::UnknownUserException(__FILE__, __LINE__, __ex.ice_name());
+ }
+ }
}
catch(const ::Ice::LocalException& __ex)
{
- throw ::IceInternal::LocalExceptionWrapper(__ex, false);
+ throw ::IceInternal::LocalExceptionWrapper(__ex, false);
}
}
@@ -1194,23 +1194,23 @@ IceDelegateM::Ice::Object::ice_ids(const Context* context)
bool __ok = __og.invoke();
try
{
- BasicStream* __is = __og.is();
- if(!__ok)
- {
- try
- {
- __is->throwException();
- }
- catch(const ::Ice::UserException& __ex)
- {
- throw ::Ice::UnknownUserException(__FILE__, __LINE__, __ex.ice_name());
- }
- }
- __is->read(__ret, false);
+ BasicStream* __is = __og.is();
+ if(!__ok)
+ {
+ try
+ {
+ __is->throwException();
+ }
+ catch(const ::Ice::UserException& __ex)
+ {
+ throw ::Ice::UnknownUserException(__FILE__, __LINE__, __ex.ice_name());
+ }
+ }
+ __is->read(__ret, false);
}
catch(const ::Ice::LocalException& __ex)
{
- throw ::IceInternal::LocalExceptionWrapper(__ex, false);
+ throw ::IceInternal::LocalExceptionWrapper(__ex, false);
}
return __ret;
}
@@ -1224,23 +1224,23 @@ IceDelegateM::Ice::Object::ice_id(const Context* context)
bool __ok = __og.invoke();
try
{
- BasicStream* __is = __og.is();
- if(!__ok)
- {
- try
- {
- __is->throwException();
- }
- catch(const ::Ice::UserException& __ex)
- {
- throw ::Ice::UnknownUserException(__FILE__, __LINE__, __ex.ice_name());
- }
- }
- __is->read(__ret, false);
+ BasicStream* __is = __og.is();
+ if(!__ok)
+ {
+ try
+ {
+ __is->throwException();
+ }
+ catch(const ::Ice::UserException& __ex)
+ {
+ throw ::Ice::UnknownUserException(__FILE__, __LINE__, __ex.ice_name());
+ }
+ }
+ __is->read(__ret, false);
}
catch(const ::Ice::LocalException& __ex)
{
- throw ::IceInternal::LocalExceptionWrapper(__ex, false);
+ throw ::IceInternal::LocalExceptionWrapper(__ex, false);
}
return __ret;
}
@@ -1248,19 +1248,19 @@ IceDelegateM::Ice::Object::ice_id(const Context* context)
bool
IceDelegateM::Ice::Object::ice_invoke(const string& operation,
OperationMode mode,
- const pair<const Byte*, const Byte*>& inParams,
- vector<Byte>& outParams,
- const Context* context)
+ const pair<const Byte*, const Byte*>& inParams,
+ vector<Byte>& outParams,
+ const Context* context)
{
Outgoing __og(__connection.get(), __reference.get(), operation, mode, context, __compress);
try
{
- BasicStream* __os = __og.os();
- __os->writeBlob(inParams.first, static_cast<Int>(inParams.second - inParams.first));
+ BasicStream* __os = __og.os();
+ __os->writeBlob(inParams.first, static_cast<Int>(inParams.second - inParams.first));
}
catch(const ::Ice::LocalException& __ex)
{
- __og.abort(__ex);
+ __og.abort(__ex);
}
bool ok = __og.invoke();
if(__reference->getMode() == Reference::ModeTwoway)
@@ -1329,19 +1329,19 @@ IceDelegateD::Ice::Object::ice_isA(const string& __id, const Context* context)
__initCurrent(__current, "ice_isA", ::Ice::Nonmutating, context);
while(true)
{
- Direct __direct(__current);
- bool __ret;
- try
- {
- __ret = __direct.servant()->ice_isA(__id, __current);
- }
- catch(...)
- {
- __direct.destroy();
- throw;
- }
- __direct.destroy();
- return __ret;
+ Direct __direct(__current);
+ bool __ret;
+ try
+ {
+ __ret = __direct.servant()->ice_isA(__id, __current);
+ }
+ catch(...)
+ {
+ __direct.destroy();
+ throw;
+ }
+ __direct.destroy();
+ return __ret;
}
return false; // To keep the Visual C++ compiler happy.
}
@@ -1353,18 +1353,18 @@ IceDelegateD::Ice::Object::ice_ping(const ::Ice::Context* context)
__initCurrent(__current, "ice_ping", ::Ice::Nonmutating, context);
while(true)
{
- Direct __direct(__current);
- try
- {
- __direct.servant()->ice_ping(__current);
- }
- catch(...)
- {
- __direct.destroy();
- throw;
- }
- __direct.destroy();
- return;
+ Direct __direct(__current);
+ try
+ {
+ __direct.servant()->ice_ping(__current);
+ }
+ catch(...)
+ {
+ __direct.destroy();
+ throw;
+ }
+ __direct.destroy();
+ return;
}
}
@@ -1375,19 +1375,19 @@ IceDelegateD::Ice::Object::ice_ids(const ::Ice::Context* context)
__initCurrent(__current, "ice_ids", ::Ice::Nonmutating, context);
while(true)
{
- Direct __direct(__current);
- vector<string> __ret;
- try
- {
- __ret = __direct.servant()->ice_ids(__current);
- }
- catch(...)
- {
- __direct.destroy();
- throw;
- }
- __direct.destroy();
- return __ret;
+ Direct __direct(__current);
+ vector<string> __ret;
+ try
+ {
+ __ret = __direct.servant()->ice_ids(__current);
+ }
+ catch(...)
+ {
+ __direct.destroy();
+ throw;
+ }
+ __direct.destroy();
+ return __ret;
}
return vector<string>(); // To keep the Visual C++ compiler happy.
}
@@ -1399,29 +1399,29 @@ IceDelegateD::Ice::Object::ice_id(const ::Ice::Context* context)
__initCurrent(__current, "ice_id", ::Ice::Nonmutating, context);
while(true)
{
- Direct __direct(__current);
- string __ret;
- try
- {
- __ret = __direct.servant()->ice_id(__current);
- }
- catch(...)
- {
- __direct.destroy();
- throw;
- }
- __direct.destroy();
- return __ret;
+ Direct __direct(__current);
+ string __ret;
+ try
+ {
+ __ret = __direct.servant()->ice_id(__current);
+ }
+ catch(...)
+ {
+ __direct.destroy();
+ throw;
+ }
+ __direct.destroy();
+ return __ret;
}
return string(); // To keep the Visual C++ compiler happy.
}
bool
IceDelegateD::Ice::Object::ice_invoke(const string&,
- OperationMode,
- const pair<const Byte*, const Byte*>& inParams,
- vector<Byte>&,
- const Context*)
+ OperationMode,
+ const pair<const Byte*, const Byte*>& inParams,
+ vector<Byte>&,
+ const Context*)
{
throw CollocationOptimizationException(__FILE__, __LINE__);
return false;
@@ -1456,7 +1456,7 @@ IceDelegateD::Ice::Object::__copyFrom(const ::IceInternal::Handle< ::IceDelegate
void
IceDelegateD::Ice::Object::__initCurrent(Current& current, const string& op, OperationMode mode,
- const Context* context)
+ const Context* context)
{
current.adapter = __adapter;
current.id = __reference->getIdentity();
@@ -1465,29 +1465,29 @@ IceDelegateD::Ice::Object::__initCurrent(Current& current, const string& op, Ope
current.mode = mode;
if(context != 0)
{
- //
- // Explicit context
- //
- current.ctx = *context;
+ //
+ // Explicit context
+ //
+ current.ctx = *context;
}
else
{
- //
- // Implicit context
- //
- const ImplicitContextIPtr& implicitContext =
- __reference->getInstance()->getImplicitContext();
+ //
+ // Implicit context
+ //
+ const ImplicitContextIPtr& implicitContext =
+ __reference->getInstance()->getImplicitContext();
- const Context& prxContext = __reference->getContext()->getValue();
+ const Context& prxContext = __reference->getContext()->getValue();
- if(implicitContext == 0)
- {
- current.ctx = prxContext;
- }
- else
- {
- implicitContext->combine(prxContext, current.ctx);
- }
+ if(implicitContext == 0)
+ {
+ current.ctx = prxContext;
+ }
+ else
+ {
+ implicitContext->combine(prxContext, current.ctx);
+ }
}
current.requestId = -1;
}
@@ -1512,19 +1512,19 @@ Ice::proxyIdentityLess(const ObjectPrx& lhs, const ObjectPrx& rhs)
{
if(!lhs && !rhs)
{
- return false;
+ return false;
}
else if(!lhs && rhs)
{
- return true;
+ return true;
}
else if(lhs && !rhs)
{
- return false;
+ return false;
}
else
{
- return lhs->ice_getIdentity() < rhs->ice_getIdentity();
+ return lhs->ice_getIdentity() < rhs->ice_getIdentity();
}
}
@@ -1533,19 +1533,19 @@ Ice::proxyIdentityEqual(const ObjectPrx& lhs, const ObjectPrx& rhs)
{
if(!lhs && !rhs)
{
- return true;
+ return true;
}
else if(!lhs && rhs)
{
- return false;
+ return false;
}
else if(lhs && !rhs)
{
- return false;
+ return false;
}
else
{
- return lhs->ice_getIdentity() == rhs->ice_getIdentity();
+ return lhs->ice_getIdentity() == rhs->ice_getIdentity();
}
}
@@ -1554,43 +1554,43 @@ Ice::proxyIdentityAndFacetLess(const ObjectPrx& lhs, const ObjectPrx& rhs)
{
if(!lhs && !rhs)
{
- return false;
+ return false;
}
else if(!lhs && rhs)
{
- return true;
+ return true;
}
else if(lhs && !rhs)
{
- return false;
+ return false;
}
else
{
- Identity lhsIdentity = lhs->ice_getIdentity();
- Identity rhsIdentity = rhs->ice_getIdentity();
-
- if(lhsIdentity < rhsIdentity)
- {
- return true;
- }
- else if(rhsIdentity < lhsIdentity)
- {
- return false;
- }
-
- string lhsFacet = lhs->ice_getFacet();
- string rhsFacet = rhs->ice_getFacet();
-
- if(lhsFacet < rhsFacet)
- {
- return true;
- }
- else if(rhsFacet < lhsFacet)
- {
- return false;
- }
-
- return false;
+ Identity lhsIdentity = lhs->ice_getIdentity();
+ Identity rhsIdentity = rhs->ice_getIdentity();
+
+ if(lhsIdentity < rhsIdentity)
+ {
+ return true;
+ }
+ else if(rhsIdentity < lhsIdentity)
+ {
+ return false;
+ }
+
+ string lhsFacet = lhs->ice_getFacet();
+ string rhsFacet = rhs->ice_getFacet();
+
+ if(lhsFacet < rhsFacet)
+ {
+ return true;
+ }
+ else if(rhsFacet < lhsFacet)
+ {
+ return false;
+ }
+
+ return false;
}
}
@@ -1599,33 +1599,33 @@ Ice::proxyIdentityAndFacetEqual(const ObjectPrx& lhs, const ObjectPrx& rhs)
{
if(!lhs && !rhs)
{
- return true;
+ return true;
}
else if(!lhs && rhs)
{
- return false;
+ return false;
}
else if(lhs && !rhs)
{
- return false;
+ return false;
}
else
{
- Identity lhsIdentity = lhs->ice_getIdentity();
- Identity rhsIdentity = rhs->ice_getIdentity();
-
- if(lhsIdentity == rhsIdentity)
- {
- string lhsFacet = lhs->ice_getFacet();
- string rhsFacet = rhs->ice_getFacet();
-
- if(lhsFacet == rhsFacet)
- {
- return true;
- }
- }
-
- return false;
+ Identity lhsIdentity = lhs->ice_getIdentity();
+ Identity rhsIdentity = rhs->ice_getIdentity();
+
+ if(lhsIdentity == rhsIdentity)
+ {
+ string lhsFacet = lhs->ice_getFacet();
+ string rhsFacet = rhs->ice_getFacet();
+
+ if(lhsFacet == rhsFacet)
+ {
+ return true;
+ }
+ }
+
+ return false;
}
}
diff --git a/cpp/src/Ice/ProxyFactory.cpp b/cpp/src/Ice/ProxyFactory.cpp
index 3de3450d22f..338cd0a62fb 100644
--- a/cpp/src/Ice/ProxyFactory.cpp
+++ b/cpp/src/Ice/ProxyFactory.cpp
@@ -39,11 +39,11 @@ IceInternal::ProxyFactory::proxyToString(const ObjectPrx& proxy) const
{
if(proxy)
{
- return proxy->__reference()->toString();
+ return proxy->__reference()->toString();
}
else
{
- return "";
+ return "";
}
}
@@ -69,13 +69,13 @@ IceInternal::ProxyFactory::proxyToStream(const ObjectPrx& proxy, BasicStream* s)
{
if(proxy)
{
- proxy->__reference()->getIdentity().__write(s);
- proxy->__reference()->streamWrite(s);
+ proxy->__reference()->getIdentity().__write(s);
+ proxy->__reference()->streamWrite(s);
}
else
{
- Identity ident;
- ident.__write(s);
+ Identity ident;
+ ident.__write(s);
}
}
@@ -104,48 +104,48 @@ IceInternal::ProxyFactory::checkRetryAfterException(const LocalException& ex, co
if(one)
{
- LocatorInfoPtr li = ref->getLocatorInfo();
- if(li)
- {
- //
- // We retry ObjectNotExistException if the reference is
- // indirect.
- //
- li->clearObjectCache(IndirectReferencePtr::dynamicCast(ref));
- }
- else if(ref->getRouterInfo() && one->operation == "ice_add_proxy")
- {
- //
- // If we have a router, an ObjectNotExistException with an
- // operation name "ice_add_proxy" indicates to the client
- // that the router isn't aware of the proxy (for example,
- // because it was evicted by the router). In this case, we
- // must *always* retry, so that the missing proxy is added
- // to the router.
- //
- if(traceLevels->retry >= 1)
- {
- Trace out(logger, traceLevels->retryCat);
- out << "retrying operation call to add proxy to router\n" << ex;
- }
- return; // We must always retry, so we don't look at the retry count.
- }
- else
- {
- //
- // For all other cases, we don't retry
- // ObjectNotExistException.
- //
- ex.ice_throw();
- }
+ LocatorInfoPtr li = ref->getLocatorInfo();
+ if(li)
+ {
+ //
+ // We retry ObjectNotExistException if the reference is
+ // indirect.
+ //
+ li->clearObjectCache(IndirectReferencePtr::dynamicCast(ref));
+ }
+ else if(ref->getRouterInfo() && one->operation == "ice_add_proxy")
+ {
+ //
+ // If we have a router, an ObjectNotExistException with an
+ // operation name "ice_add_proxy" indicates to the client
+ // that the router isn't aware of the proxy (for example,
+ // because it was evicted by the router). In this case, we
+ // must *always* retry, so that the missing proxy is added
+ // to the router.
+ //
+ if(traceLevels->retry >= 1)
+ {
+ Trace out(logger, traceLevels->retryCat);
+ out << "retrying operation call to add proxy to router\n" << ex;
+ }
+ return; // We must always retry, so we don't look at the retry count.
+ }
+ else
+ {
+ //
+ // For all other cases, we don't retry
+ // ObjectNotExistException.
+ //
+ ex.ice_throw();
+ }
}
else if(dynamic_cast<const RequestFailedException*>(&ex))
{
- //
+ //
// We don't retry other *NotExistException, which are all
// derived from RequestFailedException.
- //
- ex.ice_throw();
+ //
+ ex.ice_throw();
}
//
@@ -172,7 +172,7 @@ IceInternal::ProxyFactory::checkRetryAfterException(const LocalException& ex, co
//
if(dynamic_cast<const MarshalException*>(&ex))
{
- ex.ice_throw();
+ ex.ice_throw();
}
++cnt;
@@ -180,33 +180,33 @@ IceInternal::ProxyFactory::checkRetryAfterException(const LocalException& ex, co
if(cnt > static_cast<int>(_retryIntervals.size()))
{
- if(traceLevels->retry >= 1)
- {
- Trace out(logger, traceLevels->retryCat);
- out << "cannot retry operation call because retry limit has been exceeded\n" << ex;
- }
- ex.ice_throw();
+ if(traceLevels->retry >= 1)
+ {
+ Trace out(logger, traceLevels->retryCat);
+ out << "cannot retry operation call because retry limit has been exceeded\n" << ex;
+ }
+ ex.ice_throw();
}
int interval = _retryIntervals[cnt - 1];
if(traceLevels->retry >= 1)
{
- Trace out(logger, traceLevels->retryCat);
- out << "retrying operation call";
- if(interval > 0)
- {
- out << " in " << interval << "ms";
- }
- out << " because of exception\n" << ex;
+ Trace out(logger, traceLevels->retryCat);
+ out << "retrying operation call";
+ if(interval > 0)
+ {
+ out << " in " << interval << "ms";
+ }
+ out << " because of exception\n" << ex;
}
if(interval > 0)
{
- //
- // Sleep before retrying.
- //
- IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(interval));
+ //
+ // Sleep before retrying.
+ //
+ IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(interval));
}
}
@@ -220,46 +220,46 @@ IceInternal::ProxyFactory::ProxyFactory(const InstancePtr& instance) :
while(true)
{
- const string delim = " \t";
+ const string delim = " \t";
- beg = str.find_first_not_of(delim, end);
- if(beg == string::npos)
- {
- if(_retryIntervals.empty())
- {
- _retryIntervals.push_back(0);
- }
- break;
- }
+ beg = str.find_first_not_of(delim, end);
+ if(beg == string::npos)
+ {
+ if(_retryIntervals.empty())
+ {
+ _retryIntervals.push_back(0);
+ }
+ break;
+ }
- end = str.find_first_of(delim, beg);
- if(end == string::npos)
- {
- end = str.length();
- }
-
- if(beg == end)
- {
- break;
- }
+ end = str.find_first_of(delim, beg);
+ if(end == string::npos)
+ {
+ end = str.length();
+ }
+
+ if(beg == end)
+ {
+ break;
+ }
- istringstream value(str.substr(beg, end - beg));
+ istringstream value(str.substr(beg, end - beg));
- int v;
- if(!(value >> v) || !value.eof())
- {
- v = 0;
- }
+ int v;
+ if(!(value >> v) || !value.eof())
+ {
+ v = 0;
+ }
- //
- // If -1 is the first value, no retry and wait intervals.
- //
- if(v == -1 && _retryIntervals.empty())
- {
- break;
- }
+ //
+ // If -1 is the first value, no retry and wait intervals.
+ //
+ if(v == -1 && _retryIntervals.empty())
+ {
+ break;
+ }
- _retryIntervals.push_back(v > 0 ? v : 0);
+ _retryIntervals.push_back(v > 0 ? v : 0);
}
}
diff --git a/cpp/src/Ice/Reference.cpp b/cpp/src/Ice/Reference.cpp
index 99308ff37af..2dfe49d0e55 100644
--- a/cpp/src/Ice/Reference.cpp
+++ b/cpp/src/Ice/Reference.cpp
@@ -41,7 +41,7 @@ struct RandomNumberGenerator : public std::unary_function<ptrdiff_t, ptrdiff_t>
{
ptrdiff_t operator()(ptrdiff_t d)
{
- return IceUtil::random(static_cast<int>(d));
+ return IceUtil::random(static_cast<int>(d));
}
};
@@ -74,7 +74,7 @@ IceInternal::Reference::changeMode(Mode newMode) const
{
if(newMode == _mode)
{
- return ReferencePtr(const_cast<Reference*>(this));
+ return ReferencePtr(const_cast<Reference*>(this));
}
ReferencePtr r = _instance->referenceFactory()->copy(this);
r->_mode = newMode;
@@ -86,7 +86,7 @@ IceInternal::Reference::changeIdentity(const Identity& newIdentity) const
{
if(newIdentity == _identity)
{
- return ReferencePtr(const_cast<Reference*>(this));
+ return ReferencePtr(const_cast<Reference*>(this));
}
ReferencePtr r = _instance->referenceFactory()->copy(this);
r->_identity = newIdentity;
@@ -98,7 +98,7 @@ IceInternal::Reference::changeFacet(const string& newFacet) const
{
if(newFacet == _facet)
{
- return ReferencePtr(const_cast<Reference*>(this));
+ return ReferencePtr(const_cast<Reference*>(this));
}
ReferencePtr r = _instance->referenceFactory()->copy(this);
r->_facet = newFacet;
@@ -132,19 +132,19 @@ Reference::hash() const
for(q = _context->getValue().begin(); q != _context->getValue().end(); ++q)
{
- for(p = q->first.begin(); p != q->first.end(); ++p)
- {
- h = 5 * h + *p;
- }
- for(p = q->second.begin(); p != q->second.end(); ++p)
- {
- h = 5 * h + *p;
- }
+ for(p = q->first.begin(); p != q->first.end(); ++p)
+ {
+ h = 5 * h + *p;
+ }
+ for(p = q->second.begin(); p != q->second.end(); ++p)
+ {
+ h = 5 * h + *p;
+ }
}
for(p = _facet.begin(); p != _facet.end(); ++p)
{
- h = 5 * h + *p;
+ h = 5 * h + *p;
}
h = 5 * h + static_cast<Int>(getSecure());
@@ -168,11 +168,11 @@ IceInternal::Reference::streamWrite(BasicStream* s) const
//
if(_facet.empty())
{
- s->write(static_cast<string*>(0), static_cast<string*>(0));
+ s->write(static_cast<string*>(0), static_cast<string*>(0));
}
else
{
- s->write(&_facet, &_facet + 1);
+ s->write(&_facet, &_facet + 1);
}
s->write(static_cast<Byte>(_mode));
@@ -213,66 +213,66 @@ IceInternal::Reference::toString() const
{
s << " -f ";
- //
- // If the encoded facet string contains characters which
- // the reference parser uses as separators, then we enclose
- // the facet string in quotes.
- //
- string fs = _facet;
+ //
+ // If the encoded facet string contains characters which
+ // the reference parser uses as separators, then we enclose
+ // the facet string in quotes.
+ //
+ string fs = _facet;
if(_instance->initializationData().stringConverter)
{
UTF8BufferI buffer;
Byte* last =
- _instance->initializationData().stringConverter->toUTF8(fs.data(), fs.data() + fs.size(), buffer);
- fs = string(reinterpret_cast<const char*>(buffer.getBuffer()), last - buffer.getBuffer());
+ _instance->initializationData().stringConverter->toUTF8(fs.data(), fs.data() + fs.size(), buffer);
+ fs = string(reinterpret_cast<const char*>(buffer.getBuffer()), last - buffer.getBuffer());
+ }
+ fs = IceUtil::escapeString(fs, "");
+ if(fs.find_first_of(" :@") != string::npos)
+ {
+ s << '"' << fs << '"';
+ }
+ else
+ {
+ s << fs;
}
- fs = IceUtil::escapeString(fs, "");
- if(fs.find_first_of(" :@") != string::npos)
- {
- s << '"' << fs << '"';
- }
- else
- {
- s << fs;
- }
}
switch(_mode)
{
- case ModeTwoway:
- {
- s << " -t";
- break;
- }
-
- case ModeOneway:
- {
- s << " -o";
- break;
- }
-
- case ModeBatchOneway:
- {
- s << " -O";
- break;
- }
-
- case ModeDatagram:
- {
- s << " -d";
- break;
- }
-
- case ModeBatchDatagram:
- {
- s << " -D";
- break;
- }
+ case ModeTwoway:
+ {
+ s << " -t";
+ break;
+ }
+
+ case ModeOneway:
+ {
+ s << " -o";
+ break;
+ }
+
+ case ModeBatchOneway:
+ {
+ s << " -O";
+ break;
+ }
+
+ case ModeDatagram:
+ {
+ s << " -d";
+ break;
+ }
+
+ case ModeBatchDatagram:
+ {
+ s << " -D";
+ break;
+ }
}
if(getSecure())
{
- s << " -s";
+ s << " -s";
}
return s.str();
@@ -289,27 +289,27 @@ IceInternal::Reference::operator==(const Reference& r) const
if(getType() != r.getType())
{
- return false;
+ return false;
}
if(_mode != r._mode)
{
- return false;
+ return false;
}
if(_identity != r._identity)
{
- return false;
+ return false;
}
if(_context->getValue() != r._context->getValue())
{
- return false;
+ return false;
}
if(_facet != r._facet)
{
- return false;
+ return false;
}
return true;
@@ -330,47 +330,47 @@ IceInternal::Reference::operator<(const Reference& r) const
if(_mode < r._mode)
{
- return true;
+ return true;
}
else if(r._mode < _mode)
{
- return false;
+ return false;
}
if(_identity < r._identity)
{
- return true;
+ return true;
}
else if(r._identity < _identity)
{
- return false;
+ return false;
}
if(_context->getValue() < r._context->getValue())
{
- return true;
+ return true;
}
else if(r._context->getValue() < _context->getValue())
{
- return false;
+ return false;
}
if(_facet < r._facet)
{
- return true;
+ return true;
}
else if(r._facet < _facet)
{
- return false;
+ return false;
}
if(getType() < r.getType())
{
- return true;
+ return true;
}
else if(r.getType() < getType())
{
- return false;
+ return false;
}
return false;
@@ -383,7 +383,7 @@ public:
bool
operator()(ConnectionIPtr p) const
{
- return p->endpoint()->datagram();
+ return p->endpoint()->datagram();
}
};
@@ -394,12 +394,12 @@ public:
bool
operator()(ConnectionIPtr p) const
{
- return p->endpoint()->secure();
+ return p->endpoint()->secure();
}
};
IceInternal::Reference::Reference(const InstancePtr& inst, const CommunicatorPtr& com, const Identity& ident,
- const SharedContextPtr& ctx, const string& fs, Mode md) :
+ const SharedContextPtr& ctx, const string& fs, Mode md) :
_hashInitialized(false),
_instance(inst),
_communicator(com),
@@ -425,8 +425,8 @@ void IceInternal::incRef(IceInternal::FixedReference* p) { p->__incRef(); }
void IceInternal::decRef(IceInternal::FixedReference* p) { p->__decRef(); }
IceInternal::FixedReference::FixedReference(const InstancePtr& inst, const CommunicatorPtr& com, const Identity& ident,
- const SharedContextPtr& ctx, const string& fs, Mode md,
- const vector<ConnectionIPtr>& fixedConns) :
+ const SharedContextPtr& ctx, const string& fs, Mode md,
+ const vector<ConnectionIPtr>& fixedConns) :
Reference(inst, com, ident, ctx, fs, md),
_fixedConnections(fixedConns)
{
@@ -620,9 +620,9 @@ IceInternal::FixedReference::getConnection(bool& compress) const
vector<ConnectionIPtr> filteredConns = filterConnections(_fixedConnections);
if(filteredConns.empty())
{
- NoEndpointException ex(__FILE__, __LINE__);
- ex.proxy = ""; // No stringified representation for fixed proxies
- throw ex;
+ NoEndpointException ex(__FILE__, __LINE__);
+ ex.proxy = ""; // No stringified representation for fixed proxies
+ throw ex;
}
ConnectionIPtr connection = filteredConns[0];
@@ -669,7 +669,7 @@ IceInternal::FixedReference::operator<(const Reference& r) const
{
const FixedReference* rhs = dynamic_cast<const FixedReference*>(&r);
assert(rhs);
- return _fixedConnections < rhs->_fixedConnections;
+ return _fixedConnections < rhs->_fixedConnections;
}
return false;
}
@@ -693,28 +693,28 @@ IceInternal::FixedReference::filterConnections(const vector<ConnectionIPtr>& all
switch(getMode())
{
- case Reference::ModeTwoway:
- case Reference::ModeOneway:
- case Reference::ModeBatchOneway:
- {
- //
- // Filter out datagram connections.
- //
+ case Reference::ModeTwoway:
+ case Reference::ModeOneway:
+ case Reference::ModeBatchOneway:
+ {
+ //
+ // Filter out datagram connections.
+ //
connections.erase(remove_if(connections.begin(), connections.end(), ConnectionIsDatagram()),
- connections.end());
- break;
- }
-
- case Reference::ModeDatagram:
- case Reference::ModeBatchDatagram:
- {
- //
- // Filter out non-datagram connections.
- //
+ connections.end());
+ break;
+ }
+
+ case Reference::ModeDatagram:
+ case Reference::ModeBatchDatagram:
+ {
+ //
+ // Filter out non-datagram connections.
+ //
connections.erase(remove_if(connections.begin(), connections.end(), not1(ConnectionIsDatagram())),
- connections.end());
- break;
- }
+ connections.end());
+ break;
+ }
}
//
@@ -733,17 +733,17 @@ IceInternal::FixedReference::filterConnections(const vector<ConnectionIPtr>& all
DefaultsAndOverridesPtr overrides = getInstance()->defaultsAndOverrides();
if(overrides->overrideSecure ? overrides->overrideSecureValue : getSecure())
{
- connections.erase(remove_if(connections.begin(), connections.end(), not1(ConnectionIsSecure())),
- connections.end());
+ connections.erase(remove_if(connections.begin(), connections.end(), not1(ConnectionIsSecure())),
+ connections.end());
}
else
{
- //
- // We must use stable_partition() instead of just simply
- // partition(), because otherwise some STL implementations
- // order our now randomized connections.
- //
- stable_partition(connections.begin(), connections.end(), not1(ConnectionIsSecure()));
+ //
+ // We must use stable_partition() instead of just simply
+ // partition(), because otherwise some STL implementations
+ // order our now randomized connections.
+ //
+ stable_partition(connections.begin(), connections.end(), not1(ConnectionIsSecure()));
}
return connections;
@@ -758,10 +758,10 @@ IceInternal::RoutableReference::getRoutedEndpoints() const
if(_routerInfo)
{
//
- // If we route, we send everything to the router's client
- // proxy endpoints.
- //
- return _routerInfo->getClientEndpoints();
+ // If we route, we send everything to the router's client
+ // proxy endpoints.
+ //
+ return _routerInfo->getClientEndpoints();
}
return vector<EndpointIPtr>();
}
@@ -807,7 +807,7 @@ IceInternal::RoutableReference::changeSecure(bool newSecure) const
{
if(newSecure == _secure)
{
- return RoutableReferencePtr(const_cast<RoutableReference*>(this));
+ return RoutableReferencePtr(const_cast<RoutableReference*>(this));
}
RoutableReferencePtr r = RoutableReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this));
r->_secure = newSecure;
@@ -819,7 +819,7 @@ IceInternal::RoutableReference::changePreferSecure(bool newPreferSecure) const
{
if(newPreferSecure == _preferSecure)
{
- return RoutableReferencePtr(const_cast<RoutableReference*>(this));
+ return RoutableReferencePtr(const_cast<RoutableReference*>(this));
}
RoutableReferencePtr r = RoutableReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this));
r->_preferSecure = newPreferSecure;
@@ -832,7 +832,7 @@ IceInternal::RoutableReference::changeRouter(const RouterPrx& newRouter) const
RouterInfoPtr newRouterInfo = getInstance()->routerManager()->get(newRouter);
if(newRouterInfo == _routerInfo)
{
- return RoutableReferencePtr(const_cast<RoutableReference*>(this));
+ return RoutableReferencePtr(const_cast<RoutableReference*>(this));
}
RoutableReferencePtr r = RoutableReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this));
r->_routerInfo = newRouterInfo;
@@ -844,7 +844,7 @@ IceInternal::RoutableReference::changeCollocationOptimization(bool newCollocatio
{
if(newCollocationOptimization == _collocationOptimization)
{
- return RoutableReferencePtr(const_cast<RoutableReference*>(this));
+ return RoutableReferencePtr(const_cast<RoutableReference*>(this));
}
RoutableReferencePtr r = RoutableReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this));
r->_collocationOptimization = newCollocationOptimization;
@@ -856,7 +856,7 @@ IceInternal::RoutableReference::changeCompress(bool newCompress) const
{
if(_overrideCompress && newCompress == _compress)
{
- return RoutableReferencePtr(const_cast<RoutableReference*>(this));
+ return RoutableReferencePtr(const_cast<RoutableReference*>(this));
}
RoutableReferencePtr r = RoutableReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this));
r->_compress = newCompress;
@@ -869,7 +869,7 @@ IceInternal::RoutableReference::changeTimeout(int newTimeout) const
{
if(_overrideTimeout && newTimeout == _timeout)
{
- return RoutableReferencePtr(const_cast<RoutableReference*>(this));
+ return RoutableReferencePtr(const_cast<RoutableReference*>(this));
}
RoutableReferencePtr r = RoutableReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this));
r->_timeout = newTimeout;
@@ -882,7 +882,7 @@ IceInternal::RoutableReference::changeConnectionId(const string& id) const
{
if(id == _connectionId)
{
- return RoutableReferencePtr(const_cast<RoutableReference*>(this));
+ return RoutableReferencePtr(const_cast<RoutableReference*>(this));
}
RoutableReferencePtr r = RoutableReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this));
r->_connectionId = id;
@@ -894,7 +894,7 @@ IceInternal::RoutableReference::changeCacheConnection(bool newCache) const
{
if(newCache == _cacheConnection)
{
- return RoutableReferencePtr(const_cast<RoutableReference*>(this));
+ return RoutableReferencePtr(const_cast<RoutableReference*>(this));
}
RoutableReferencePtr r = RoutableReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this));
r->_cacheConnection = newCache;
@@ -906,7 +906,7 @@ IceInternal::RoutableReference::changeEndpointSelection(EndpointSelectionType ne
{
if(newType == _endpointSelection)
{
- return RoutableReferencePtr(const_cast<RoutableReference*>(this));
+ return RoutableReferencePtr(const_cast<RoutableReference*>(this));
}
RoutableReferencePtr r = RoutableReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this));
r->_endpointSelection = newType;
@@ -945,35 +945,35 @@ IceInternal::RoutableReference::operator==(const Reference& r) const
}
if(_secure != rhs->_secure)
{
- return false;
+ return false;
}
if(_preferSecure != rhs->_preferSecure)
{
- return false;
+ return false;
}
if(_collocationOptimization != rhs->_collocationOptimization)
{
- return false;
+ return false;
}
if(_cacheConnection != rhs->_cacheConnection)
{
- return false;
+ return false;
}
if(_endpointSelection != rhs->_endpointSelection)
{
- return false;
+ return false;
}
if(_connectionId != rhs->_connectionId)
{
- return false;
+ return false;
}
if(_overrideCompress != rhs->_overrideCompress || _overrideCompress && _compress != rhs->_compress)
{
- return false;
+ return false;
}
if(_overrideTimeout != rhs->_overrideTimeout || _overrideTimeout && _timeout != rhs->_timeout)
{
- return false;
+ return false;
}
if(_threadPerConnection != rhs->_threadPerConnection)
{
@@ -1002,93 +1002,93 @@ IceInternal::RoutableReference::operator<(const Reference& r) const
if(Reference::operator==(r))
{
const RoutableReference* rhs = dynamic_cast<const RoutableReference*>(&r);
- assert(rhs);
- if(!_secure && rhs->_secure)
- {
- return true;
- }
- else if(rhs->_secure < _secure)
- {
- return false;
- }
- else if(!_preferSecure && rhs->_preferSecure)
- {
- return true;
- }
- else if(rhs->_preferSecure < _preferSecure)
- {
- return false;
- }
- if(!_collocationOptimization && rhs->_collocationOptimization)
- {
- return true;
- }
- else if(rhs->_collocationOptimization < _collocationOptimization)
- {
- return false;
- }
- if(!_cacheConnection && rhs->_cacheConnection)
- {
- return true;
- }
- else if(rhs->_cacheConnection < _cacheConnection)
- {
- return false;
- }
- if(_endpointSelection < rhs->_endpointSelection)
- {
- return true;
- }
- else if(rhs->_endpointSelection < _endpointSelection)
- {
- return false;
- }
- if(_connectionId < rhs->_connectionId)
- {
- return true;
- }
- else if(rhs->_connectionId < _connectionId)
- {
- return false;
- }
- if(!_overrideCompress && rhs->_overrideCompress)
- {
- return true;
- }
- else if(rhs->_overrideCompress < _overrideCompress)
- {
- return false;
- }
- else if(_overrideCompress)
- {
- if(!_compress && rhs->_compress)
- {
- return true;
- }
- else if(rhs->_compress < _compress)
- {
- return false;
- }
- }
- if(!_overrideTimeout && rhs->_overrideTimeout)
- {
- return true;
- }
- else if(rhs->_overrideTimeout < _overrideTimeout)
- {
- return false;
- }
- else if(_overrideTimeout)
- {
- if(_timeout < rhs->_timeout)
- {
- return true;
- }
- else if(rhs->_timeout < _timeout)
- {
- return false;
- }
- }
+ assert(rhs);
+ if(!_secure && rhs->_secure)
+ {
+ return true;
+ }
+ else if(rhs->_secure < _secure)
+ {
+ return false;
+ }
+ else if(!_preferSecure && rhs->_preferSecure)
+ {
+ return true;
+ }
+ else if(rhs->_preferSecure < _preferSecure)
+ {
+ return false;
+ }
+ if(!_collocationOptimization && rhs->_collocationOptimization)
+ {
+ return true;
+ }
+ else if(rhs->_collocationOptimization < _collocationOptimization)
+ {
+ return false;
+ }
+ if(!_cacheConnection && rhs->_cacheConnection)
+ {
+ return true;
+ }
+ else if(rhs->_cacheConnection < _cacheConnection)
+ {
+ return false;
+ }
+ if(_endpointSelection < rhs->_endpointSelection)
+ {
+ return true;
+ }
+ else if(rhs->_endpointSelection < _endpointSelection)
+ {
+ return false;
+ }
+ if(_connectionId < rhs->_connectionId)
+ {
+ return true;
+ }
+ else if(rhs->_connectionId < _connectionId)
+ {
+ return false;
+ }
+ if(!_overrideCompress && rhs->_overrideCompress)
+ {
+ return true;
+ }
+ else if(rhs->_overrideCompress < _overrideCompress)
+ {
+ return false;
+ }
+ else if(_overrideCompress)
+ {
+ if(!_compress && rhs->_compress)
+ {
+ return true;
+ }
+ else if(rhs->_compress < _compress)
+ {
+ return false;
+ }
+ }
+ if(!_overrideTimeout && rhs->_overrideTimeout)
+ {
+ return true;
+ }
+ else if(rhs->_overrideTimeout < _overrideTimeout)
+ {
+ return false;
+ }
+ else if(_overrideTimeout)
+ {
+ if(_timeout < rhs->_timeout)
+ {
+ return true;
+ }
+ else if(rhs->_timeout < _timeout)
+ {
+ return false;
+ }
+ }
if(!_threadPerConnection && rhs->_threadPerConnection)
{
return true;
@@ -1097,15 +1097,15 @@ IceInternal::RoutableReference::operator<(const Reference& r) const
{
return false;
}
- return _routerInfo < rhs->_routerInfo;
+ return _routerInfo < rhs->_routerInfo;
}
return false;
}
IceInternal::RoutableReference::RoutableReference(const InstancePtr& inst, const CommunicatorPtr& com,
- const Identity& ident, const SharedContextPtr& ctx, const string& fs,
- Mode md, bool sec, bool prefSec, const RouterInfoPtr& rtrInfo,
- bool collocationOpt, bool cacheConnection,
+ const Identity& ident, const SharedContextPtr& ctx, const string& fs,
+ Mode md, bool sec, bool prefSec, const RouterInfoPtr& rtrInfo,
+ bool collocationOpt, bool cacheConnection,
EndpointSelectionType endpointSelection, bool threadPerConnection) :
Reference(inst, com, ident, ctx, fs, md),
_secure(sec),
@@ -1148,36 +1148,36 @@ IceInternal::RoutableReference::createConnection(const vector<EndpointIPtr>& all
// Filter out unknown endpoints.
//
endpoints.erase(remove_if(endpoints.begin(), endpoints.end(), Ice::constMemFun(&EndpointI::unknown)),
- endpoints.end());
+ endpoints.end());
//
// Filter out endpoints according to the mode of the reference.
//
switch(getMode())
{
- case Reference::ModeTwoway:
- case Reference::ModeOneway:
- case Reference::ModeBatchOneway:
- {
- //
- // Filter out datagram endpoints.
- //
+ case Reference::ModeTwoway:
+ case Reference::ModeOneway:
+ case Reference::ModeBatchOneway:
+ {
+ //
+ // Filter out datagram endpoints.
+ //
endpoints.erase(remove_if(endpoints.begin(), endpoints.end(), Ice::constMemFun(&EndpointI::datagram)),
endpoints.end());
- break;
- }
-
- case Reference::ModeDatagram:
- case Reference::ModeBatchDatagram:
- {
- //
- // Filter out non-datagram endpoints.
- //
+ break;
+ }
+
+ case Reference::ModeDatagram:
+ case Reference::ModeBatchDatagram:
+ {
+ //
+ // Filter out non-datagram endpoints.
+ //
endpoints.erase(remove_if(endpoints.begin(), endpoints.end(),
- not1(Ice::constMemFun(&EndpointI::datagram))),
+ not1(Ice::constMemFun(&EndpointI::datagram))),
endpoints.end());
- break;
- }
+ break;
+ }
}
//
@@ -1185,22 +1185,22 @@ IceInternal::RoutableReference::createConnection(const vector<EndpointIPtr>& all
//
switch(getEndpointSelection())
{
- case Random:
- {
- RandomNumberGenerator rng;
- random_shuffle(endpoints.begin(), endpoints.end(), rng);
- break;
- }
- case Ordered:
- {
- // Nothing to do.
- break;
- }
- default:
- {
- assert(false);
- break;
- }
+ case Random:
+ {
+ RandomNumberGenerator rng;
+ random_shuffle(endpoints.begin(), endpoints.end(), rng);
+ break;
+ }
+ case Ordered:
+ {
+ // Nothing to do.
+ break;
+ }
+ default:
+ {
+ assert(false);
+ break;
+ }
}
//
@@ -1212,33 +1212,33 @@ IceInternal::RoutableReference::createConnection(const vector<EndpointIPtr>& all
DefaultsAndOverridesPtr overrides = getInstance()->defaultsAndOverrides();
if(overrides->overrideSecure ? overrides->overrideSecureValue : getSecure())
{
- endpoints.erase(remove_if(endpoints.begin(), endpoints.end(), not1(Ice::constMemFun(&EndpointI::secure))),
- endpoints.end());
+ endpoints.erase(remove_if(endpoints.begin(), endpoints.end(), not1(Ice::constMemFun(&EndpointI::secure))),
+ endpoints.end());
}
else if(getPreferSecure())
{
- //
- // We must use stable_partition() instead of just simply
- // partition(), because otherwise some STL implementations
- // order our now randomized endpoints.
- //
- stable_partition(endpoints.begin(), endpoints.end(), Ice::constMemFun(&EndpointI::secure));
+ //
+ // We must use stable_partition() instead of just simply
+ // partition(), because otherwise some STL implementations
+ // order our now randomized endpoints.
+ //
+ stable_partition(endpoints.begin(), endpoints.end(), Ice::constMemFun(&EndpointI::secure));
}
else
{
- //
- // We must use stable_partition() instead of just simply
- // partition(), because otherwise some STL implementations
- // order our now randomized endpoints.
- //
- stable_partition(endpoints.begin(), endpoints.end(), not1(Ice::constMemFun(&EndpointI::secure)));
+ //
+ // We must use stable_partition() instead of just simply
+ // partition(), because otherwise some STL implementations
+ // order our now randomized endpoints.
+ //
+ stable_partition(endpoints.begin(), endpoints.end(), not1(Ice::constMemFun(&EndpointI::secure)));
}
if(endpoints.empty())
{
NoEndpointException ex(__FILE__, __LINE__);
- ex.proxy = toString();
- throw ex;
+ ex.proxy = toString();
+ throw ex;
}
//
@@ -1247,42 +1247,42 @@ IceInternal::RoutableReference::createConnection(const vector<EndpointIPtr>& all
OutgoingConnectionFactoryPtr factory = getInstance()->outgoingConnectionFactory();
if(getCacheConnection() || endpoints.size() == 1)
{
- //
- // Get an existing connection or create one if there's no
- // existing connection to one of the given endpoints.
- //
- return factory->create(endpoints, false, _threadPerConnection, comp);
+ //
+ // Get an existing connection or create one if there's no
+ // existing connection to one of the given endpoints.
+ //
+ return factory->create(endpoints, false, _threadPerConnection, comp);
}
else
{
- //
- // Go through the list of endpoints and try to create the
- // connection until it succeeds. This is different from just
- // calling create() with the given endpoints since this might
- // create a new connection even if there's an existing
- // connection for one of the endpoints.
- //
-
- auto_ptr<LocalException> exception;
- vector<EndpointIPtr> endpoint;
- endpoint.push_back(0);
-
- for(vector<EndpointIPtr>::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p)
- {
- try
- {
- endpoint.back() = *p;
- return factory->create(endpoint, p + 1 == endpoints.end(), _threadPerConnection, comp);
- }
- catch(const LocalException& ex)
- {
- exception.reset(dynamic_cast<LocalException*>(ex.ice_clone()));
- }
- }
-
- assert(exception.get());
- exception->ice_throw();
- return 0; // Keeps the compiler happy.
+ //
+ // Go through the list of endpoints and try to create the
+ // connection until it succeeds. This is different from just
+ // calling create() with the given endpoints since this might
+ // create a new connection even if there's an existing
+ // connection for one of the endpoints.
+ //
+
+ auto_ptr<LocalException> exception;
+ vector<EndpointIPtr> endpoint;
+ endpoint.push_back(0);
+
+ for(vector<EndpointIPtr>::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p)
+ {
+ try
+ {
+ endpoint.back() = *p;
+ return factory->create(endpoint, p + 1 == endpoints.end(), _threadPerConnection, comp);
+ }
+ catch(const LocalException& ex)
+ {
+ exception.reset(dynamic_cast<LocalException*>(ex.ice_clone()));
+ }
+ }
+
+ assert(exception.get());
+ exception->ice_throw();
+ return 0; // Keeps the compiler happy.
}
}
@@ -1291,15 +1291,15 @@ IceInternal::RoutableReference::applyOverrides(vector<EndpointIPtr>& endpoints)
{
for(vector<EndpointIPtr>::iterator p = endpoints.begin(); p != endpoints.end(); ++p)
{
- *p = (*p)->connectionId(_connectionId);
- if(_overrideCompress)
- {
- *p = (*p)->compress(_compress);
- }
- if(_overrideTimeout)
- {
- *p = (*p)->timeout(_timeout);
- }
+ *p = (*p)->connectionId(_connectionId);
+ if(_overrideCompress)
+ {
+ *p = (*p)->compress(_compress);
+ }
+ if(_overrideTimeout)
+ {
+ *p = (*p)->timeout(_timeout);
+ }
}
}
@@ -1307,9 +1307,9 @@ void IceInternal::incRef(IceInternal::DirectReference* p) { p->__incRef(); }
void IceInternal::decRef(IceInternal::DirectReference* p) { p->__decRef(); }
IceInternal::DirectReference::DirectReference(const InstancePtr& inst, const CommunicatorPtr& com,
- const Identity& ident, const SharedContextPtr& ctx, const string& fs,
- Mode md, bool sec, bool prefSec, const vector<EndpointIPtr>& endpts,
- const RouterInfoPtr& rtrInfo, bool collocationOpt, bool cacheConnection,
+ const Identity& ident, const SharedContextPtr& ctx, const string& fs,
+ Mode md, bool sec, bool prefSec, const vector<EndpointIPtr>& endpts,
+ const RouterInfoPtr& rtrInfo, bool collocationOpt, bool cacheConnection,
EndpointSelectionType endpointSelection, bool threadPerConnection) :
RoutableReference(inst, com, ident, ctx, fs, md, sec, prefSec, rtrInfo, collocationOpt, cacheConnection,
endpointSelection, threadPerConnection),
@@ -1353,12 +1353,12 @@ IceInternal::DirectReference::changeCompress(bool newCompress) const
DirectReferencePtr r = DirectReferencePtr::dynamicCast(RoutableReference::changeCompress(newCompress));
if(r.get() != this) // Also override the compress flag on the endpoints if it was updated.
{
- vector<EndpointIPtr> newEndpoints;
- for(vector<EndpointIPtr>::const_iterator p = _endpoints.begin(); p != _endpoints.end(); ++p)
- {
- newEndpoints.push_back((*p)->compress(newCompress));
- }
- r->_endpoints = newEndpoints;
+ vector<EndpointIPtr> newEndpoints;
+ for(vector<EndpointIPtr>::const_iterator p = _endpoints.begin(); p != _endpoints.end(); ++p)
+ {
+ newEndpoints.push_back((*p)->compress(newCompress));
+ }
+ r->_endpoints = newEndpoints;
}
return r;
}
@@ -1369,12 +1369,12 @@ IceInternal::DirectReference::changeTimeout(int newTimeout) const
DirectReferencePtr r = DirectReferencePtr::dynamicCast(RoutableReference::changeTimeout(newTimeout));
if(r.get() != this) // Also override the timeout on the endpoints if it was updated.
{
- vector<EndpointIPtr> newEndpoints;
- for(vector<EndpointIPtr>::const_iterator p = _endpoints.begin(); p != _endpoints.end(); ++p)
- {
- newEndpoints.push_back((*p)->timeout(newTimeout));
- }
- r->_endpoints = newEndpoints;
+ vector<EndpointIPtr> newEndpoints;
+ for(vector<EndpointIPtr>::const_iterator p = _endpoints.begin(); p != _endpoints.end(); ++p)
+ {
+ newEndpoints.push_back((*p)->timeout(newTimeout));
+ }
+ r->_endpoints = newEndpoints;
}
return r;
}
@@ -1385,12 +1385,12 @@ IceInternal::DirectReference::changeConnectionId(const string& newConnectionId)
DirectReferencePtr r = DirectReferencePtr::dynamicCast(RoutableReference::changeConnectionId(newConnectionId));
if(r.get() != this) // Also override the connection id on the endpoints if it was updated.
{
- vector<EndpointIPtr> newEndpoints;
- for(vector<EndpointIPtr>::const_iterator p = _endpoints.begin(); p != _endpoints.end(); ++p)
- {
- newEndpoints.push_back((*p)->connectionId(newConnectionId));
- }
- r->_endpoints = newEndpoints;
+ vector<EndpointIPtr> newEndpoints;
+ for(vector<EndpointIPtr>::const_iterator p = _endpoints.begin(); p != _endpoints.end(); ++p)
+ {
+ newEndpoints.push_back((*p)->connectionId(newConnectionId));
+ }
+ r->_endpoints = newEndpoints;
}
return r;
}
@@ -1406,17 +1406,17 @@ IceInternal::DirectReference::changeAdapterId(const string& newAdapterId) const
{
if(!newAdapterId.empty())
{
- LocatorInfoPtr locatorInfo =
- getInstance()->locatorManager()->get(getInstance()->referenceFactory()->getDefaultLocator());
- return getInstance()->referenceFactory()->create(getIdentity(), getContext(), getFacet(), getMode(),
- getSecure(), getPreferSecure(), newAdapterId, getRouterInfo(),
- locatorInfo, getCollocationOptimization(),
+ LocatorInfoPtr locatorInfo =
+ getInstance()->locatorManager()->get(getInstance()->referenceFactory()->getDefaultLocator());
+ return getInstance()->referenceFactory()->create(getIdentity(), getContext(), getFacet(), getMode(),
+ getSecure(), getPreferSecure(), newAdapterId, getRouterInfo(),
+ locatorInfo, getCollocationOptimization(),
getCacheConnection(), getEndpointSelection(),
getThreadPerConnection(), getLocatorCacheTimeout());
}
else
{
- return DirectReferencePtr(const_cast<DirectReference*>(this));
+ return DirectReferencePtr(const_cast<DirectReference*>(this));
}
}
@@ -1425,7 +1425,7 @@ IceInternal::DirectReference::changeEndpoints(const vector<EndpointIPtr>& newEnd
{
if(newEndpoints == _endpoints)
{
- return DirectReferencePtr(const_cast<DirectReference*>(this));
+ return DirectReferencePtr(const_cast<DirectReference*>(this));
}
DirectReferencePtr r = DirectReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this));
r->_endpoints = newEndpoints;
@@ -1442,14 +1442,14 @@ IceInternal::DirectReference::streamWrite(BasicStream* s) const
s->writeSize(sz);
if(sz)
{
- for(vector<EndpointIPtr>::const_iterator p = _endpoints.begin(); p != _endpoints.end(); ++p)
- {
- (*p)->streamWrite(s);
- }
+ for(vector<EndpointIPtr>::const_iterator p = _endpoints.begin(); p != _endpoints.end(); ++p)
+ {
+ (*p)->streamWrite(s);
+ }
}
else
{
- s->write(string("")); // Adapter id.
+ s->write(string("")); // Adapter id.
}
}
@@ -1468,12 +1468,12 @@ IceInternal::DirectReference::toString() const
vector<EndpointIPtr>::const_iterator p;
for(p = _endpoints.begin(); p != _endpoints.end(); ++p)
{
- string endp = (*p)->toString();
- if(!endp.empty())
- {
- result.append(":");
- result.append(endp);
- }
+ string endp = (*p)->toString();
+ if(!endp.empty())
+ {
+ result.append(":");
+ result.append(endp);
+ }
}
return result;
}
@@ -1486,7 +1486,7 @@ IceInternal::DirectReference::getConnection(bool& comp) const
if(endpts.empty())
{
- endpts = _endpoints; // Endpoint overrides are already applied on these endpoints.
+ endpts = _endpoints; // Endpoint overrides are already applied on these endpoints.
}
ConnectionIPtr connection = createConnection(endpts, comp);
@@ -1540,8 +1540,8 @@ IceInternal::DirectReference::operator<(const Reference& r) const
if(RoutableReference::operator==(r))
{
const DirectReference* rhs = dynamic_cast<const DirectReference*>(&r);
- assert(rhs);
- return _endpoints < rhs->_endpoints;
+ assert(rhs);
+ return _endpoints < rhs->_endpoints;
}
return false;
}
@@ -1562,10 +1562,10 @@ void IceInternal::incRef(IceInternal::IndirectReference* p) { p->__incRef(); }
void IceInternal::decRef(IceInternal::IndirectReference* p) { p->__decRef(); }
IceInternal::IndirectReference::IndirectReference(const InstancePtr& inst, const CommunicatorPtr& com,
- const Identity& ident, const SharedContextPtr& ctx, const string& fs,
- Mode md, bool sec, bool prefSec, const string& adptid,
- const RouterInfoPtr& rtrInfo, const LocatorInfoPtr& locInfo,
- bool collocationOpt, bool cacheConnection,
+ const Identity& ident, const SharedContextPtr& ctx, const string& fs,
+ Mode md, bool sec, bool prefSec, const string& adptid,
+ const RouterInfoPtr& rtrInfo, const LocatorInfoPtr& locInfo,
+ bool collocationOpt, bool cacheConnection,
EndpointSelectionType endpointSelection, bool threadPerConnection,
int locatorCacheTimeout) :
RoutableReference(inst, com, ident, ctx, fs, md, sec, prefSec, rtrInfo, collocationOpt, cacheConnection,
@@ -1606,7 +1606,7 @@ IceInternal::IndirectReference::changeLocator(const LocatorPrx& newLocator) cons
LocatorInfoPtr newLocatorInfo = getInstance()->locatorManager()->get(newLocator);
if(newLocatorInfo == _locatorInfo)
{
- return IndirectReferencePtr(const_cast<IndirectReference*>(this));
+ return IndirectReferencePtr(const_cast<IndirectReference*>(this));
}
IndirectReferencePtr r = IndirectReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this));
r->_locatorInfo = newLocatorInfo;
@@ -1618,7 +1618,7 @@ IceInternal::IndirectReference::changeAdapterId(const string& newAdapterId) cons
{
if(newAdapterId == _adapterId)
{
- return IndirectReferencePtr(const_cast<IndirectReference*>(this));
+ return IndirectReferencePtr(const_cast<IndirectReference*>(this));
}
IndirectReferencePtr r = IndirectReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this));
r->_adapterId = newAdapterId;
@@ -1630,14 +1630,14 @@ IceInternal::IndirectReference::changeEndpoints(const vector<EndpointIPtr>& newE
{
if(!newEndpoints.empty())
{
- return getInstance()->referenceFactory()->create(getIdentity(), getContext(), getFacet(), getMode(),
- getSecure(), getPreferSecure(), newEndpoints, getRouterInfo(),
- getCollocationOptimization(), getCacheConnection(),
+ return getInstance()->referenceFactory()->create(getIdentity(), getContext(), getFacet(), getMode(),
+ getSecure(), getPreferSecure(), newEndpoints, getRouterInfo(),
+ getCollocationOptimization(), getCacheConnection(),
getEndpointSelection(), getThreadPerConnection());
}
else
{
- return IndirectReferencePtr(const_cast<IndirectReference*>(this));
+ return IndirectReferencePtr(const_cast<IndirectReference*>(this));
}
}
@@ -1646,7 +1646,7 @@ IceInternal::IndirectReference::changeLocatorCacheTimeout(int timeout) const
{
if(timeout == _locatorCacheTimeout)
{
- return IndirectReferencePtr(const_cast<IndirectReference*>(this));
+ return IndirectReferencePtr(const_cast<IndirectReference*>(this));
}
IndirectReferencePtr r = IndirectReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this));
r->_locatorCacheTimeout = timeout;
@@ -1690,18 +1690,18 @@ IceInternal::IndirectReference::toString() const
{
UTF8BufferI buffer;
Byte* last = getInstance()->initializationData().stringConverter->toUTF8(a.data(), a.data() + a.size(), buffer);
- a = string(reinterpret_cast<const char*>(buffer.getBuffer()), last - buffer.getBuffer());
+ a = string(reinterpret_cast<const char*>(buffer.getBuffer()), last - buffer.getBuffer());
}
a = IceUtil::escapeString(a, "");
if(a.find_first_of(" ") != string::npos)
{
- result.append("\"");
- result.append(a);
- result.append("\"");
+ result.append("\"");
+ result.append(a);
+ result.append("\"");
}
else
{
- result.append(_adapterId);
+ result.append(_adapterId);
}
return result;
}
@@ -1713,59 +1713,59 @@ IceInternal::IndirectReference::getConnection(bool& comp) const
while(true)
{
- vector<EndpointIPtr> endpts = RoutableReference::getRoutedEndpoints();
- bool cached = false;
- if(endpts.empty() && _locatorInfo)
- {
- const IndirectReferencePtr self = const_cast<IndirectReference*>(this);
- endpts = _locatorInfo->getEndpoints(self, _locatorCacheTimeout, cached);
- }
-
- applyOverrides(endpts);
-
- try
- {
- connection = createConnection(endpts, comp);
- assert(connection);
- }
- catch(const NoEndpointException& ex)
- {
- throw ex; // No need to retry if there's no endpoints.
- }
- catch(const LocalException& ex)
- {
- if(!getRouterInfo())
- {
- assert(_locatorInfo);
-
- // COMPILERFIX: Braces needed to prevent BCB from causing Reference refCount from
- // being decremented twice when loop continues.
- {
- const IndirectReferencePtr self = const_cast<IndirectReference*>(this);
- _locatorInfo->clearCache(self);
- }
-
- if(cached)
- {
- // COMPILERFIX: Braces needed to prevent BCB from causing TraceLevels refCount from
- // being decremented twice when loop continues.
- {
- TraceLevelsPtr traceLevels = getInstance()->traceLevels();
- if(traceLevels->retry >= 2)
- {
- Trace out(getInstance()->initializationData().logger, traceLevels->retryCat);
- out << "connection to cached endpoints failed\n"
- << "removing endpoints from cache and trying one more time\n" << ex;
- }
- }
- continue;
- }
- }
-
- throw;
- }
-
- break;
+ vector<EndpointIPtr> endpts = RoutableReference::getRoutedEndpoints();
+ bool cached = false;
+ if(endpts.empty() && _locatorInfo)
+ {
+ const IndirectReferencePtr self = const_cast<IndirectReference*>(this);
+ endpts = _locatorInfo->getEndpoints(self, _locatorCacheTimeout, cached);
+ }
+
+ applyOverrides(endpts);
+
+ try
+ {
+ connection = createConnection(endpts, comp);
+ assert(connection);
+ }
+ catch(const NoEndpointException& ex)
+ {
+ throw ex; // No need to retry if there's no endpoints.
+ }
+ catch(const LocalException& ex)
+ {
+ if(!getRouterInfo())
+ {
+ assert(_locatorInfo);
+
+ // COMPILERFIX: Braces needed to prevent BCB from causing Reference refCount from
+ // being decremented twice when loop continues.
+ {
+ const IndirectReferencePtr self = const_cast<IndirectReference*>(this);
+ _locatorInfo->clearCache(self);
+ }
+
+ if(cached)
+ {
+ // COMPILERFIX: Braces needed to prevent BCB from causing TraceLevels refCount from
+ // being decremented twice when loop continues.
+ {
+ TraceLevelsPtr traceLevels = getInstance()->traceLevels();
+ if(traceLevels->retry >= 2)
+ {
+ Trace out(getInstance()->initializationData().logger, traceLevels->retryCat);
+ out << "connection to cached endpoints failed\n"
+ << "removing endpoints from cache and trying one more time\n" << ex;
+ }
+ }
+ continue;
+ }
+ }
+
+ throw;
+ }
+
+ break;
}
//
@@ -1815,7 +1815,7 @@ IceInternal::IndirectReference::operator==(const Reference& r) const
}
return _adapterId == rhs->_adapterId && _locatorInfo == rhs->_locatorInfo &&
- _locatorCacheTimeout == rhs->_locatorCacheTimeout;
+ _locatorCacheTimeout == rhs->_locatorCacheTimeout;
}
bool
@@ -1838,26 +1838,26 @@ IceInternal::IndirectReference::operator<(const Reference& r) const
if(RoutableReference::operator==(r))
{
const IndirectReference* rhs = dynamic_cast<const IndirectReference*>(&r);
- assert(rhs);
- if(_adapterId < rhs->_adapterId)
- {
- return true;
- }
- else if(rhs->_adapterId < _adapterId)
- {
- return false;
- }
-
- if(_locatorInfo < rhs->_locatorInfo)
- {
- return true;
- }
- else if(rhs->_locatorInfo < _locatorInfo)
- {
- return false;
- }
-
- return _locatorCacheTimeout < rhs->_locatorCacheTimeout;
+ assert(rhs);
+ if(_adapterId < rhs->_adapterId)
+ {
+ return true;
+ }
+ else if(rhs->_adapterId < _adapterId)
+ {
+ return false;
+ }
+
+ if(_locatorInfo < rhs->_locatorInfo)
+ {
+ return true;
+ }
+ else if(rhs->_locatorInfo < _locatorInfo)
+ {
+ return false;
+ }
+
+ return _locatorCacheTimeout < rhs->_locatorCacheTimeout;
}
return false;
}
diff --git a/cpp/src/Ice/Reference.h b/cpp/src/Ice/Reference.h
index bd88dcc6826..4b9a07c259e 100644
--- a/cpp/src/Ice/Reference.h
+++ b/cpp/src/Ice/Reference.h
@@ -35,19 +35,19 @@ public:
enum Type
{
- TypeDirect,
- TypeIndirect,
- TypeFixed
+ TypeDirect,
+ TypeIndirect,
+ TypeFixed
};
enum Mode
{
- ModeTwoway,
- ModeOneway,
- ModeBatchOneway,
- ModeDatagram,
- ModeBatchDatagram,
- ModeLast = ModeBatchDatagram
+ ModeTwoway,
+ ModeOneway,
+ ModeBatchOneway,
+ ModeDatagram,
+ ModeBatchDatagram,
+ ModeLast = ModeBatchDatagram
};
Mode getMode() const { return _mode; }
@@ -125,7 +125,7 @@ public:
protected:
Reference(const InstancePtr&, const Ice::CommunicatorPtr&, const Ice::Identity&, const SharedContextPtr&,
- const std::string&, Mode);
+ const std::string&, Mode);
Reference(const Reference&);
IceUtil::RecMutex _hashMutex; // For lazy initialization of hash value.
@@ -148,7 +148,7 @@ class FixedReference : public Reference
public:
FixedReference(const InstancePtr&, const Ice::CommunicatorPtr&, const Ice::Identity&, const SharedContextPtr&,
- const std::string&, Mode, const std::vector<Ice::ConnectionIPtr>&);
+ const std::string&, Mode, const std::vector<Ice::ConnectionIPtr>&);
const std::vector<Ice::ConnectionIPtr>& getFixedConnections() const;
@@ -238,7 +238,7 @@ public:
protected:
RoutableReference(const InstancePtr&, const Ice::CommunicatorPtr&, const Ice::Identity&, const SharedContextPtr&,
- const std::string&, Mode, bool, bool, const RouterInfoPtr&, bool, bool,
+ const std::string&, Mode, bool, bool, const RouterInfoPtr&, bool, bool,
Ice::EndpointSelectionType, bool);
RoutableReference(const RoutableReference&);
@@ -267,7 +267,7 @@ class DirectReference : public RoutableReference
public:
DirectReference(const InstancePtr&, const Ice::CommunicatorPtr&, const Ice::Identity&, const SharedContextPtr&,
- const std::string&, Mode, bool, bool, const std::vector<EndpointIPtr>&, const RouterInfoPtr&, bool,
+ const std::string&, Mode, bool, bool, const std::vector<EndpointIPtr>&, const RouterInfoPtr&, bool,
bool, Ice::EndpointSelectionType, bool);
virtual Type getType() const;
@@ -307,8 +307,8 @@ class IndirectReference : public RoutableReference
public:
IndirectReference(const InstancePtr&, const Ice::CommunicatorPtr&, const Ice::Identity&, const SharedContextPtr&,
- const std::string&, Mode, bool, bool, const std::string&, const RouterInfoPtr&,
- const LocatorInfoPtr&, bool, bool, Ice::EndpointSelectionType, bool, int);
+ const std::string&, Mode, bool, bool, const std::string&, const RouterInfoPtr&,
+ const LocatorInfoPtr&, bool, bool, Ice::EndpointSelectionType, bool, int);
virtual LocatorInfoPtr getLocatorInfo() const { return _locatorInfo; }
diff --git a/cpp/src/Ice/ReferenceFactory.cpp b/cpp/src/Ice/ReferenceFactory.cpp
index 9e2105beaa7..13348367d9a 100644
--- a/cpp/src/Ice/ReferenceFactory.cpp
+++ b/cpp/src/Ice/ReferenceFactory.cpp
@@ -38,7 +38,7 @@ IceInternal::ReferenceFactory::copy(const Reference* r) const
if(!_instance)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
const Ice::Identity& ident = r->getIdentity();
@@ -52,14 +52,14 @@ IceInternal::ReferenceFactory::copy(const Reference* r) const
ReferencePtr
IceInternal::ReferenceFactory::create(const Identity& ident,
- const SharedContextPtr& context,
- const string& facet,
- Reference::Mode mode,
- bool secure,
- bool preferSecure,
- const vector<EndpointIPtr>& endpoints,
- const RouterInfoPtr& routerInfo,
- bool collocationOptimization,
+ const SharedContextPtr& context,
+ const string& facet,
+ Reference::Mode mode,
+ bool secure,
+ bool preferSecure,
+ const vector<EndpointIPtr>& endpoints,
+ const RouterInfoPtr& routerInfo,
+ bool collocationOptimization,
bool cacheConnection,
EndpointSelectionType endpointSelection,
bool threadPerConnection)
@@ -68,7 +68,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident,
if(!_instance)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
if(ident.name.empty() && ident.category.empty())
@@ -80,31 +80,31 @@ IceInternal::ReferenceFactory::create(const Identity& ident,
// Create new reference
//
return new DirectReference(_instance, _communicator, ident, context, facet, mode, secure, preferSecure,
- endpoints, routerInfo, collocationOptimization, cacheConnection, endpointSelection,
+ endpoints, routerInfo, collocationOptimization, cacheConnection, endpointSelection,
threadPerConnection);
}
ReferencePtr
IceInternal::ReferenceFactory::create(const Identity& ident,
- const SharedContextPtr& context,
- const string& facet,
- Reference::Mode mode,
- bool secure,
- bool preferSecure,
- const string& adapterId,
- const RouterInfoPtr& routerInfo,
- const LocatorInfoPtr& locatorInfo,
- bool collocationOptimization,
+ const SharedContextPtr& context,
+ const string& facet,
+ Reference::Mode mode,
+ bool secure,
+ bool preferSecure,
+ const string& adapterId,
+ const RouterInfoPtr& routerInfo,
+ const LocatorInfoPtr& locatorInfo,
+ bool collocationOptimization,
bool cacheConnection,
EndpointSelectionType endpointSelection,
bool threadPerConnection,
- int locatorCacheTimeout)
+ int locatorCacheTimeout)
{
IceUtil::Mutex::Lock sync(*this);
if(!_instance)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
if(ident.name.empty() && ident.category.empty())
@@ -116,22 +116,22 @@ IceInternal::ReferenceFactory::create(const Identity& ident,
// Create new reference
//
return new IndirectReference(_instance, _communicator, ident, context, facet, mode, secure, preferSecure,
- adapterId, routerInfo, locatorInfo, collocationOptimization, cacheConnection,
+ adapterId, routerInfo, locatorInfo, collocationOptimization, cacheConnection,
endpointSelection, threadPerConnection, locatorCacheTimeout);
}
ReferencePtr
IceInternal::ReferenceFactory::create(const Identity& ident,
- const SharedContextPtr& context,
- const string& facet,
- Reference::Mode mode,
- const vector<Ice::ConnectionIPtr>& fixedConnections)
+ const SharedContextPtr& context,
+ const string& facet,
+ Reference::Mode mode,
+ const vector<Ice::ConnectionIPtr>& fixedConnections)
{
IceUtil::Mutex::Lock sync(*this);
if(!_instance)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
if(ident.name.empty() && ident.category.empty())
@@ -162,9 +162,9 @@ IceInternal::ReferenceFactory::create(const string& str)
beg = s.find_first_not_of(delim, end);
if(beg == string::npos)
{
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
}
//
@@ -175,9 +175,9 @@ IceInternal::ReferenceFactory::create(const string& str)
end = IceUtil::checkQuote(s, beg);
if(end == string::npos)
{
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
}
else if(end == 0)
{
@@ -197,9 +197,9 @@ IceInternal::ReferenceFactory::create(const string& str)
if(beg == end)
{
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
}
//
@@ -243,54 +243,54 @@ IceInternal::ReferenceFactory::create(const string& str)
while(true)
{
- beg = s.find_first_not_of(delim, end);
- if(beg == string::npos)
- {
- break;
- }
+ beg = s.find_first_not_of(delim, end);
+ if(beg == string::npos)
+ {
+ break;
+ }
if(s[beg] == ':' || s[beg] == '@')
{
break;
}
- end = s.find_first_of(delim + ":@", beg);
- if(end == string::npos)
- {
- end = s.length();
- }
-
- if(beg == end)
- {
- break;
- }
-
- string option = s.substr(beg, end - beg);
- if(option.length() != 2 || option[0] != '-')
- {
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
- }
+ end = s.find_first_of(delim + ":@", beg);
+ if(end == string::npos)
+ {
+ end = s.length();
+ }
+
+ if(beg == end)
+ {
+ break;
+ }
+
+ string option = s.substr(beg, end - beg);
+ if(option.length() != 2 || option[0] != '-')
+ {
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
+ }
//
// Check for the presence of an option argument. The
// argument may be enclosed in single or double
// quotation marks.
//
- string argument;
- string::size_type argumentBeg = s.find_first_not_of(delim, end);
- if(argumentBeg != string::npos)
- {
+ string argument;
+ string::size_type argumentBeg = s.find_first_not_of(delim, end);
+ if(argumentBeg != string::npos)
+ {
if(s[argumentBeg] != '@' && s[argumentBeg] != ':' && s[argumentBeg] != '-')
{
beg = argumentBeg;
end = IceUtil::checkQuote(s, beg);
if(end == string::npos)
{
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
}
else if(end == 0)
{
@@ -307,122 +307,122 @@ IceInternal::ReferenceFactory::create(const string& str)
argument = s.substr(beg, end - beg);
end++; // Skip trailing quote
}
- }
- }
-
- //
- // If any new options are added here,
- // IceInternal::Reference::toString() and its derived classes must be updated as well.
- //
- switch(option[1])
- {
- case 'f':
- {
- if(argument.empty())
- {
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
- }
-
- if(!IceUtil::unescapeString(argument, 0, argument.size(), facet))
- {
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
- }
-
- if(_instance->initializationData().stringConverter)
- {
- string tmpFacet;
- _instance->initializationData().stringConverter->fromUTF8(
- reinterpret_cast<const Byte*>(facet.data()),
- reinterpret_cast<const Byte*>(facet.data() + facet.size()), tmpFacet);
- facet = tmpFacet;
- }
-
- break;
- }
-
- case 't':
- {
- if(!argument.empty())
- {
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
- }
- mode = Reference::ModeTwoway;
- break;
- }
-
- case 'o':
- {
- if(!argument.empty())
- {
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
- }
- mode = Reference::ModeOneway;
- break;
- }
-
- case 'O':
- {
- if(!argument.empty())
- {
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
- }
- mode = Reference::ModeBatchOneway;
- break;
- }
-
- case 'd':
- {
- if(!argument.empty())
- {
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
- }
- mode = Reference::ModeDatagram;
- break;
- }
-
- case 'D':
- {
- if(!argument.empty())
- {
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
- }
- mode = Reference::ModeBatchDatagram;
- break;
- }
-
- case 's':
- {
- if(!argument.empty())
- {
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
- }
- secure = true;
- break;
- }
-
- default:
- {
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
- }
- }
+ }
+ }
+
+ //
+ // If any new options are added here,
+ // IceInternal::Reference::toString() and its derived classes must be updated as well.
+ //
+ switch(option[1])
+ {
+ case 'f':
+ {
+ if(argument.empty())
+ {
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
+ }
+
+ if(!IceUtil::unescapeString(argument, 0, argument.size(), facet))
+ {
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
+ }
+
+ if(_instance->initializationData().stringConverter)
+ {
+ string tmpFacet;
+ _instance->initializationData().stringConverter->fromUTF8(
+ reinterpret_cast<const Byte*>(facet.data()),
+ reinterpret_cast<const Byte*>(facet.data() + facet.size()), tmpFacet);
+ facet = tmpFacet;
+ }
+
+ break;
+ }
+
+ case 't':
+ {
+ if(!argument.empty())
+ {
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
+ }
+ mode = Reference::ModeTwoway;
+ break;
+ }
+
+ case 'o':
+ {
+ if(!argument.empty())
+ {
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
+ }
+ mode = Reference::ModeOneway;
+ break;
+ }
+
+ case 'O':
+ {
+ if(!argument.empty())
+ {
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
+ }
+ mode = Reference::ModeBatchOneway;
+ break;
+ }
+
+ case 'd':
+ {
+ if(!argument.empty())
+ {
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
+ }
+ mode = Reference::ModeDatagram;
+ break;
+ }
+
+ case 'D':
+ {
+ if(!argument.empty())
+ {
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
+ }
+ mode = Reference::ModeBatchDatagram;
+ break;
+ }
+
+ case 's':
+ {
+ if(!argument.empty())
+ {
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
+ }
+ secure = true;
+ break;
+ }
+
+ default:
+ {
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
+ }
+ }
}
RouterInfoPtr routerInfo = _instance->routerManager()->get(getDefaultRouter());
@@ -430,9 +430,9 @@ IceInternal::ReferenceFactory::create(const string& str)
if(beg == string::npos)
{
- return create(ident, _instance->getDefaultContext(), facet, mode, secure,
- _instance->defaultsAndOverrides()->defaultPreferSecure, "", routerInfo,
- locatorInfo, _instance->defaultsAndOverrides()->defaultCollocationOptimization,
+ return create(ident, _instance->getDefaultContext(), facet, mode, secure,
+ _instance->defaultsAndOverrides()->defaultPreferSecure, "", routerInfo,
+ locatorInfo, _instance->defaultsAndOverrides()->defaultCollocationOptimization,
true, _instance->defaultsAndOverrides()->defaultEndpointSelection,
_instance->threadPerConnection(), _instance->defaultsAndOverrides()->defaultLocatorCacheTimeout);
}
@@ -441,118 +441,118 @@ IceInternal::ReferenceFactory::create(const string& str)
switch(s[beg])
{
- case ':':
- {
- vector<string> unknownEndpoints;
- end = beg;
-
- while(end < s.length() && s[end] == ':')
- {
- beg = end + 1;
-
- end = s.find(':', beg);
- if(end == string::npos)
- {
- end = s.length();
- }
-
- string es = s.substr(beg, end - beg);
- EndpointIPtr endp = _instance->endpointFactoryManager()->create(es);
- if(endp != 0)
- {
- vector<EndpointIPtr> endps = endp->expand(false);
- endpoints.insert(endpoints.end(), endps.begin(), endps.end());
- }
- else
- {
- unknownEndpoints.push_back(es);
- }
- }
- if(endpoints.size() == 0)
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = unknownEndpoints.front();
- throw ex;
- }
- else if(unknownEndpoints.size() != 0 &&
- _instance->initializationData().properties->
- getPropertyAsIntWithDefault("Ice.Warn.Endpoints", 1) > 0)
- {
- Warning out(_instance->initializationData().logger);
- out << "Proxy contains unknown endpoints:";
- for(unsigned int idx = 0; idx < unknownEndpoints.size(); ++idx)
- {
- out << " `" << unknownEndpoints[idx] << "'";
- }
- }
-
- return create(ident, _instance->getDefaultContext(), facet, mode, secure,
- _instance->defaultsAndOverrides()->defaultPreferSecure, endpoints, routerInfo,
- _instance->defaultsAndOverrides()->defaultCollocationOptimization, true,
+ case ':':
+ {
+ vector<string> unknownEndpoints;
+ end = beg;
+
+ while(end < s.length() && s[end] == ':')
+ {
+ beg = end + 1;
+
+ end = s.find(':', beg);
+ if(end == string::npos)
+ {
+ end = s.length();
+ }
+
+ string es = s.substr(beg, end - beg);
+ EndpointIPtr endp = _instance->endpointFactoryManager()->create(es);
+ if(endp != 0)
+ {
+ vector<EndpointIPtr> endps = endp->expand(false);
+ endpoints.insert(endpoints.end(), endps.begin(), endps.end());
+ }
+ else
+ {
+ unknownEndpoints.push_back(es);
+ }
+ }
+ if(endpoints.size() == 0)
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = unknownEndpoints.front();
+ throw ex;
+ }
+ else if(unknownEndpoints.size() != 0 &&
+ _instance->initializationData().properties->
+ getPropertyAsIntWithDefault("Ice.Warn.Endpoints", 1) > 0)
+ {
+ Warning out(_instance->initializationData().logger);
+ out << "Proxy contains unknown endpoints:";
+ for(unsigned int idx = 0; idx < unknownEndpoints.size(); ++idx)
+ {
+ out << " `" << unknownEndpoints[idx] << "'";
+ }
+ }
+
+ return create(ident, _instance->getDefaultContext(), facet, mode, secure,
+ _instance->defaultsAndOverrides()->defaultPreferSecure, endpoints, routerInfo,
+ _instance->defaultsAndOverrides()->defaultCollocationOptimization, true,
_instance->defaultsAndOverrides()->defaultEndpointSelection,
_instance->threadPerConnection());
- break;
- }
- case '@':
- {
- beg = s.find_first_not_of(delim, beg + 1);
- if(beg == string::npos)
- {
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
- }
-
- end = IceUtil::checkQuote(s, beg);
- if(end == string::npos)
- {
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
- }
- else if(end == 0)
- {
- end = s.find_first_of(delim, beg);
- if(end == string::npos)
- {
- end = s.size();
- }
- }
- else
- {
- beg++; // Skip leading quote
- }
-
-
- if(!IceUtil::unescapeString(s, beg, end, adapter) || adapter.size() == 0)
- {
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
- }
+ break;
+ }
+ case '@':
+ {
+ beg = s.find_first_not_of(delim, beg + 1);
+ if(beg == string::npos)
+ {
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
+ }
+
+ end = IceUtil::checkQuote(s, beg);
+ if(end == string::npos)
+ {
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
+ }
+ else if(end == 0)
+ {
+ end = s.find_first_of(delim, beg);
+ if(end == string::npos)
+ {
+ end = s.size();
+ }
+ }
+ else
+ {
+ beg++; // Skip leading quote
+ }
+
+
+ if(!IceUtil::unescapeString(s, beg, end, adapter) || adapter.size() == 0)
+ {
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
+ }
if(_instance->initializationData().stringConverter)
{
- string tmpAdapter;
+ string tmpAdapter;
_instance->initializationData().stringConverter->fromUTF8(
- reinterpret_cast<const Byte*>(adapter.data()),
- reinterpret_cast<const Byte*>(adapter.data() + adapter.size()), tmpAdapter);
- adapter = tmpAdapter;
+ reinterpret_cast<const Byte*>(adapter.data()),
+ reinterpret_cast<const Byte*>(adapter.data() + adapter.size()), tmpAdapter);
+ adapter = tmpAdapter;
}
-
- return create(ident, _instance->getDefaultContext(), facet, mode, secure,
- _instance->defaultsAndOverrides()->defaultPreferSecure, adapter, routerInfo, locatorInfo,
- _instance->defaultsAndOverrides()->defaultCollocationOptimization, true,
+
+ return create(ident, _instance->getDefaultContext(), facet, mode, secure,
+ _instance->defaultsAndOverrides()->defaultPreferSecure, adapter, routerInfo, locatorInfo,
+ _instance->defaultsAndOverrides()->defaultCollocationOptimization, true,
_instance->defaultsAndOverrides()->defaultEndpointSelection, _instance->threadPerConnection(),
- _instance->defaultsAndOverrides()->defaultLocatorCacheTimeout);
- break;
- }
- default:
- {
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
- }
+ _instance->defaultsAndOverrides()->defaultLocatorCacheTimeout);
+ break;
+ }
+ default:
+ {
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
+ }
}
return 0; // Unreachable, prevents compiler warning.
@@ -573,7 +573,7 @@ IceInternal::ReferenceFactory::createFromProperties(const string& propertyPrefix
if(!properties->getProperty(property).empty())
{
ref = ref->changeLocator(
- LocatorPrx::uncheckedCast(_communicator->propertyToProxy(property)));
+ LocatorPrx::uncheckedCast(_communicator->propertyToProxy(property)));
}
property = propertyPrefix + ".LocatorCacheTimeout";
@@ -586,7 +586,7 @@ IceInternal::ReferenceFactory::createFromProperties(const string& propertyPrefix
if(!properties->getProperty(property).empty())
{
ref = ref->changeRouter(
- RouterPrx::uncheckedCast(_communicator->propertyToProxy(property)));
+ RouterPrx::uncheckedCast(_communicator->propertyToProxy(property)));
}
property = propertyPrefix + ".PreferSecure";
@@ -606,19 +606,19 @@ IceInternal::ReferenceFactory::createFromProperties(const string& propertyPrefix
{
string type = properties->getProperty(property);
if(type == "Random")
- {
- ref = ref->changeEndpointSelection(Random);
- }
- else if(type == "Ordered")
- {
- ref = ref->changeEndpointSelection(Ordered);
- }
- else
- {
- EndpointSelectionTypeParseException ex(__FILE__, __LINE__);
- ex.str = type;
- throw ex;
- }
+ {
+ ref = ref->changeEndpointSelection(Random);
+ }
+ else if(type == "Ordered")
+ {
+ ref = ref->changeEndpointSelection(Ordered);
+ }
+ else
+ {
+ EndpointSelectionTypeParseException ex(__FILE__, __LINE__);
+ ex.str = type;
+ throw ex;
+ }
}
property = propertyPrefix + ".CollocationOptimization";
@@ -646,7 +646,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s)
if(ident.name.empty() && ident.category.empty())
{
- return 0;
+ return 0;
}
//
@@ -657,10 +657,10 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s)
string facet;
if(!facetPath.empty())
{
- if(facetPath.size() > 1)
- {
- throw ProxyUnmarshalException(__FILE__, __LINE__);
- }
+ if(facetPath.size() > 1)
+ {
+ throw ProxyUnmarshalException(__FILE__, __LINE__);
+ }
facet.swap(facetPath[0]);
}
@@ -669,7 +669,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s)
Reference::Mode mode = static_cast<Reference::Mode>(modeAsByte);
if(mode < 0 || mode > Reference::ModeLast)
{
- throw ProxyUnmarshalException(__FILE__, __LINE__);
+ throw ProxyUnmarshalException(__FILE__, __LINE__);
}
bool secure;
@@ -686,25 +686,25 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s)
if(sz > 0)
{
- endpoints.reserve(sz);
- while(sz--)
- {
- EndpointIPtr endpoint = _instance->endpointFactoryManager()->read(s);
- endpoints.push_back(endpoint);
- }
- return create(ident, _instance->getDefaultContext(), facet, mode, secure,
- _instance->defaultsAndOverrides()->defaultPreferSecure, endpoints, routerInfo,
- _instance->defaultsAndOverrides()->defaultCollocationOptimization, true,
- _instance->defaultsAndOverrides()->defaultEndpointSelection, _instance->threadPerConnection());
+ endpoints.reserve(sz);
+ while(sz--)
+ {
+ EndpointIPtr endpoint = _instance->endpointFactoryManager()->read(s);
+ endpoints.push_back(endpoint);
+ }
+ return create(ident, _instance->getDefaultContext(), facet, mode, secure,
+ _instance->defaultsAndOverrides()->defaultPreferSecure, endpoints, routerInfo,
+ _instance->defaultsAndOverrides()->defaultCollocationOptimization, true,
+ _instance->defaultsAndOverrides()->defaultEndpointSelection, _instance->threadPerConnection());
}
else
{
- s->read(adapterId);
- return create(ident, _instance->getDefaultContext(), facet, mode, secure,
- _instance->defaultsAndOverrides()->defaultPreferSecure, adapterId, routerInfo, locatorInfo,
- _instance->defaultsAndOverrides()->defaultCollocationOptimization, true,
- _instance->defaultsAndOverrides()->defaultEndpointSelection, _instance->threadPerConnection(),
- _instance->defaultsAndOverrides()->defaultLocatorCacheTimeout);
+ s->read(adapterId);
+ return create(ident, _instance->getDefaultContext(), facet, mode, secure,
+ _instance->defaultsAndOverrides()->defaultPreferSecure, adapterId, routerInfo, locatorInfo,
+ _instance->defaultsAndOverrides()->defaultCollocationOptimization, true,
+ _instance->defaultsAndOverrides()->defaultEndpointSelection, _instance->threadPerConnection(),
+ _instance->defaultsAndOverrides()->defaultLocatorCacheTimeout);
}
}
@@ -749,7 +749,7 @@ IceInternal::ReferenceFactory::destroy()
if(!_instance)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
_instance = 0;
diff --git a/cpp/src/Ice/ReferenceFactory.h b/cpp/src/Ice/ReferenceFactory.h
index cea63de6757..e687c956255 100644
--- a/cpp/src/Ice/ReferenceFactory.h
+++ b/cpp/src/Ice/ReferenceFactory.h
@@ -32,19 +32,19 @@ public:
// Create a direct reference.
//
ReferencePtr create(const ::Ice::Identity&, const SharedContextPtr&, const ::std::string&,
- Reference::Mode, bool, bool, const ::std::vector<EndpointIPtr>&,
- const RouterInfoPtr&, bool, bool, Ice::EndpointSelectionType, bool);
+ Reference::Mode, bool, bool, const ::std::vector<EndpointIPtr>&,
+ const RouterInfoPtr&, bool, bool, Ice::EndpointSelectionType, bool);
//
// Create an indirect reference.
//
ReferencePtr create(const ::Ice::Identity&, const SharedContextPtr&, const ::std::string&,
- Reference::Mode, bool, bool, const ::std::string&,
- const RouterInfoPtr&, const LocatorInfoPtr&, bool, bool, Ice::EndpointSelectionType, bool, int);
+ Reference::Mode, bool, bool, const ::std::string&,
+ const RouterInfoPtr&, const LocatorInfoPtr&, bool, bool, Ice::EndpointSelectionType, bool, int);
//
// Create a fixed reference.
//
ReferencePtr create(const ::Ice::Identity&, const SharedContextPtr&, const ::std::string&,
- Reference::Mode, const ::std::vector< ::Ice::ConnectionIPtr>&);
+ Reference::Mode, const ::std::vector< ::Ice::ConnectionIPtr>&);
//
// Create a reference from a string.
diff --git a/cpp/src/Ice/RouterInfo.cpp b/cpp/src/Ice/RouterInfo.cpp
index d5294304d2c..8eb60be1bdd 100644
--- a/cpp/src/Ice/RouterInfo.cpp
+++ b/cpp/src/Ice/RouterInfo.cpp
@@ -45,7 +45,7 @@ IceInternal::RouterManager::get(const RouterPrx& rtr)
{
if(!rtr)
{
- return 0;
+ return 0;
}
RouterPrx router = RouterPrx::uncheckedCast(rtr->ice_router(0)); // The router cannot be routed.
@@ -56,24 +56,24 @@ IceInternal::RouterManager::get(const RouterPrx& rtr)
if(_tableHint != _table.end())
{
- if(_tableHint->first == router)
- {
- p = _tableHint;
- }
+ if(_tableHint->first == router)
+ {
+ p = _tableHint;
+ }
}
if(p == _table.end())
{
- p = _table.find(router);
+ p = _table.find(router);
}
if(p == _table.end())
{
- _tableHint = _table.insert(_tableHint, pair<const RouterPrx, RouterInfoPtr>(router, new RouterInfo(router)));
+ _tableHint = _table.insert(_tableHint, pair<const RouterPrx, RouterInfoPtr>(router, new RouterInfo(router)));
}
else
{
- _tableHint = p;
+ _tableHint = p;
}
return _tableHint->second;
@@ -85,26 +85,26 @@ IceInternal::RouterManager::erase(const RouterPrx& rtr)
RouterInfoPtr info;
if(rtr)
{
- RouterPrx router = RouterPrx::uncheckedCast(rtr->ice_router(0)); // The router cannot be routed.
- IceUtil::Mutex::Lock sync(*this);
-
- map<RouterPrx, RouterInfoPtr>::iterator p = _table.end();
- if(_tableHint != _table.end() && _tableHint->first == router)
- {
- p = _tableHint;
- _tableHint = _table.end();
- }
-
- if(p == _table.end())
- {
- p = _table.find(router);
- }
-
- if(p != _table.end())
- {
- info = p->second;
- _table.erase(p);
- }
+ RouterPrx router = RouterPrx::uncheckedCast(rtr->ice_router(0)); // The router cannot be routed.
+ IceUtil::Mutex::Lock sync(*this);
+
+ map<RouterPrx, RouterInfoPtr>::iterator p = _table.end();
+ if(_tableHint != _table.end() && _tableHint->first == router)
+ {
+ p = _tableHint;
+ _tableHint = _table.end();
+ }
+
+ if(p == _table.end())
+ {
+ p = _table.find(router);
+ }
+
+ if(p != _table.end())
+ {
+ info = p->second;
+ _table.erase(p);
+ }
}
return info;
@@ -161,34 +161,34 @@ IceInternal::RouterInfo::getClientEndpoints()
if(_clientEndpoints.size() == 0) // Lazy initialization.
{
- ObjectPrx clientProxy = _router->getClientProxy();
- if(!clientProxy)
- {
- //
- // If getClientProxy() return nil, use router endpoints.
- //
- _clientEndpoints = _router->__reference()->getEndpoints();
- }
- else
- {
- clientProxy = clientProxy->ice_router(0); // The client proxy cannot be routed.
-
- //
- // In order to avoid creating a new connection to the router,
- // we must use the same timeout as the already existing
- // connection.
- //
- try
- {
- clientProxy = clientProxy->ice_timeout(_router->ice_getConnection()->timeout());
- }
- catch(const Ice::CollocationOptimizationException&)
- {
- // Ignore - collocated router
- }
-
- _clientEndpoints = clientProxy->__reference()->getEndpoints();
- }
+ ObjectPrx clientProxy = _router->getClientProxy();
+ if(!clientProxy)
+ {
+ //
+ // If getClientProxy() return nil, use router endpoints.
+ //
+ _clientEndpoints = _router->__reference()->getEndpoints();
+ }
+ else
+ {
+ clientProxy = clientProxy->ice_router(0); // The client proxy cannot be routed.
+
+ //
+ // In order to avoid creating a new connection to the router,
+ // we must use the same timeout as the already existing
+ // connection.
+ //
+ try
+ {
+ clientProxy = clientProxy->ice_timeout(_router->ice_getConnection()->timeout());
+ }
+ catch(const Ice::CollocationOptimizationException&)
+ {
+ // Ignore - collocated router
+ }
+
+ _clientEndpoints = clientProxy->__reference()->getEndpoints();
+ }
}
return _clientEndpoints;
@@ -201,15 +201,15 @@ IceInternal::RouterInfo::getServerEndpoints()
if(_serverEndpoints.size() == 0) // Lazy initialization.
{
- ObjectPrx serverProxy = _router->getServerProxy();
- if(!serverProxy)
- {
- throw NoEndpointException(__FILE__, __LINE__);
- }
+ ObjectPrx serverProxy = _router->getServerProxy();
+ if(!serverProxy)
+ {
+ throw NoEndpointException(__FILE__, __LINE__);
+ }
- serverProxy = serverProxy->ice_router(0); // The server proxy cannot be routed.
+ serverProxy = serverProxy->ice_router(0); // The server proxy cannot be routed.
- _serverEndpoints = serverProxy->__reference()->getEndpoints();
+ _serverEndpoints = serverProxy->__reference()->getEndpoints();
}
return _serverEndpoints;
@@ -226,25 +226,25 @@ IceInternal::RouterInfo::addProxy(const ObjectPrx& proxy)
if(p == _identities.end())
{
- //
- // Only add the proxy to the router if it's not already in our local map.
- //
- ObjectProxySeq proxies;
- proxies.push_back(proxy);
- ObjectProxySeq evictedProxies = _router->addProxies(proxies);
-
- //
- // If we successfully added the proxy to the router, we add it to our local map.
- //
- _identities.insert(_identities.begin(), proxy->ice_getIdentity());
-
- //
- // We also must remove whatever proxies the router evicted.
- //
- for(ObjectProxySeq::iterator q = evictedProxies.begin(); q != evictedProxies.end(); ++q)
- {
- _identities.erase((*q)->ice_getIdentity());
- }
+ //
+ // Only add the proxy to the router if it's not already in our local map.
+ //
+ ObjectProxySeq proxies;
+ proxies.push_back(proxy);
+ ObjectProxySeq evictedProxies = _router->addProxies(proxies);
+
+ //
+ // If we successfully added the proxy to the router, we add it to our local map.
+ //
+ _identities.insert(_identities.begin(), proxy->ice_getIdentity());
+
+ //
+ // We also must remove whatever proxies the router evicted.
+ //
+ for(ObjectProxySeq::iterator q = evictedProxies.begin(); q != evictedProxies.end(); ++q)
+ {
+ _identities.erase((*q)->ice_getIdentity());
+ }
}
}
diff --git a/cpp/src/Ice/ServantManager.cpp b/cpp/src/Ice/ServantManager.cpp
index 4f2ad489d1e..0a9a6d010ce 100644
--- a/cpp/src/Ice/ServantManager.cpp
+++ b/cpp/src/Ice/ServantManager.cpp
@@ -35,26 +35,26 @@ IceInternal::ServantManager::addServant(const ObjectPtr& object, const Identity&
if(p == _servantMapMap.end() || p->first != ident)
{
- p = _servantMapMap.find(ident);
+ p = _servantMapMap.find(ident);
}
if(p == _servantMapMap.end())
{
- p = _servantMapMap.insert(_servantMapMapHint, pair<const Identity, FacetMap>(ident, FacetMap()));
+ p = _servantMapMap.insert(_servantMapMapHint, pair<const Identity, FacetMap>(ident, FacetMap()));
}
else
{
- if(p->second.find(facet) != p->second.end())
- {
- AlreadyRegisteredException ex(__FILE__, __LINE__);
- ex.kindOfObject = "servant";
- ex.id = _instance->identityToString(ident);
- if(!facet.empty())
- {
- ex.id += " -f " + IceUtil::escapeString(facet, "");
- }
- throw ex;
- }
+ if(p->second.find(facet) != p->second.end())
+ {
+ AlreadyRegisteredException ex(__FILE__, __LINE__);
+ ex.kindOfObject = "servant";
+ ex.id = _instance->identityToString(ident);
+ if(!facet.empty())
+ {
+ ex.id += " -f " + IceUtil::escapeString(facet, "");
+ }
+ throw ex;
+ }
}
_servantMapMapHint = p;
@@ -81,19 +81,19 @@ IceInternal::ServantManager::removeServant(const Identity& ident, const string&
if(p == _servantMapMap.end() || p->first != ident)
{
- p = _servantMapMap.find(ident);
+ p = _servantMapMap.find(ident);
}
if(p == _servantMapMap.end() || (q = p->second.find(facet)) == p->second.end())
{
- NotRegisteredException ex(__FILE__, __LINE__);
- ex.kindOfObject = "servant";
- ex.id = _instance->identityToString(ident);
- if(!facet.empty())
- {
- ex.id += " -f " + IceUtil::escapeString(facet, "");
- }
- throw ex;
+ NotRegisteredException ex(__FILE__, __LINE__);
+ ex.kindOfObject = "servant";
+ ex.id = _instance->identityToString(ident);
+ if(!facet.empty())
+ {
+ ex.id += " -f " + IceUtil::escapeString(facet, "");
+ }
+ throw ex;
}
servant = q->second;
@@ -101,15 +101,15 @@ IceInternal::ServantManager::removeServant(const Identity& ident, const string&
if(p->second.empty())
{
- if(p == _servantMapMapHint)
- {
- _servantMapMap.erase(p++);
- _servantMapMapHint = p;
- }
- else
- {
- _servantMapMap.erase(p);
- }
+ if(p == _servantMapMapHint)
+ {
+ _servantMapMap.erase(p++);
+ _servantMapMapHint = p;
+ }
+ else
+ {
+ _servantMapMap.erase(p);
+ }
}
return servant;
}
@@ -125,27 +125,27 @@ IceInternal::ServantManager::removeAllFacets(const Identity& ident)
if(p == _servantMapMap.end() || p->first != ident)
{
- p = _servantMapMap.find(ident);
+ p = _servantMapMap.find(ident);
}
if(p == _servantMapMap.end())
{
- NotRegisteredException ex(__FILE__, __LINE__);
- ex.kindOfObject = "servant";
- ex.id = _instance->identityToString(ident);
- throw ex;
+ NotRegisteredException ex(__FILE__, __LINE__);
+ ex.kindOfObject = "servant";
+ ex.id = _instance->identityToString(ident);
+ throw ex;
}
FacetMap result = p->second;
if(p == _servantMapMapHint)
{
- _servantMapMap.erase(p++);
- _servantMapMapHint = p;
+ _servantMapMap.erase(p++);
+ _servantMapMapHint = p;
}
else
{
- _servantMapMap.erase(p);
+ _servantMapMap.erase(p);
}
return result;
@@ -171,17 +171,17 @@ IceInternal::ServantManager::findServant(const Identity& ident, const string& fa
if(p == servantMapMap.end() || p->first != ident)
{
- p = servantMapMap.find(ident);
+ p = servantMapMap.find(ident);
}
if(p == servantMapMap.end() || (q = p->second.find(facet)) == p->second.end())
{
- return 0;
+ return 0;
}
else
{
- _servantMapMapHint = p;
- return q->second;
+ _servantMapMapHint = p;
+ return q->second;
}
}
@@ -198,17 +198,17 @@ IceInternal::ServantManager::findAllFacets(const Identity& ident) const
if(p == servantMapMap.end() || p->first != ident)
{
- p = servantMapMap.find(ident);
+ p = servantMapMap.find(ident);
}
if(p == servantMapMap.end())
{
- return FacetMap();
+ return FacetMap();
}
else
{
- _servantMapMapHint = p;
- return p->second;
+ _servantMapMapHint = p;
+ return p->second;
}
}
@@ -230,18 +230,18 @@ IceInternal::ServantManager::hasServant(const Identity& ident) const
if(p == servantMapMap.end() || p->first != ident)
{
- p = servantMapMap.find(ident);
+ p = servantMapMap.find(ident);
}
if(p == servantMapMap.end())
{
- return false;
+ return false;
}
else
{
- _servantMapMapHint = p;
- assert(!p->second.empty());
- return true;
+ _servantMapMapHint = p;
+ assert(!p->second.empty());
+ return true;
}
}
@@ -255,10 +255,10 @@ IceInternal::ServantManager::addServantLocator(const ServantLocatorPtr& locator,
if((_locatorMapHint != _locatorMap.end() && _locatorMapHint->first == category)
|| _locatorMap.find(category) != _locatorMap.end())
{
- AlreadyRegisteredException ex(__FILE__, __LINE__);
- ex.kindOfObject = "servant locator";
- ex.id = IceUtil::escapeString(category, "");
- throw ex;
+ AlreadyRegisteredException ex(__FILE__, __LINE__);
+ ex.kindOfObject = "servant locator";
+ ex.id = IceUtil::escapeString(category, "");
+ throw ex;
}
_locatorMapHint = _locatorMap.insert(_locatorMapHint, pair<const string, ServantLocatorPtr>(category, locator));
@@ -278,30 +278,30 @@ IceInternal::ServantManager::findServantLocator(const string& category) const
//assert(_instance); // Must not be called after destruction.
map<string, ServantLocatorPtr>& locatorMap =
- const_cast<map<string, ServantLocatorPtr>&>(_locatorMap);
+ const_cast<map<string, ServantLocatorPtr>&>(_locatorMap);
map<string, ServantLocatorPtr>::iterator p = locatorMap.end();
if(_locatorMapHint != locatorMap.end())
{
- if(_locatorMapHint->first == category)
- {
- p = _locatorMapHint;
- }
+ if(_locatorMapHint->first == category)
+ {
+ p = _locatorMapHint;
+ }
}
if(p == locatorMap.end())
{
- p = locatorMap.find(category);
+ p = locatorMap.find(category);
}
if(p != locatorMap.end())
{
- _locatorMapHint = p;
- return p->second;
+ _locatorMapHint = p;
+ return p->second;
}
else
{
- return 0;
+ return 0;
}
}
@@ -330,40 +330,40 @@ IceInternal::ServantManager::destroy()
map<string, ServantLocatorPtr> locatorMap;
{
- IceUtil::Mutex::Lock sync(*this);
-
- assert(_instance); // Must not be called after destruction.
-
- servantMapMap.swap(_servantMapMap);
- _servantMapMapHint = _servantMapMap.end();
-
- for(map<string, ServantLocatorPtr>::const_iterator p = _locatorMap.begin(); p != _locatorMap.end(); ++p)
- {
- try
- {
- p->second->deactivate(p->first);
- }
- catch(const Exception& ex)
- {
- Error out(_instance->initializationData().logger);
- out << "exception during locator deactivation:\n"
- << "object adapter: `" << _adapterName << "'\n"
- << "locator category: `" << p->first << "'\n"
- << ex;
- }
- catch(...)
- {
- Error out(_instance->initializationData().logger);
- out << "unknown exception during locator deactivation:\n"
- << "object adapter: `" << _adapterName << "'\n"
- << "locator category: `" << p->first << "'";
- }
- }
-
- locatorMap.swap(_locatorMap);
- _locatorMapHint = _locatorMap.end();
-
- _instance = 0;
+ IceUtil::Mutex::Lock sync(*this);
+
+ assert(_instance); // Must not be called after destruction.
+
+ servantMapMap.swap(_servantMapMap);
+ _servantMapMapHint = _servantMapMap.end();
+
+ for(map<string, ServantLocatorPtr>::const_iterator p = _locatorMap.begin(); p != _locatorMap.end(); ++p)
+ {
+ try
+ {
+ p->second->deactivate(p->first);
+ }
+ catch(const Exception& ex)
+ {
+ Error out(_instance->initializationData().logger);
+ out << "exception during locator deactivation:\n"
+ << "object adapter: `" << _adapterName << "'\n"
+ << "locator category: `" << p->first << "'\n"
+ << ex;
+ }
+ catch(...)
+ {
+ Error out(_instance->initializationData().logger);
+ out << "unknown exception during locator deactivation:\n"
+ << "object adapter: `" << _adapterName << "'\n"
+ << "locator category: `" << p->first << "'";
+ }
+ }
+
+ locatorMap.swap(_locatorMap);
+ _locatorMapHint = _locatorMap.end();
+
+ _instance = 0;
}
//
diff --git a/cpp/src/Ice/Service.cpp b/cpp/src/Ice/Service.cpp
index 21f6a579eb5..d4232d2aefe 100755
--- a/cpp/src/Ice/Service.cpp
+++ b/cpp/src/Ice/Service.cpp
@@ -107,19 +107,19 @@ private:
{
public:
- StatusThread(ServiceStatusManager* manager) :
- _manager(manager)
- {
- }
+ StatusThread(ServiceStatusManager* manager) :
+ _manager(manager)
+ {
+ }
- virtual void run()
- {
- _manager->run();
- }
+ virtual void run()
+ {
+ _manager->run();
+ }
private:
- ServiceStatusManager* _manager;
+ ServiceStatusManager* _manager;
};
friend class StatusThread;
@@ -159,26 +159,26 @@ Ice::Service::shutdown()
{
if(_communicator)
{
- try
- {
- _communicator->shutdown();
- }
- catch(const CommunicatorDestroyedException&)
- {
- //
- // Expected if the service communicator is being destroyed.
- //
- }
- catch(const Ice::Exception& ex)
- {
- ostringstream ostr;
- ostr << "exception during shutdown:\n" << ex;
- warning(ostr.str());
- }
- catch(...)
- {
- warning("unknown exception during shutdown");
- }
+ try
+ {
+ _communicator->shutdown();
+ }
+ catch(const CommunicatorDestroyedException&)
+ {
+ //
+ // Expected if the service communicator is being destroyed.
+ //
+ }
+ catch(const Ice::Exception& ex)
+ {
+ ostringstream ostr;
+ ostr << "exception during shutdown:\n" << ex;
+ warning(ostr.str());
+ }
+ catch(...)
+ {
+ warning("unknown exception during shutdown");
+ }
}
return true;
}
@@ -204,48 +204,48 @@ Ice::Service::main(int& argc, char* argv[], const InitializationData& initData)
{
if(strcmp(argv[idx], "--service") == 0)
{
- //
- // When running as a service, we need a logger to use for reporting any
- // failures that occur prior to initializing a communicator. After we have
- // a communicator, we can use the configured logger instead. If a logger
- // is defined in InitializationData, we'll use that. Otherwise, we create
- // a temporary event logger.
- //
- // We postpone the initialization of the communicator until serviceMain so
- // that we can incorporate the executable's arguments and the service's
- // arguments into one vector.
- //
- _logger = initData.logger;
- if(!_logger)
- {
- try
- {
- //
- // Use the executable name as the source for the temporary logger.
- //
- string loggerName = _name;
- transform(loggerName.begin(), loggerName.end(), loggerName.begin(), ::tolower);
- string::size_type pos = loggerName.find_last_of("\\/");
- if(pos != string::npos)
- {
- loggerName.erase(0, pos + 1); // Remove leading path.
- }
- pos = loggerName.rfind(".exe");
- if(pos != string::npos)
- {
- loggerName.erase(pos, loggerName.size() - pos); // Remove .exe extension.
- }
-
- _logger = new EventLoggerI(loggerName);
- }
- catch(const IceUtil::Exception& ex)
- {
- ostringstream ostr;
- ostr << ex;
- error("unable to create EventLogger:\n" + ostr.str());
- return EXIT_FAILURE;
- }
- }
+ //
+ // When running as a service, we need a logger to use for reporting any
+ // failures that occur prior to initializing a communicator. After we have
+ // a communicator, we can use the configured logger instead. If a logger
+ // is defined in InitializationData, we'll use that. Otherwise, we create
+ // a temporary event logger.
+ //
+ // We postpone the initialization of the communicator until serviceMain so
+ // that we can incorporate the executable's arguments and the service's
+ // arguments into one vector.
+ //
+ _logger = initData.logger;
+ if(!_logger)
+ {
+ try
+ {
+ //
+ // Use the executable name as the source for the temporary logger.
+ //
+ string loggerName = _name;
+ transform(loggerName.begin(), loggerName.end(), loggerName.begin(), ::tolower);
+ string::size_type pos = loggerName.find_last_of("\\/");
+ if(pos != string::npos)
+ {
+ loggerName.erase(0, pos + 1); // Remove leading path.
+ }
+ pos = loggerName.rfind(".exe");
+ if(pos != string::npos)
+ {
+ loggerName.erase(pos, loggerName.size() - pos); // Remove .exe extension.
+ }
+
+ _logger = new EventLoggerI(loggerName);
+ }
+ catch(const IceUtil::Exception& ex)
+ {
+ ostringstream ostr;
+ ostr << ex;
+ error("unable to create EventLogger:\n" + ostr.str());
+ return EXIT_FAILURE;
+ }
+ }
if(idx + 1 >= argc)
{
@@ -439,17 +439,17 @@ Ice::Service::main(int& argc, char* argv[], const InitializationData& initData)
changeDirectory = false;
}
- else if(strcmp(argv[idx], "--pidfile") == 0)
+ else if(strcmp(argv[idx], "--pidfile") == 0)
{
- if(idx + 1 < argc)
- {
- pidFile = argv[idx + 1];
- }
- else
- {
- cerr << argv[0] << ": --pidfile must be followed by an argument" << endl;
- return EXIT_FAILURE;
- }
+ if(idx + 1 < argc)
+ {
+ pidFile = argv[idx + 1];
+ }
+ else
+ {
+ cerr << argv[0] << ": --pidfile must be followed by an argument" << endl;
+ return EXIT_FAILURE;
+ }
for(int i = idx; i + 2 < argc; ++i)
{
@@ -835,8 +835,8 @@ Ice::Service::startService(const string& name, const vector<string>& args)
}
else
{
- showServiceStatus("Service failed to start.", status);
- return EXIT_FAILURE;
+ showServiceStatus("Service failed to start.", status);
+ return EXIT_FAILURE;
}
return EXIT_SUCCESS;
@@ -893,8 +893,8 @@ Ice::Service::stopService(const string& name)
}
else
{
- showServiceStatus("Service failed to stop.", status);
- return EXIT_FAILURE;
+ showServiceStatus("Service failed to stop.", status);
+ return EXIT_FAILURE;
}
return EXIT_SUCCESS;
@@ -1137,11 +1137,11 @@ Ice::Service::terminateService(DWORD exitCode)
status.dwControlsAccepted = 0;
if(exitCode != 0)
{
- status.dwWin32ExitCode = ERROR_SERVICE_SPECIFIC_ERROR;
+ status.dwWin32ExitCode = ERROR_SERVICE_SPECIFIC_ERROR;
}
else
{
- status.dwWin32ExitCode = 0;
+ status.dwWin32ExitCode = 0;
}
status.dwServiceSpecificExitCode = exitCode;
status.dwCheckPoint = 0;
@@ -1155,7 +1155,7 @@ Ice::Service::waitForServiceState(SC_HANDLE hService, DWORD pendingState, SERVIC
{
if(!QueryServiceStatus(hService, &status))
{
- return false;
+ return false;
}
//
@@ -1226,38 +1226,38 @@ Ice::Service::showServiceStatus(const string& msg, SERVICE_STATUS& status)
switch(status.dwCurrentState)
{
case SERVICE_STOPPED:
- state = "STOPPED";
- break;
+ state = "STOPPED";
+ break;
case SERVICE_START_PENDING:
- state = "START PENDING";
- break;
+ state = "START PENDING";
+ break;
case SERVICE_STOP_PENDING:
- state = "STOP PENDING";
- break;
+ state = "STOP PENDING";
+ break;
case SERVICE_RUNNING:
- state = "RUNNING";
- break;
+ state = "RUNNING";
+ break;
case SERVICE_CONTINUE_PENDING:
- state = "CONTINUE PENDING";
- break;
+ state = "CONTINUE PENDING";
+ break;
case SERVICE_PAUSE_PENDING:
- state = "PAUSE PENDING";
- break;
+ state = "PAUSE PENDING";
+ break;
case SERVICE_PAUSED:
- state = "PAUSED";
- break;
+ state = "PAUSED";
+ break;
default:
- state = "UNKNOWN";
- break;
+ state = "UNKNOWN";
+ break;
}
ostringstream ostr;
ostr << msg << endl
- << " Current state: " << state << endl
- << " Exit code: " << status.dwWin32ExitCode << endl
- << " Service specific exit code: " << status.dwServiceSpecificExitCode << endl
- << " Check point: " << status.dwCheckPoint << endl
- << " Wait hint: " << status.dwWaitHint;
+ << " Current state: " << state << endl
+ << " Exit code: " << status.dwWin32ExitCode << endl
+ << " Service specific exit code: " << status.dwServiceSpecificExitCode << endl
+ << " Check point: " << status.dwCheckPoint << endl
+ << " Wait hint: " << status.dwWaitHint;
trace(ostr.str());
}
@@ -1314,14 +1314,14 @@ Ice::Service::serviceMain(int argc, char* argv[])
ostringstream ostr;
ostr << "exception occurred while initializing a communicator:\n" << ex;
error(ostr.str());
- terminateService(EXIT_FAILURE);
+ terminateService(EXIT_FAILURE);
return;
}
catch(...)
{
delete[] args;
error("unknown exception occurred while initializing a communicator");
- terminateService(EXIT_FAILURE);
+ terminateService(EXIT_FAILURE);
return;
}
@@ -1345,8 +1345,8 @@ Ice::Service::serviceMain(int argc, char* argv[])
//
// Change the current status from START_PENDING to RUNNING.
//
- serviceStatusManager->stopUpdate();
- serviceStatusManager->changeStatus(SERVICE_RUNNING, SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN);
+ serviceStatusManager->stopUpdate();
+ serviceStatusManager->changeStatus(SERVICE_RUNNING, SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN);
//
// Wait for the service to be shut down.
@@ -1396,21 +1396,21 @@ Ice::Service::control(int ctrl)
case SERVICE_CONTROL_SHUTDOWN:
case SERVICE_CONTROL_STOP:
{
- serviceStatusManager->startUpdate(SERVICE_STOP_PENDING);
- shutdown();
- break;
+ serviceStatusManager->startUpdate(SERVICE_STOP_PENDING);
+ shutdown();
+ break;
}
default:
{
- if(ctrl != SERVICE_CONTROL_INTERROGATE)
- {
- ostringstream ostr;
- ostr << "unrecognized service control code " << ctrl;
- error(ostr.str());
- }
+ if(ctrl != SERVICE_CONTROL_INTERROGATE)
+ {
+ ostringstream ostr;
+ ostr << "unrecognized service control code " << ctrl;
+ error(ostr.str());
+ }
- serviceStatusManager->reportStatus();
- break;
+ serviceStatusManager->reportStatus();
+ break;
}
}
}
@@ -1449,20 +1449,20 @@ Ice::ServiceStatusManager::stopUpdate()
IceUtil::ThreadPtr thread;
{
- Lock sync(*this);
+ Lock sync(*this);
- if(_thread)
- {
- _stopped = true;
- notify();
- thread = _thread;
- _thread = 0;
- }
+ if(_thread)
+ {
+ _stopped = true;
+ notify();
+ thread = _thread;
+ _thread = 0;
+ }
}
if(thread)
{
- thread->getThreadControl().join();
+ thread->getThreadControl().join();
}
}
@@ -1581,11 +1581,11 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa
break;
}
cerr << argv[0] << ": failure occurred in daemon";
- if(strlen(msg) > 0)
- {
- cerr << ':' << endl << msg;
- }
- cerr << endl;
+ if(strlen(msg) > 0)
+ {
+ cerr << ':' << endl << msg;
+ }
+ cerr << endl;
_exit(EXIT_FAILURE);
}
@@ -1644,7 +1644,7 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa
}
}
- vector<int> fdsToClose;
+ vector<int> fdsToClose;
if(_closeFiles)
{
//
@@ -1665,13 +1665,13 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa
{
if(fcntl(i, F_GETFL) != -1)
{
- //
- // Don't close the write end of the pipe.
- //
- if(i != fds[1])
- {
- fdsToClose.push_back(i);
- }
+ //
+ // Don't close the write end of the pipe.
+ //
+ if(i != fds[1])
+ {
+ fdsToClose.push_back(i);
+ }
}
}
}
@@ -1694,21 +1694,21 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa
{
//
// Close unnecessary file descriptors.
- //
- PropertiesPtr properties = _communicator->getProperties();
- string stdOut = properties->getProperty("Ice.StdOut");
- string stdErr = properties->getProperty("Ice.StdErr");
+ //
+ PropertiesPtr properties = _communicator->getProperties();
+ string stdOut = properties->getProperty("Ice.StdOut");
+ string stdErr = properties->getProperty("Ice.StdErr");
- vector<int>::const_iterator p;
- for(p = fdsToClose.begin(); p != fdsToClose.end(); ++p)
+ vector<int>::const_iterator p;
+ for(p = fdsToClose.begin(); p != fdsToClose.end(); ++p)
{
- //
- // NOTE: Do not close stdout if Ice.StdOut is defined. Likewise for Ice.StdErr.
- //
- if((*p == 1 && !stdOut.empty()) || (*p == 2 && !stdErr.empty()))
- {
- continue;
- }
+ //
+ // NOTE: Do not close stdout if Ice.StdOut is defined. Likewise for Ice.StdErr.
+ //
+ if((*p == 1 && !stdOut.empty()) || (*p == 2 && !stdErr.empty()))
+ {
+ continue;
+ }
close(*p);
}
@@ -1718,31 +1718,31 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa
int fd;
fd = open("/dev/null", O_RDWR);
assert(fd == 0);
- if(stdOut.empty())
- {
- fd = dup2(0, 1);
- assert(fd == 1);
- }
- if(stdErr.empty())
- {
- fd = dup2(1, 2);
- assert(fd == 2);
- }
+ if(stdOut.empty())
+ {
+ fd = dup2(0, 1);
+ assert(fd == 1);
+ }
+ if(stdErr.empty())
+ {
+ fd = dup2(1, 2);
+ assert(fd == 2);
+ }
+ }
+
+ //
+ // Write PID
+ //
+ if(_pidFile.size() > 0)
+ {
+ ofstream of(_pidFile.c_str());
+ of << getpid() << endl;
+
+ if(!of)
+ {
+ warning("Could not write PID file " + _pidFile);
+ }
}
-
- //
- // Write PID
- //
- if(_pidFile.size() > 0)
- {
- ofstream of(_pidFile.c_str());
- of << getpid() << endl;
-
- if(!of)
- {
- warning("Could not write PID file " + _pidFile);
- }
- }
//
// Use the configured logger.
diff --git a/cpp/src/Ice/SharedContext.h b/cpp/src/Ice/SharedContext.h
index c44858ffb34..1d551f9d406 100644
--- a/cpp/src/Ice/SharedContext.h
+++ b/cpp/src/Ice/SharedContext.h
@@ -32,13 +32,13 @@ public:
}
SharedContext(const Ice::Context& val) :
- _val(val)
+ _val(val)
{
}
inline const Ice::Context& getValue()
{
- return _val;
+ return _val;
}
private:
diff --git a/cpp/src/Ice/SliceChecksums.cpp b/cpp/src/Ice/SliceChecksums.cpp
index eb44bfa5946..98390369e18 100644
--- a/cpp/src/Ice/SliceChecksums.cpp
+++ b/cpp/src/Ice/SliceChecksums.cpp
@@ -22,8 +22,8 @@ public:
~SliceChecksumDictDestroyer()
{
- delete _sliceChecksums;
- _sliceChecksums = 0;
+ delete _sliceChecksums;
+ _sliceChecksums = 0;
}
};
static SliceChecksumDictDestroyer destroyer;
@@ -34,7 +34,7 @@ Ice::sliceChecksums()
IceUtil::StaticMutex::Lock lock(_mutex);
if(_sliceChecksums == 0)
{
- _sliceChecksums = new SliceChecksumDict();
+ _sliceChecksums = new SliceChecksumDict();
}
return *_sliceChecksums;
}
@@ -44,7 +44,7 @@ IceInternal::SliceChecksumInit::SliceChecksumInit(const char* checksums[])
IceUtil::StaticMutex::Lock lock(_mutex);
if(_sliceChecksums == 0)
{
- _sliceChecksums = new SliceChecksumDict();
+ _sliceChecksums = new SliceChecksumDict();
}
for(int i = 0; checksums[i] != 0; i += 2)
diff --git a/cpp/src/Ice/StringConverter.cpp b/cpp/src/Ice/StringConverter.cpp
index 566bfac4abb..985111f9aa9 100755
--- a/cpp/src/Ice/StringConverter.cpp
+++ b/cpp/src/Ice/StringConverter.cpp
@@ -19,8 +19,8 @@ namespace Ice
Byte*
UnicodeWstringConverter::toUTF8(const wchar_t* sourceStart,
- const wchar_t* sourceEnd,
- UTF8Buffer& buffer) const
+ const wchar_t* sourceEnd,
+ UTF8Buffer& buffer) const
{
//
// The "chunk size" is the maximum of the number of characters in the
@@ -34,27 +34,27 @@ UnicodeWstringConverter::toUTF8(const wchar_t* sourceStart,
ConversionResult result;
while((result =
- convertUTFWstringToUTF8(sourceStart, sourceEnd,
- targetStart, targetEnd, lenientConversion))
- == targetExhausted)
+ convertUTFWstringToUTF8(sourceStart, sourceEnd,
+ targetStart, targetEnd, lenientConversion))
+ == targetExhausted)
{
- targetStart = buffer.getMoreBytes(chunkSize, targetStart);
- targetEnd = targetStart + chunkSize;
+ targetStart = buffer.getMoreBytes(chunkSize, targetStart);
+ targetEnd = targetStart + chunkSize;
}
-
+
switch(result)
{
- case conversionOK:
- break;
- case sourceExhausted:
- throw StringConversionException(__FILE__, __LINE__, "wide string source exhausted");
- case sourceIllegal:
- throw StringConversionException(__FILE__, __LINE__, "wide string source illegal");
- default:
- {
- assert(0);
- throw StringConversionException(__FILE__, __LINE__);
- }
+ case conversionOK:
+ break;
+ case sourceExhausted:
+ throw StringConversionException(__FILE__, __LINE__, "wide string source exhausted");
+ case sourceIllegal:
+ throw StringConversionException(__FILE__, __LINE__, "wide string source illegal");
+ default:
+ {
+ assert(0);
+ throw StringConversionException(__FILE__, __LINE__);
+ }
}
return targetStart;
}
@@ -62,24 +62,24 @@ UnicodeWstringConverter::toUTF8(const wchar_t* sourceStart,
void
UnicodeWstringConverter::fromUTF8(const Byte* sourceStart, const Byte* sourceEnd,
- wstring& target) const
+ wstring& target) const
{
ConversionResult result =
- convertUTF8ToUTFWstring(sourceStart, sourceEnd, target, lenientConversion);
+ convertUTF8ToUTFWstring(sourceStart, sourceEnd, target, lenientConversion);
switch(result)
- {
- case conversionOK:
- break;
- case sourceExhausted:
- throw StringConversionException(__FILE__, __LINE__, "UTF-8 string source exhausted");
- case sourceIllegal:
- throw StringConversionException(__FILE__, __LINE__, "UTF-8 string source illegal");
- default:
- {
- assert(0);
- throw StringConversionException(__FILE__, __LINE__);
- }
+ {
+ case conversionOK:
+ break;
+ case sourceExhausted:
+ throw StringConversionException(__FILE__, __LINE__, "UTF-8 string source exhausted");
+ case sourceIllegal:
+ throw StringConversionException(__FILE__, __LINE__, "UTF-8 string source illegal");
+ default:
+ {
+ assert(0);
+ throw StringConversionException(__FILE__, __LINE__);
+ }
}
}
}
diff --git a/cpp/src/Ice/TcpAcceptor.cpp b/cpp/src/Ice/TcpAcceptor.cpp
index 3a933042bbd..193aefe8175 100644
--- a/cpp/src/Ice/TcpAcceptor.cpp
+++ b/cpp/src/Ice/TcpAcceptor.cpp
@@ -30,8 +30,8 @@ IceInternal::TcpAcceptor::close()
{
if(_traceLevels->network >= 1)
{
- Trace out(_logger, _traceLevels->networkCat);
- out << "stopping to accept tcp connections at " << toString();
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "stopping to accept tcp connections at " << toString();
}
SOCKET fd = _fd;
@@ -44,18 +44,18 @@ IceInternal::TcpAcceptor::listen()
{
try
{
- doListen(_fd, _backlog);
+ doListen(_fd, _backlog);
}
catch(...)
{
- _fd = INVALID_SOCKET;
- throw;
+ _fd = INVALID_SOCKET;
+ throw;
}
if(_traceLevels->network >= 1)
{
- Trace out(_logger, _traceLevels->networkCat);
- out << "accepting tcp connections at " << toString();
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "accepting tcp connections at " << toString();
}
}
@@ -67,8 +67,8 @@ IceInternal::TcpAcceptor::accept(int timeout)
if(_traceLevels->network >= 1)
{
- Trace out(_logger, _traceLevels->networkCat);
- out << "accepted tcp connection\n" << fdToString(fd);
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "accepted tcp connection\n" << fdToString(fd);
}
return new TcpTransceiver(_instance, fd);
@@ -116,20 +116,20 @@ IceInternal::TcpAcceptor::TcpAcceptor(const InstancePtr& instance, const string&
try
{
- _fd = createSocket(false);
- setBlock(_fd, false);
- getAddress(host, port, _addr);
- if(_traceLevels->network >= 2)
- {
- Trace out(_logger, _traceLevels->networkCat);
- out << "attempting to bind to tcp socket " << toString();
- }
- doBind(_fd, _addr);
+ _fd = createSocket(false);
+ setBlock(_fd, false);
+ getAddress(host, port, _addr);
+ if(_traceLevels->network >= 2)
+ {
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "attempting to bind to tcp socket " << toString();
+ }
+ doBind(_fd, _addr);
}
catch(...)
{
- _fd = INVALID_SOCKET;
- throw;
+ _fd = INVALID_SOCKET;
+ throw;
}
}
diff --git a/cpp/src/Ice/TcpConnector.cpp b/cpp/src/Ice/TcpConnector.cpp
index 22ca94ab15d..935aaa9a84a 100644
--- a/cpp/src/Ice/TcpConnector.cpp
+++ b/cpp/src/Ice/TcpConnector.cpp
@@ -24,8 +24,8 @@ IceInternal::TcpConnector::connect(int timeout)
{
if(_traceLevels->network >= 2)
{
- Trace out(_logger, _traceLevels->networkCat);
- out << "trying to establish tcp connection to " << toString();
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "trying to establish tcp connection to " << toString();
}
SOCKET fd = createSocket(false);
@@ -34,8 +34,8 @@ IceInternal::TcpConnector::connect(int timeout)
if(_traceLevels->network >= 1)
{
- Trace out(_logger, _traceLevels->networkCat);
- out << "tcp connection established\n" << fdToString(fd);
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "tcp connection established\n" << fdToString(fd);
}
return new TcpTransceiver(_instance, fd);
diff --git a/cpp/src/Ice/TcpEndpointI.cpp b/cpp/src/Ice/TcpEndpointI.cpp
index 817008a0141..6cf54872826 100644
--- a/cpp/src/Ice/TcpEndpointI.cpp
+++ b/cpp/src/Ice/TcpEndpointI.cpp
@@ -22,7 +22,7 @@ using namespace Ice;
using namespace IceInternal;
IceInternal::TcpEndpointI::TcpEndpointI(const InstancePtr& instance, const string& ho, Int po, Int ti,
- const string& conId, bool co, bool pub) :
+ const string& conId, bool co, bool pub) :
_instance(instance),
_host(ho),
_port(po),
@@ -47,96 +47,96 @@ IceInternal::TcpEndpointI::TcpEndpointI(const InstancePtr& instance, const strin
while(true)
{
- beg = str.find_first_not_of(delim, end);
- if(beg == string::npos)
- {
- break;
- }
-
- end = str.find_first_of(delim, beg);
- if(end == string::npos)
- {
- end = str.length();
- }
-
- string option = str.substr(beg, end - beg);
- if(option.length() != 2 || option[0] != '-')
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "tcp " + str;
- throw ex;
- }
-
- string argument;
- string::size_type argumentBeg = str.find_first_not_of(delim, end);
- if(argumentBeg != string::npos && str[argumentBeg] != '-')
- {
- beg = argumentBeg;
- end = str.find_first_of(delim, beg);
- if(end == string::npos)
- {
- end = str.length();
- }
- argument = str.substr(beg, end - beg);
- }
-
- switch(option[1])
- {
- case 'h':
- {
- if(argument.empty())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "tcp " + str;
- throw ex;
- }
- const_cast<string&>(_host) = argument;
- break;
- }
-
- case 'p':
- {
- istringstream p(argument);
- if(!(p >> const_cast<Int&>(_port)) || !p.eof() || _port < 0 || _port > 65535)
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "tcp " + str;
- throw ex;
- }
- break;
- }
-
- case 't':
- {
- istringstream t(argument);
- if(!(t >> const_cast<Int&>(_timeout)) || !t.eof())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "tcp " + str;
- throw ex;
- }
- break;
- }
-
- case 'z':
- {
- if(!argument.empty())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "tcp " + str;
- throw ex;
- }
- const_cast<bool&>(_compress) = true;
- break;
- }
-
- default:
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "tcp " + str;
- throw ex;
- }
- }
+ beg = str.find_first_not_of(delim, end);
+ if(beg == string::npos)
+ {
+ break;
+ }
+
+ end = str.find_first_of(delim, beg);
+ if(end == string::npos)
+ {
+ end = str.length();
+ }
+
+ string option = str.substr(beg, end - beg);
+ if(option.length() != 2 || option[0] != '-')
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "tcp " + str;
+ throw ex;
+ }
+
+ string argument;
+ string::size_type argumentBeg = str.find_first_not_of(delim, end);
+ if(argumentBeg != string::npos && str[argumentBeg] != '-')
+ {
+ beg = argumentBeg;
+ end = str.find_first_of(delim, beg);
+ if(end == string::npos)
+ {
+ end = str.length();
+ }
+ argument = str.substr(beg, end - beg);
+ }
+
+ switch(option[1])
+ {
+ case 'h':
+ {
+ if(argument.empty())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "tcp " + str;
+ throw ex;
+ }
+ const_cast<string&>(_host) = argument;
+ break;
+ }
+
+ case 'p':
+ {
+ istringstream p(argument);
+ if(!(p >> const_cast<Int&>(_port)) || !p.eof() || _port < 0 || _port > 65535)
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "tcp " + str;
+ throw ex;
+ }
+ break;
+ }
+
+ case 't':
+ {
+ istringstream t(argument);
+ if(!(t >> const_cast<Int&>(_timeout)) || !t.eof())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "tcp " + str;
+ throw ex;
+ }
+ break;
+ }
+
+ case 'z':
+ {
+ if(!argument.empty())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "tcp " + str;
+ throw ex;
+ }
+ const_cast<bool&>(_compress) = true;
+ break;
+ }
+
+ default:
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "tcp " + str;
+ throw ex;
+ }
+ }
}
}
@@ -181,11 +181,11 @@ IceInternal::TcpEndpointI::toString() const
s << "tcp -h " << _host << " -p " << _port;
if(_timeout != -1)
{
- s << " -t " << _timeout;
+ s << " -t " << _timeout;
}
if(_compress)
{
- s << " -z";
+ s << " -z";
}
return s.str();
}
@@ -207,11 +207,11 @@ IceInternal::TcpEndpointI::timeout(Int timeout) const
{
if(timeout == _timeout)
{
- return const_cast<TcpEndpointI*>(this);
+ return const_cast<TcpEndpointI*>(this);
}
else
{
- return new TcpEndpointI(_instance, _host, _port, timeout, _connectionId, _compress, _publish);
+ return new TcpEndpointI(_instance, _host, _port, timeout, _connectionId, _compress, _publish);
}
}
@@ -220,11 +220,11 @@ IceInternal::TcpEndpointI::connectionId(const string& connectionId) const
{
if(connectionId == _connectionId)
{
- return const_cast<TcpEndpointI*>(this);
+ return const_cast<TcpEndpointI*>(this);
}
else
{
- return new TcpEndpointI(_instance, _host, _port, _timeout, connectionId, _compress, _publish);
+ return new TcpEndpointI(_instance, _host, _port, _timeout, connectionId, _compress, _publish);
}
}
@@ -239,11 +239,11 @@ IceInternal::TcpEndpointI::compress(bool compress) const
{
if(compress == _compress)
{
- return const_cast<TcpEndpointI*>(this);
+ return const_cast<TcpEndpointI*>(this);
}
else
{
- return new TcpEndpointI(_instance, _host, _port, _timeout, _connectionId, compress, _publish);
+ return new TcpEndpointI(_instance, _host, _port, _timeout, _connectionId, compress, _publish);
}
}
@@ -297,18 +297,18 @@ IceInternal::TcpEndpointI::expand(bool server) const
{
if(_host.empty())
{
- const_cast<string&>(_host) = _instance->defaultsAndOverrides()->defaultHost;
- if(_host.empty())
- {
- if(server)
- {
- const_cast<string&>(_host) = "0.0.0.0";
- }
- else
- {
- const_cast<string&>(_host) = "127.0.0.1";
- }
- }
+ const_cast<string&>(_host) = _instance->defaultsAndOverrides()->defaultHost;
+ if(_host.empty())
+ {
+ if(server)
+ {
+ const_cast<string&>(_host) = "0.0.0.0";
+ }
+ else
+ {
+ const_cast<string&>(_host) = "127.0.0.1";
+ }
+ }
}
else if(_host == "*")
{
@@ -319,11 +319,11 @@ IceInternal::TcpEndpointI::expand(bool server) const
if(_host == "0.0.0.0")
{
vector<string> hosts = getLocalHosts();
- for(unsigned int i = 0; i < hosts.size(); ++i)
- {
- endps.push_back(new TcpEndpointI(_instance, hosts[i], _port, _timeout, _connectionId, _compress,
- hosts.size() == 1 || hosts[i] != "127.0.0.1"));
- }
+ for(unsigned int i = 0; i < hosts.size(); ++i)
+ {
+ endps.push_back(new TcpEndpointI(_instance, hosts[i], _port, _timeout, _connectionId, _compress,
+ hosts.size() == 1 || hosts[i] != "127.0.0.1"));
+ }
}
else
{
@@ -350,7 +350,7 @@ IceInternal::TcpEndpointI::equivalent(const AcceptorPtr& acceptor) const
const TcpAcceptor* tcpAcceptor = dynamic_cast<const TcpAcceptor*>(acceptor.get());
if(!tcpAcceptor)
{
- return false;
+ return false;
}
return tcpAcceptor->equivalent(_host, _port);
}
@@ -361,52 +361,52 @@ IceInternal::TcpEndpointI::operator==(const EndpointI& r) const
const TcpEndpointI* p = dynamic_cast<const TcpEndpointI*>(&r);
if(!p)
{
- return false;
+ return false;
}
if(this == p)
{
- return true;
+ return true;
}
if(_port != p->_port)
{
- return false;
+ return false;
}
if(_timeout != p->_timeout)
{
- return false;
+ return false;
}
if(_connectionId != p->_connectionId)
{
- return false;
+ return false;
}
if(_compress != p->_compress)
{
- return false;
+ return false;
}
if(_host != p->_host)
{
- //
- // We do the most time-consuming part of the comparison last.
- //
- struct sockaddr_in laddr;
- struct sockaddr_in raddr;
- try
- {
- getAddress(_host, _port, laddr);
- getAddress(p->_host, p->_port, raddr);
- }
- catch(const DNSException&)
- {
- return false;
- }
+ //
+ // We do the most time-consuming part of the comparison last.
+ //
+ struct sockaddr_in laddr;
+ struct sockaddr_in raddr;
+ try
+ {
+ getAddress(_host, _port, laddr);
+ getAddress(p->_host, p->_port, raddr);
+ }
+ catch(const DNSException&)
+ {
+ return false;
+ }
- return compareAddress(laddr, raddr);
+ return compareAddress(laddr, raddr);
}
return true;
@@ -429,76 +429,76 @@ IceInternal::TcpEndpointI::operator<(const EndpointI& r) const
if(this == p)
{
- return false;
+ return false;
}
if(_port < p->_port)
{
- return true;
+ return true;
}
else if(p->_port < _port)
{
- return false;
+ return false;
}
if(_timeout < p->_timeout)
{
- return true;
+ return true;
}
else if(p->_timeout < _timeout)
{
- return false;
+ return false;
}
if(_connectionId < p->_connectionId)
{
- return true;
+ return true;
}
else if(p->_connectionId < _connectionId)
{
- return false;
+ return false;
}
if(!_compress && p->_compress)
{
- return true;
+ return true;
}
else if(p->_compress < _compress)
{
- return false;
+ return false;
}
if(_host != p->_host)
{
- //
- // We do the most time-consuming part of the comparison last.
- //
- struct sockaddr_in laddr;
- try
- {
- getAddress(_host, _port, laddr);
- }
- catch(const DNSException&)
- {
- }
-
- struct sockaddr_in raddr;
- try
- {
- getAddress(p->_host, p->_port, raddr);
- }
- catch(const DNSException&)
- {
- }
-
- if(laddr.sin_addr.s_addr < raddr.sin_addr.s_addr)
- {
- return true;
- }
- else if(raddr.sin_addr.s_addr < laddr.sin_addr.s_addr)
- {
- return false;
- }
+ //
+ // We do the most time-consuming part of the comparison last.
+ //
+ struct sockaddr_in laddr;
+ try
+ {
+ getAddress(_host, _port, laddr);
+ }
+ catch(const DNSException&)
+ {
+ }
+
+ struct sockaddr_in raddr;
+ try
+ {
+ getAddress(p->_host, p->_port, raddr);
+ }
+ catch(const DNSException&)
+ {
+ }
+
+ if(laddr.sin_addr.s_addr < raddr.sin_addr.s_addr)
+ {
+ return true;
+ }
+ else if(raddr.sin_addr.s_addr < laddr.sin_addr.s_addr)
+ {
+ return false;
+ }
}
return false;
diff --git a/cpp/src/Ice/TcpTransceiver.cpp b/cpp/src/Ice/TcpTransceiver.cpp
index 4eb5f54fa02..541843223b7 100644
--- a/cpp/src/Ice/TcpTransceiver.cpp
+++ b/cpp/src/Ice/TcpTransceiver.cpp
@@ -32,20 +32,20 @@ IceInternal::TcpTransceiver::close()
{
if(_traceLevels->network >= 1)
{
- Trace out(_logger, _traceLevels->networkCat);
- out << "closing tcp connection\n" << toString();
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "closing tcp connection\n" << toString();
}
assert(_fd != INVALID_SOCKET);
try
{
- closeSocket(_fd);
- _fd = INVALID_SOCKET;
+ closeSocket(_fd);
+ _fd = INVALID_SOCKET;
}
catch(const SocketException&)
{
- _fd = INVALID_SOCKET;
- throw;
+ _fd = INVALID_SOCKET;
+ throw;
}
}
@@ -54,8 +54,8 @@ IceInternal::TcpTransceiver::shutdownWrite()
{
if(_traceLevels->network >= 2)
{
- Trace out(_logger, _traceLevels->networkCat);
- out << "shutting down tcp connection for writing\n" << toString();
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "shutting down tcp connection for writing\n" << toString();
}
assert(_fd != INVALID_SOCKET);
@@ -67,8 +67,8 @@ IceInternal::TcpTransceiver::shutdownReadWrite()
{
if(_traceLevels->network >= 2)
{
- Trace out(_logger, _traceLevels->networkCat);
- out << "shutting down tcp connection for reading and writing\n" << toString();
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "shutting down tcp connection for reading and writing\n" << toString();
}
assert(_fd != INVALID_SOCKET);
@@ -87,112 +87,112 @@ IceInternal::TcpTransceiver::write(Buffer& buf, int timeout)
//
if(_isPeerLocal && packetSize > 64 * 1024)
{
- packetSize = 64 * 1024;
+ packetSize = 64 * 1024;
}
#endif
while(buf.i != buf.b.end())
{
- assert(_fd != INVALID_SOCKET);
- ssize_t ret = ::send(_fd, reinterpret_cast<const char*>(&*buf.i), packetSize, 0);
-
- if(ret == 0)
- {
- ConnectionLostException ex(__FILE__, __LINE__);
- ex.error = 0;
- throw ex;
- }
-
- if(ret == SOCKET_ERROR)
- {
- if(interrupted())
- {
- continue;
- }
-
- if(noBuffers() && packetSize > 1024)
- {
- packetSize /= 2;
- continue;
- }
-
- if(wouldBlock())
- {
- repeatSelect:
-
- int rs;
- assert(_fd != INVALID_SOCKET);
+ assert(_fd != INVALID_SOCKET);
+ ssize_t ret = ::send(_fd, reinterpret_cast<const char*>(&*buf.i), packetSize, 0);
+
+ if(ret == 0)
+ {
+ ConnectionLostException ex(__FILE__, __LINE__);
+ ex.error = 0;
+ throw ex;
+ }
+
+ if(ret == SOCKET_ERROR)
+ {
+ if(interrupted())
+ {
+ continue;
+ }
+
+ if(noBuffers() && packetSize > 1024)
+ {
+ packetSize /= 2;
+ continue;
+ }
+
+ if(wouldBlock())
+ {
+ repeatSelect:
+
+ int rs;
+ assert(_fd != INVALID_SOCKET);
#ifdef _WIN32
- FD_SET(_fd, &_wFdSet);
-
- if(timeout >= 0)
- {
- struct timeval tv;
- tv.tv_sec = timeout / 1000;
- tv.tv_usec = (timeout - tv.tv_sec * 1000) * 1000;
- rs = ::select(static_cast<int>(_fd + 1), 0, &_wFdSet, 0, &tv);
- }
- else
- {
- rs = ::select(static_cast<int>(_fd + 1), 0, &_wFdSet, 0, 0);
- }
+ FD_SET(_fd, &_wFdSet);
+
+ if(timeout >= 0)
+ {
+ struct timeval tv;
+ tv.tv_sec = timeout / 1000;
+ tv.tv_usec = (timeout - tv.tv_sec * 1000) * 1000;
+ rs = ::select(static_cast<int>(_fd + 1), 0, &_wFdSet, 0, &tv);
+ }
+ else
+ {
+ rs = ::select(static_cast<int>(_fd + 1), 0, &_wFdSet, 0, 0);
+ }
#else
- struct pollfd pollFd[1];
- pollFd[0].fd = _fd;
- pollFd[0].events = POLLOUT;
- rs = ::poll(pollFd, 1, timeout);
-#endif
- if(rs == SOCKET_ERROR)
- {
- if(interrupted())
- {
- goto repeatSelect;
- }
-
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
-
- if(rs == 0)
- {
- throw TimeoutException(__FILE__, __LINE__);
- }
-
- continue;
- }
-
- if(connectionLost())
- {
- ConnectionLostException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
- else
- {
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
- }
-
- if(_traceLevels->network >= 3)
- {
- Trace out(_logger, _traceLevels->networkCat);
- out << "sent " << ret << " of " << packetSize << " bytes via tcp\n" << toString();
- }
-
- if(_stats)
- {
- _stats->bytesSent(type(), static_cast<Int>(ret));
- }
-
- buf.i += ret;
-
- if(packetSize > buf.b.end() - buf.i)
- {
- packetSize = static_cast<int>(buf.b.end() - buf.i);
- }
+ struct pollfd pollFd[1];
+ pollFd[0].fd = _fd;
+ pollFd[0].events = POLLOUT;
+ rs = ::poll(pollFd, 1, timeout);
+#endif
+ if(rs == SOCKET_ERROR)
+ {
+ if(interrupted())
+ {
+ goto repeatSelect;
+ }
+
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+
+ if(rs == 0)
+ {
+ throw TimeoutException(__FILE__, __LINE__);
+ }
+
+ continue;
+ }
+
+ if(connectionLost())
+ {
+ ConnectionLostException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+ else
+ {
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+ }
+
+ if(_traceLevels->network >= 3)
+ {
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "sent " << ret << " of " << packetSize << " bytes via tcp\n" << toString();
+ }
+
+ if(_stats)
+ {
+ _stats->bytesSent(type(), static_cast<Int>(ret));
+ }
+
+ buf.i += ret;
+
+ if(packetSize > buf.b.end() - buf.i)
+ {
+ packetSize = static_cast<int>(buf.b.end() - buf.i);
+ }
}
}
@@ -204,125 +204,125 @@ IceInternal::TcpTransceiver::read(Buffer& buf, int timeout)
while(buf.i != buf.b.end())
{
- assert(_fd != INVALID_SOCKET);
- ssize_t ret = ::recv(_fd, reinterpret_cast<char*>(&*buf.i), packetSize, 0);
-
- if(ret == 0)
- {
- //
- // If the connection is lost when reading data, we shut
- // down the write end of the socket. This helps to unblock
- // threads that are stuck in send() or select() while
- // sending data. Note: I don't really understand why
- // send() or select() sometimes don't detect a connection
- // loss. Therefore this helper to make them detect it.
- //
- //assert(_fd != INVALID_SOCKET);
- //shutdownSocketReadWrite(_fd);
-
- ConnectionLostException ex(__FILE__, __LINE__);
- ex.error = 0;
- throw ex;
- }
-
- if(ret == SOCKET_ERROR)
- {
- if(interrupted())
- {
- continue;
- }
-
- if(noBuffers() && packetSize > 1024)
- {
- packetSize /= 2;
- continue;
- }
-
- if(wouldBlock())
- {
- repeatSelect:
-
- int rs;
- assert(_fd != INVALID_SOCKET);
+ assert(_fd != INVALID_SOCKET);
+ ssize_t ret = ::recv(_fd, reinterpret_cast<char*>(&*buf.i), packetSize, 0);
+
+ if(ret == 0)
+ {
+ //
+ // If the connection is lost when reading data, we shut
+ // down the write end of the socket. This helps to unblock
+ // threads that are stuck in send() or select() while
+ // sending data. Note: I don't really understand why
+ // send() or select() sometimes don't detect a connection
+ // loss. Therefore this helper to make them detect it.
+ //
+ //assert(_fd != INVALID_SOCKET);
+ //shutdownSocketReadWrite(_fd);
+
+ ConnectionLostException ex(__FILE__, __LINE__);
+ ex.error = 0;
+ throw ex;
+ }
+
+ if(ret == SOCKET_ERROR)
+ {
+ if(interrupted())
+ {
+ continue;
+ }
+
+ if(noBuffers() && packetSize > 1024)
+ {
+ packetSize /= 2;
+ continue;
+ }
+
+ if(wouldBlock())
+ {
+ repeatSelect:
+
+ int rs;
+ assert(_fd != INVALID_SOCKET);
#ifdef _WIN32
- FD_SET(_fd, &_rFdSet);
-
- if(timeout >= 0)
- {
- struct timeval tv;
- tv.tv_sec = timeout / 1000;
- tv.tv_usec = (timeout - tv.tv_sec * 1000) * 1000;
- rs = ::select(static_cast<int>(_fd + 1), &_rFdSet, 0, 0, &tv);
- }
- else
- {
- rs = ::select(static_cast<int>(_fd + 1), &_rFdSet, 0, 0, 0);
- }
+ FD_SET(_fd, &_rFdSet);
+
+ if(timeout >= 0)
+ {
+ struct timeval tv;
+ tv.tv_sec = timeout / 1000;
+ tv.tv_usec = (timeout - tv.tv_sec * 1000) * 1000;
+ rs = ::select(static_cast<int>(_fd + 1), &_rFdSet, 0, 0, &tv);
+ }
+ else
+ {
+ rs = ::select(static_cast<int>(_fd + 1), &_rFdSet, 0, 0, 0);
+ }
#else
- struct pollfd pollFd[1];
- pollFd[0].fd = _fd;
- pollFd[0].events = POLLIN;
- rs = ::poll(pollFd, 1, timeout);
+ struct pollfd pollFd[1];
+ pollFd[0].fd = _fd;
+ pollFd[0].events = POLLIN;
+ rs = ::poll(pollFd, 1, timeout);
#endif
- if(rs == SOCKET_ERROR)
- {
- if(interrupted())
- {
- goto repeatSelect;
- }
-
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
-
- if(rs == 0)
- {
- throw TimeoutException(__FILE__, __LINE__);
- }
-
- continue;
- }
-
- if(connectionLost())
- {
- //
- // See the commment above about shutting down the
- // socket if the connection is lost while reading
- // data.
- //
- //assert(_fd != INVALID_SOCKET);
- //shutdownSocketReadWrite(_fd);
-
- ConnectionLostException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
- else
- {
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
- }
-
- if(_traceLevels->network >= 3)
- {
- Trace out(_logger, _traceLevels->networkCat);
- out << "received " << ret << " of " << packetSize << " bytes via tcp\n" << toString();
- }
-
- if(_stats)
- {
- _stats->bytesReceived(type(), static_cast<Int>(ret));
- }
-
- buf.i += ret;
-
- if(packetSize > buf.b.end() - buf.i)
- {
- packetSize = static_cast<int>(buf.b.end() - buf.i);
- }
+ if(rs == SOCKET_ERROR)
+ {
+ if(interrupted())
+ {
+ goto repeatSelect;
+ }
+
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+
+ if(rs == 0)
+ {
+ throw TimeoutException(__FILE__, __LINE__);
+ }
+
+ continue;
+ }
+
+ if(connectionLost())
+ {
+ //
+ // See the commment above about shutting down the
+ // socket if the connection is lost while reading
+ // data.
+ //
+ //assert(_fd != INVALID_SOCKET);
+ //shutdownSocketReadWrite(_fd);
+
+ ConnectionLostException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+ else
+ {
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+ }
+
+ if(_traceLevels->network >= 3)
+ {
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "received " << ret << " of " << packetSize << " bytes via tcp\n" << toString();
+ }
+
+ if(_stats)
+ {
+ _stats->bytesReceived(type(), static_cast<Int>(ret));
+ }
+
+ buf.i += ret;
+
+ if(packetSize > buf.b.end() - buf.i)
+ {
+ packetSize = static_cast<int>(buf.b.end() - buf.i);
+ }
}
}
@@ -348,7 +348,7 @@ IceInternal::TcpTransceiver::checkSendSize(const Buffer& buf, size_t messageSize
{
if(buf.b.size() > messageSizeMax)
{
- throw MemoryLimitException(__FILE__, __LINE__);
+ throw MemoryLimitException(__FILE__, __LINE__);
}
}
diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp
index 87b315b9cba..6e122f575f0 100644
--- a/cpp/src/Ice/ThreadPool.cpp
+++ b/cpp/src/Ice/ThreadPool.cpp
@@ -61,9 +61,9 @@ IceInternal::ThreadPool::ThreadPool(const InstancePtr& instance, const string& p
_epollFd = epoll_create(1);
if(_epollFd < 0)
{
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
_events.resize(1);
epoll_event event;
@@ -71,9 +71,9 @@ IceInternal::ThreadPool::ThreadPool(const InstancePtr& instance, const string& p
event.data.fd = _fdIntrRead;
if(epoll_ctl(_epollFd, EPOLL_CTL_ADD, _fdIntrRead, &event) != 0)
{
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
#else
_pollFdSet.resize(1);
@@ -90,8 +90,8 @@ IceInternal::ThreadPool::ThreadPool(const InstancePtr& instance, const string& p
if(size < 1)
{
Warning out(_instance->initializationData().logger);
- out << _prefix << ".Size < 1; Size adjusted to 1";
- size = 1;
+ out << _prefix << ".Size < 1; Size adjusted to 1";
+ size = 1;
}
int sizeMax =
@@ -99,17 +99,17 @@ IceInternal::ThreadPool::ThreadPool(const InstancePtr& instance, const string& p
if(sizeMax < size)
{
Warning out(_instance->initializationData().logger);
- out << _prefix << ".SizeMax < " << _prefix << ".Size; SizeMax adjusted to Size (" << size << ")";
- sizeMax = size;
- }
+ out << _prefix << ".SizeMax < " << _prefix << ".Size; SizeMax adjusted to Size (" << size << ")";
+ sizeMax = size;
+ }
int sizeWarn = _instance->initializationData().properties->
- getPropertyAsIntWithDefault(_prefix + ".SizeWarn", sizeMax * 80 / 100);
+ getPropertyAsIntWithDefault(_prefix + ".SizeWarn", sizeMax * 80 / 100);
if(sizeWarn > sizeMax)
{
- Warning out(_instance->initializationData().logger);
- out << _prefix << ".SizeWarn > " << _prefix << ".SizeMax; adjusted SizeWarn to SizeMax (" << sizeMax << ")";
- sizeWarn = sizeMax;
+ Warning out(_instance->initializationData().logger);
+ out << _prefix << ".SizeWarn > " << _prefix << ".SizeMax; adjusted SizeWarn to SizeMax (" << sizeMax << ")";
+ sizeWarn = sizeMax;
}
const_cast<int&>(_size) = size;
@@ -120,38 +120,38 @@ IceInternal::ThreadPool::ThreadPool(const InstancePtr& instance, const string& p
if(stackSize < 0)
{
Warning out(_instance->initializationData().logger);
- out << _prefix << ".StackSize < 0; Size adjusted to OS default";
- stackSize = 0;
+ out << _prefix << ".StackSize < 0; Size adjusted to OS default";
+ stackSize = 0;
}
const_cast<size_t&>(_stackSize) = static_cast<size_t>(stackSize);
__setNoDelete(true);
try
{
- for(int i = 0 ; i < _size ; ++i)
- {
- IceUtil::ThreadPtr thread = new EventHandlerThread(this);
- thread->start(_stackSize);
- _threads.push_back(thread);
- ++_running;
- }
+ for(int i = 0 ; i < _size ; ++i)
+ {
+ IceUtil::ThreadPtr thread = new EventHandlerThread(this);
+ thread->start(_stackSize);
+ _threads.push_back(thread);
+ ++_running;
+ }
}
catch(const IceUtil::Exception& ex)
{
- {
- Error out(_instance->initializationData().logger);
- out << "cannot create thread for `" << _prefix << "':\n" << ex;
- }
+ {
+ Error out(_instance->initializationData().logger);
+ out << "cannot create thread for `" << _prefix << "':\n" << ex;
+ }
- destroy();
- joinWithAllThreads();
- __setNoDelete(false);
- throw;
+ destroy();
+ joinWithAllThreads();
+ __setNoDelete(false);
+ throw;
}
catch(...)
{
- __setNoDelete(false);
- throw;
+ __setNoDelete(false);
+ throw;
}
__setNoDelete(false);
}
@@ -162,33 +162,33 @@ IceInternal::ThreadPool::~ThreadPool()
try
{
- closeSocket(_fdIntrWrite);
+ closeSocket(_fdIntrWrite);
}
catch(const LocalException& ex)
{
- Error out(_instance->initializationData().logger);
- out << "exception in `" << _prefix << "' while calling closeSocket():\n" << ex;
+ Error out(_instance->initializationData().logger);
+ out << "exception in `" << _prefix << "' while calling closeSocket():\n" << ex;
}
try
{
- closeSocket(_fdIntrRead);
+ closeSocket(_fdIntrRead);
}
catch(const LocalException& ex)
{
- Error out(_instance->initializationData().logger);
- out << "exception in `" << _prefix << "' while calling closeSocket():\n" << ex;
+ Error out(_instance->initializationData().logger);
+ out << "exception in `" << _prefix << "' while calling closeSocket():\n" << ex;
}
#ifdef __linux
try
{
- closeSocket(_epollFd);
+ closeSocket(_epollFd);
}
catch(const LocalException& ex)
{
- Error out(_instance->initializationData().logger);
- out << "exception in `" << _prefix << "' while calling closeSocket():\n" << ex;
+ Error out(_instance->initializationData().logger);
+ out << "exception in `" << _prefix << "' while calling closeSocket():\n" << ex;
}
#endif
}
@@ -214,15 +214,15 @@ IceInternal::ThreadPool::incFdsInUse()
assert(!_destroyed);
if(_fdsInUse + 1 > FD_SETSIZE)
{
- Warning warn(_instance->initializationData().logger);
- warn << "maximum number of connections exceeded";
+ Warning warn(_instance->initializationData().logger);
+ warn << "maximum number of connections exceeded";
- //
- // No appropriate errno.
- //
- SocketException ex(__FILE__, __LINE__);
- ex.error = 0;
- throw ex;
+ //
+ // No appropriate errno.
+ //
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = 0;
+ throw ex;
}
++_fdsInUse;
#endif
@@ -238,8 +238,8 @@ IceInternal::ThreadPool::decFdsInUse()
assert(!_destroyed);
if(_fdsInUse <= 1)
{
- Trace trace(_instance->initializationData().logger, "ThreadPool");
- trace << _prefix << ": about to assert";
+ Trace trace(_instance->initializationData().logger, "ThreadPool");
+ trace << _prefix << ": about to assert";
}
assert(_fdsInUse > 1); // _fdIntrRead is always in use.
--_fdsInUse;
@@ -269,41 +269,41 @@ IceInternal::ThreadPool::promoteFollower()
{
if(_sizeMax > 1)
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- assert(!_promote);
- _promote = true;
- notify();
+ assert(!_promote);
+ _promote = true;
+ notify();
- if(!_destroyed)
- {
- assert(_inUse >= 0);
- ++_inUse;
-
- if(_inUse == _sizeWarn)
- {
- Warning out(_instance->initializationData().logger);
- out << "thread pool `" << _prefix << "' is running low on threads\n"
- << "Size=" << _size << ", " << "SizeMax=" << _sizeMax << ", " << "SizeWarn=" << _sizeWarn;
- }
-
- assert(_inUse <= _running);
- if(_inUse < _sizeMax && _inUse == _running)
- {
- try
- {
- IceUtil::ThreadPtr thread = new EventHandlerThread(this);
- thread->start(_stackSize);
- _threads.push_back(thread);
- ++_running;
- }
- catch(const IceUtil::Exception& ex)
- {
- Error out(_instance->initializationData().logger);
- out << "cannot create thread for `" << _prefix << "':\n" << ex;
- }
- }
- }
+ if(!_destroyed)
+ {
+ assert(_inUse >= 0);
+ ++_inUse;
+
+ if(_inUse == _sizeWarn)
+ {
+ Warning out(_instance->initializationData().logger);
+ out << "thread pool `" << _prefix << "' is running low on threads\n"
+ << "Size=" << _size << ", " << "SizeMax=" << _sizeMax << ", " << "SizeWarn=" << _sizeWarn;
+ }
+
+ assert(_inUse <= _running);
+ if(_inUse < _sizeMax && _inUse == _running)
+ {
+ try
+ {
+ IceUtil::ThreadPtr thread = new EventHandlerThread(this);
+ thread->start(_stackSize);
+ _threads.push_back(thread);
+ ++_running;
+ }
+ catch(const IceUtil::Exception& ex)
+ {
+ Error out(_instance->initializationData().logger);
+ out << "cannot create thread for `" << _prefix << "':\n" << ex;
+ }
+ }
+ }
}
}
@@ -319,7 +319,7 @@ IceInternal::ThreadPool::joinWithAllThreads()
assert(_destroyed);
for(vector<IceUtil::ThreadPtr>::iterator p = _threads.begin(); p != _threads.end(); ++p)
{
- (*p)->getThreadControl().join();
+ (*p)->getThreadControl().join();
}
}
@@ -339,26 +339,26 @@ repeat:
#ifdef _WIN32
if(::recv(_fdIntrRead, &c, 1, 0) == SOCKET_ERROR)
{
- if(interrupted())
- {
- goto repeat;
- }
+ if(interrupted())
+ {
+ goto repeat;
+ }
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
#else
if(::read(_fdIntrRead, &c, 1) == -1)
{
- if(interrupted())
- {
- goto repeat;
- }
+ if(interrupted())
+ {
+ goto repeat;
+ }
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
}
#endif
}
@@ -373,26 +373,26 @@ repeat:
#ifdef _WIN32
if(::send(_fdIntrWrite, &c, 1, 0) == SOCKET_ERROR)
{
- if(interrupted())
- {
- goto repeat;
- }
+ if(interrupted())
+ {
+ goto repeat;
+ }
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
#else
if(::write(_fdIntrWrite, &c, 1) == -1)
{
- if(interrupted())
- {
- goto repeat;
- }
+ if(interrupted())
+ {
+ goto repeat;
+ }
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
}
#endif
}
@@ -404,467 +404,467 @@ IceInternal::ThreadPool::run()
if(_sizeMax > 1)
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- while(!_promote)
- {
- wait();
- }
+ while(!_promote)
+ {
+ wait();
+ }
- _promote = false;
+ _promote = false;
}
while(true)
{
- int ret;
+ int ret;
#if defined(_WIN32)
- fd_set fdSet;
- memcpy(&fdSet, &_fdSet, sizeof(fd_set));
- if(_timeout > 0)
- {
- struct timeval tv;
- tv.tv_sec = _timeout;
- tv.tv_usec = 0;
- ret = ::select(static_cast<int>(_maxFd + 1), &fdSet, 0, 0, &tv);
- }
- else
- {
- ret = ::select(static_cast<int>(_maxFd + 1), &fdSet, 0, 0, 0);
- }
+ fd_set fdSet;
+ memcpy(&fdSet, &_fdSet, sizeof(fd_set));
+ if(_timeout > 0)
+ {
+ struct timeval tv;
+ tv.tv_sec = _timeout;
+ tv.tv_usec = 0;
+ ret = ::select(static_cast<int>(_maxFd + 1), &fdSet, 0, 0, &tv);
+ }
+ else
+ {
+ ret = ::select(static_cast<int>(_maxFd + 1), &fdSet, 0, 0, 0);
+ }
#elif defined(__linux)
- ret = epoll_wait(_epollFd, &_events[0], _events.size(), _timeout > 0 ? _timeout * 1000 : -1);
+ ret = epoll_wait(_epollFd, &_events[0], _events.size(), _timeout > 0 ? _timeout * 1000 : -1);
#else
- ret = poll(&_pollFdSet[0], _pollFdSet.size(), _timeout > 0 ? _timeout * 1000 : -1);
+ ret = poll(&_pollFdSet[0], _pollFdSet.size(), _timeout > 0 ? _timeout * 1000 : -1);
#endif
- if(ret == SOCKET_ERROR)
- {
- if(interrupted())
- {
- continue;
- }
-
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- //throw ex;
- Error out(_instance->initializationData().logger);
- out << "exception in `" << _prefix << "':\n" << ex;
- continue;
- }
-
- EventHandlerPtr handler;
- bool finished = false;
- bool shutdown = false;
+ if(ret == SOCKET_ERROR)
+ {
+ if(interrupted())
+ {
+ continue;
+ }
+
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ //throw ex;
+ Error out(_instance->initializationData().logger);
+ out << "exception in `" << _prefix << "':\n" << ex;
+ continue;
+ }
+
+ EventHandlerPtr handler;
+ bool finished = false;
+ bool shutdown = false;
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- if(ret == 0) // We initiate a shutdown if there is a thread pool timeout.
- {
- assert(_timeout > 0);
- _timeout = 0;
- shutdown = true;
- }
- else
- {
- bool interrupted = false;
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ if(ret == 0) // We initiate a shutdown if there is a thread pool timeout.
+ {
+ assert(_timeout > 0);
+ _timeout = 0;
+ shutdown = true;
+ }
+ else
+ {
+ bool interrupted = false;
#if defined(_WIN32)
- interrupted = FD_ISSET(_fdIntrRead, &fdSet);
+ interrupted = FD_ISSET(_fdIntrRead, &fdSet);
#elif defined(__linux)
for(int i = 0; i < ret; ++i)
- {
- if(_events[i].data.fd == _fdIntrRead)
- {
- interrupted = true;
- break;
- }
- }
+ {
+ if(_events[i].data.fd == _fdIntrRead)
+ {
+ interrupted = true;
+ break;
+ }
+ }
#else
- assert(_pollFdSet[0].fd == _fdIntrRead);
+ assert(_pollFdSet[0].fd == _fdIntrRead);
interrupted = _pollFdSet[0].revents != 0;
#endif
- if(interrupted)
- {
- //
- // There are two possiblities for an interrupt:
- //
- // 1. The thread pool has been destroyed.
- //
- // 2. An event handler was registered or unregistered.
- //
+ if(interrupted)
+ {
+ //
+ // There are two possiblities for an interrupt:
+ //
+ // 1. The thread pool has been destroyed.
+ //
+ // 2. An event handler was registered or unregistered.
+ //
- //
- // Thread pool destroyed?
- //
- if(_destroyed)
- {
- //
- // Don't clear the interrupt if destroyed, so that
- // the other threads exit as well.
- //
- return true;
- }
-
- clearInterrupt();
-
- //
- // An event handler must have been registered or
- // unregistered.
- //
- assert(!_changes.empty());
- pair<SOCKET, EventHandlerPtr> change = _changes.front();
- _changes.pop_front();
-
- if(change.second) // Addition if handler is set.
- {
- _handlerMap.insert(change);
+ //
+ // Thread pool destroyed?
+ //
+ if(_destroyed)
+ {
+ //
+ // Don't clear the interrupt if destroyed, so that
+ // the other threads exit as well.
+ //
+ return true;
+ }
+
+ clearInterrupt();
+
+ //
+ // An event handler must have been registered or
+ // unregistered.
+ //
+ assert(!_changes.empty());
+ pair<SOCKET, EventHandlerPtr> change = _changes.front();
+ _changes.pop_front();
+
+ if(change.second) // Addition if handler is set.
+ {
+ _handlerMap.insert(change);
#if defined(_WIN32)
- FD_SET(change.first, &_fdSet);
+ FD_SET(change.first, &_fdSet);
#elif defined(__linux)
- epoll_event event;
- event.events = EPOLLIN;
- event.data.fd = change.first;
- if(epoll_ctl(_epollFd, EPOLL_CTL_ADD, change.first, &event) != 0)
- {
- Error out(_instance->initializationData().logger);
- out << "error while adding filedescriptor to epoll set:\n";
- out << errorToString(getSocketErrno());
- continue;
- }
- _events.resize(_handlerMap.size() + 1);
+ epoll_event event;
+ event.events = EPOLLIN;
+ event.data.fd = change.first;
+ if(epoll_ctl(_epollFd, EPOLL_CTL_ADD, change.first, &event) != 0)
+ {
+ Error out(_instance->initializationData().logger);
+ out << "error while adding filedescriptor to epoll set:\n";
+ out << errorToString(getSocketErrno());
+ continue;
+ }
+ _events.resize(_handlerMap.size() + 1);
#else
- struct pollfd pollFd;
- pollFd.fd = change.first;
- pollFd.events = POLLIN;
- _pollFdSet.push_back(pollFd);
+ struct pollfd pollFd;
+ pollFd.fd = change.first;
+ pollFd.events = POLLIN;
+ _pollFdSet.push_back(pollFd);
#endif
- _maxFd = max(_maxFd, change.first);
- _minFd = min(_minFd, change.first);
- continue;
- }
- else // Removal if handler is not set.
- {
- map<SOCKET, EventHandlerPtr>::iterator p = _handlerMap.find(change.first);
- assert(p != _handlerMap.end());
- handler = p->second;
- finished = true;
- _handlerMap.erase(p);
+ _maxFd = max(_maxFd, change.first);
+ _minFd = min(_minFd, change.first);
+ continue;
+ }
+ else // Removal if handler is not set.
+ {
+ map<SOCKET, EventHandlerPtr>::iterator p = _handlerMap.find(change.first);
+ assert(p != _handlerMap.end());
+ handler = p->second;
+ finished = true;
+ _handlerMap.erase(p);
#if defined(_WIN32)
- FD_CLR(change.first, &_fdSet);
+ FD_CLR(change.first, &_fdSet);
#elif defined(__linux)
- epoll_event event;
- event.events = 0;
- if(epoll_ctl(_epollFd, EPOLL_CTL_DEL, change.first, &event) != 0)
- {
- Error out(_instance->initializationData().logger);
- out << "error while adding filedescriptor to epoll set:\n";
- out << errorToString(getSocketErrno());
- continue;
- }
- _events.resize(_handlerMap.size() + 1);
+ epoll_event event;
+ event.events = 0;
+ if(epoll_ctl(_epollFd, EPOLL_CTL_DEL, change.first, &event) != 0)
+ {
+ Error out(_instance->initializationData().logger);
+ out << "error while adding filedescriptor to epoll set:\n";
+ out << errorToString(getSocketErrno());
+ continue;
+ }
+ _events.resize(_handlerMap.size() + 1);
#else
- for(vector<struct pollfd>::iterator p = _pollFdSet.begin(); p != _pollFdSet.end(); ++p)
- {
- if(p->fd == change.first)
- {
- _pollFdSet.erase(p);
- break;
- }
- }
+ for(vector<struct pollfd>::iterator p = _pollFdSet.begin(); p != _pollFdSet.end(); ++p)
+ {
+ if(p->fd == change.first)
+ {
+ _pollFdSet.erase(p);
+ break;
+ }
+ }
#endif
- _maxFd = _fdIntrRead;
- _minFd = _fdIntrRead;
- if(!_handlerMap.empty())
- {
- _maxFd = max(_maxFd, (--_handlerMap.end())->first);
- _minFd = min(_minFd, _handlerMap.begin()->first);
- }
- // Don't continue; we have to call
- // finished() on the event handler below, outside
- // the thread synchronization.
- }
- }
- else
- {
- //
- // Round robin for the filedescriptors.
- //
- SOCKET largerFd = _maxFd + 1;
- SOCKET smallestFd = _maxFd + 1;
+ _maxFd = _fdIntrRead;
+ _minFd = _fdIntrRead;
+ if(!_handlerMap.empty())
+ {
+ _maxFd = max(_maxFd, (--_handlerMap.end())->first);
+ _minFd = min(_minFd, _handlerMap.begin()->first);
+ }
+ // Don't continue; we have to call
+ // finished() on the event handler below, outside
+ // the thread synchronization.
+ }
+ }
+ else
+ {
+ //
+ // Round robin for the filedescriptors.
+ //
+ SOCKET largerFd = _maxFd + 1;
+ SOCKET smallestFd = _maxFd + 1;
#if defined(_WIN32)
- if(fdSet.fd_count == 0)
- {
- Error out(_instance->initializationData().logger);
- out << "select() in `" << _prefix << "' returned " << ret
- << " but no filedescriptor is readable";
- continue;
- }
- for(u_short i = 0; i < fdSet.fd_count; ++i)
- {
- SOCKET fd = fdSet.fd_array[i];
+ if(fdSet.fd_count == 0)
+ {
+ Error out(_instance->initializationData().logger);
+ out << "select() in `" << _prefix << "' returned " << ret
+ << " but no filedescriptor is readable";
+ continue;
+ }
+ for(u_short i = 0; i < fdSet.fd_count; ++i)
+ {
+ SOCKET fd = fdSet.fd_array[i];
#elif defined(__linux)
- for(int i = 0; i < ret; ++i)
- {
- SOCKET fd = _events[i].data.fd;
+ for(int i = 0; i < ret; ++i)
+ {
+ SOCKET fd = _events[i].data.fd;
#else
for(vector<struct pollfd>::const_iterator p = _pollFdSet.begin(); p != _pollFdSet.end(); ++p)
- {
- if(p->revents == 0)
- {
- continue;
- }
- SOCKET fd = p->fd;
+ {
+ if(p->revents == 0)
+ {
+ continue;
+ }
+ SOCKET fd = p->fd;
#endif
- assert(fd != INVALID_SOCKET);
- if(fd > _lastFd || _lastFd == INVALID_SOCKET)
- {
- largerFd = min(largerFd, fd);
- }
-
- smallestFd = min(smallestFd, fd);
- }
-
- if(largerFd <= _maxFd)
- {
- assert(largerFd >= _minFd);
- _lastFd = largerFd;
- }
- else
- {
- assert(smallestFd >= _minFd && smallestFd <= _maxFd);
- _lastFd = smallestFd;
- }
- assert(_lastFd != _fdIntrRead);
- map<SOCKET, EventHandlerPtr>::iterator p = _handlerMap.find(_lastFd);
- if(p == _handlerMap.end())
- {
- Error out(_instance->initializationData().logger);
- out << "filedescriptor " << _lastFd << " not registered with `" << _prefix << "'";
- continue;
- }
-
- handler = p->second;
- }
- }
- }
-
- //
- // Now we are outside the thread synchronization.
- //
+ assert(fd != INVALID_SOCKET);
+ if(fd > _lastFd || _lastFd == INVALID_SOCKET)
+ {
+ largerFd = min(largerFd, fd);
+ }
+
+ smallestFd = min(smallestFd, fd);
+ }
+
+ if(largerFd <= _maxFd)
+ {
+ assert(largerFd >= _minFd);
+ _lastFd = largerFd;
+ }
+ else
+ {
+ assert(smallestFd >= _minFd && smallestFd <= _maxFd);
+ _lastFd = smallestFd;
+ }
+ assert(_lastFd != _fdIntrRead);
+ map<SOCKET, EventHandlerPtr>::iterator p = _handlerMap.find(_lastFd);
+ if(p == _handlerMap.end())
+ {
+ Error out(_instance->initializationData().logger);
+ out << "filedescriptor " << _lastFd << " not registered with `" << _prefix << "'";
+ continue;
+ }
+
+ handler = p->second;
+ }
+ }
+ }
+
+ //
+ // Now we are outside the thread synchronization.
+ //
- if(shutdown)
- {
- //
- // Initiate server shutdown.
- //
- ObjectAdapterFactoryPtr factory;
- try
- {
- factory = _instance->objectAdapterFactory();
- }
- catch(const Ice::CommunicatorDestroyedException&)
- {
- continue;
- }
+ if(shutdown)
+ {
+ //
+ // Initiate server shutdown.
+ //
+ ObjectAdapterFactoryPtr factory;
+ try
+ {
+ factory = _instance->objectAdapterFactory();
+ }
+ catch(const Ice::CommunicatorDestroyedException&)
+ {
+ continue;
+ }
- promoteFollower();
- factory->shutdown();
+ promoteFollower();
+ factory->shutdown();
- //
- // No "continue", because we want shutdown to be done in
- // its own thread from this pool. Therefore we called
- // promoteFollower().
- //
- }
- else
- {
- assert(handler);
-
- if(finished)
- {
- //
- // Notify a handler about it's removal from the thread
- // pool.
- //
- try
- {
- //
- // "self" is faster than "this", as the reference
- // count is not modified.
- //
- handler->finished(self);
- }
- catch(const LocalException& ex)
- {
- Error out(_instance->initializationData().logger);
- out << "exception in `" << _prefix << "' while calling finished():\n"
- << ex << '\n' << handler->toString();
- }
+ //
+ // No "continue", because we want shutdown to be done in
+ // its own thread from this pool. Therefore we called
+ // promoteFollower().
+ //
+ }
+ else
+ {
+ assert(handler);
+
+ if(finished)
+ {
+ //
+ // Notify a handler about it's removal from the thread
+ // pool.
+ //
+ try
+ {
+ //
+ // "self" is faster than "this", as the reference
+ // count is not modified.
+ //
+ handler->finished(self);
+ }
+ catch(const LocalException& ex)
+ {
+ Error out(_instance->initializationData().logger);
+ out << "exception in `" << _prefix << "' while calling finished():\n"
+ << ex << '\n' << handler->toString();
+ }
- //
- // No "continue", because we want finished() to be
- // called in its own thread from this pool. Note that
- // this means that finished() must call
- // promoteFollower().
- //
- }
- else
- {
- //
- // If the handler is "readable", try to read a
- // message.
- //
- BasicStream stream(_instance.get());
- if(handler->readable())
- {
- try
- {
- read(handler);
- }
- catch(const TimeoutException&) // Expected.
- {
- continue;
- }
- catch(const DatagramLimitException&) // Expected.
- {
- continue;
- }
- catch(const SocketException& ex)
- {
- handler->exception(ex);
- continue;
- }
- catch(const LocalException& ex)
- {
- if(handler->datagram())
- {
- if(_instance->initializationData().properties->
- getPropertyAsInt("Ice.Warn.Connections") > 0)
- {
- Warning out(_instance->initializationData().logger);
- out << "datagram connection exception:\n" << ex << '\n' << handler->toString();
- }
- }
- else
- {
- handler->exception(ex);
- }
- continue;
- }
-
- stream.swap(handler->_stream);
- assert(stream.i == stream.b.end());
- }
-
- //
- // Provide a new mesage to the handler.
- //
- try
- {
- //
- // "self" is faster than "this", as the reference
- // count is not modified.
- //
- handler->message(stream, self);
- }
- catch(const LocalException& ex)
- {
- Error out(_instance->initializationData().logger);
- out << "exception in `" << _prefix << "' while calling message():\n"
- << ex << '\n' << handler->toString();
- }
-
- //
- // No "continue", because we want message() to be
- // called in its own thread from this pool. Note that
- // this means that message() must call
- // promoteFollower().
- //
- }
- }
+ //
+ // No "continue", because we want finished() to be
+ // called in its own thread from this pool. Note that
+ // this means that finished() must call
+ // promoteFollower().
+ //
+ }
+ else
+ {
+ //
+ // If the handler is "readable", try to read a
+ // message.
+ //
+ BasicStream stream(_instance.get());
+ if(handler->readable())
+ {
+ try
+ {
+ read(handler);
+ }
+ catch(const TimeoutException&) // Expected.
+ {
+ continue;
+ }
+ catch(const DatagramLimitException&) // Expected.
+ {
+ continue;
+ }
+ catch(const SocketException& ex)
+ {
+ handler->exception(ex);
+ continue;
+ }
+ catch(const LocalException& ex)
+ {
+ if(handler->datagram())
+ {
+ if(_instance->initializationData().properties->
+ getPropertyAsInt("Ice.Warn.Connections") > 0)
+ {
+ Warning out(_instance->initializationData().logger);
+ out << "datagram connection exception:\n" << ex << '\n' << handler->toString();
+ }
+ }
+ else
+ {
+ handler->exception(ex);
+ }
+ continue;
+ }
+
+ stream.swap(handler->_stream);
+ assert(stream.i == stream.b.end());
+ }
+
+ //
+ // Provide a new mesage to the handler.
+ //
+ try
+ {
+ //
+ // "self" is faster than "this", as the reference
+ // count is not modified.
+ //
+ handler->message(stream, self);
+ }
+ catch(const LocalException& ex)
+ {
+ Error out(_instance->initializationData().logger);
+ out << "exception in `" << _prefix << "' while calling message():\n"
+ << ex << '\n' << handler->toString();
+ }
+
+ //
+ // No "continue", because we want message() to be
+ // called in its own thread from this pool. Note that
+ // this means that message() must call
+ // promoteFollower().
+ //
+ }
+ }
- if(_sizeMax > 1)
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- if(!_destroyed)
- {
- //
- // First we reap threads that have been destroyed before.
- //
- int sz = static_cast<int>(_threads.size());
- assert(_running <= sz);
- if(_running < sz)
- {
- vector<IceUtil::ThreadPtr>::iterator start =
- partition(_threads.begin(), _threads.end(), IceUtil::constMemFun(&IceUtil::Thread::isAlive));
+ if(_sizeMax > 1)
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ if(!_destroyed)
+ {
+ //
+ // First we reap threads that have been destroyed before.
+ //
+ int sz = static_cast<int>(_threads.size());
+ assert(_running <= sz);
+ if(_running < sz)
+ {
+ vector<IceUtil::ThreadPtr>::iterator start =
+ partition(_threads.begin(), _threads.end(), IceUtil::constMemFun(&IceUtil::Thread::isAlive));
- for(vector<IceUtil::ThreadPtr>::iterator p = start; p != _threads.end(); ++p)
- {
- (*p)->getThreadControl().join();
- }
+ for(vector<IceUtil::ThreadPtr>::iterator p = start; p != _threads.end(); ++p)
+ {
+ (*p)->getThreadControl().join();
+ }
- _threads.erase(start, _threads.end());
- }
-
- //
- // Now we check if this thread can be destroyed, based
- // on a load factor.
- //
+ _threads.erase(start, _threads.end());
+ }
+
+ //
+ // Now we check if this thread can be destroyed, based
+ // on a load factor.
+ //
- //
- // The load factor jumps immediately to the number of
- // threads that are currently in use, but decays
- // exponentially if the number of threads in use is
- // smaller than the load factor. This reflects that we
- // create threads immediately when they are needed,
- // but want the number of threads to slowly decline to
- // the configured minimum.
- //
- double inUse = static_cast<double>(_inUse);
- if(_load < inUse)
- {
- _load = inUse;
- }
- else
- {
- const double loadFactor = 0.05; // TODO: Configurable?
- const double oneMinusLoadFactor = 1 - loadFactor;
- _load = _load * oneMinusLoadFactor + inUse * loadFactor;
- }
-
- if(_running > _size)
- {
- int load = static_cast<int>(_load + 0.5);
+ //
+ // The load factor jumps immediately to the number of
+ // threads that are currently in use, but decays
+ // exponentially if the number of threads in use is
+ // smaller than the load factor. This reflects that we
+ // create threads immediately when they are needed,
+ // but want the number of threads to slowly decline to
+ // the configured minimum.
+ //
+ double inUse = static_cast<double>(_inUse);
+ if(_load < inUse)
+ {
+ _load = inUse;
+ }
+ else
+ {
+ const double loadFactor = 0.05; // TODO: Configurable?
+ const double oneMinusLoadFactor = 1 - loadFactor;
+ _load = _load * oneMinusLoadFactor + inUse * loadFactor;
+ }
+
+ if(_running > _size)
+ {
+ int load = static_cast<int>(_load + 0.5);
- //
- // We add one to the load factor because on
- // additional thread is needed for select().
- //
- if(load + 1 < _running)
- {
- assert(_inUse > 0);
- --_inUse;
-
- assert(_running > 0);
- --_running;
-
- return false;
- }
- }
-
- assert(_inUse > 0);
- --_inUse;
- }
+ //
+ // We add one to the load factor because on
+ // additional thread is needed for select().
+ //
+ if(load + 1 < _running)
+ {
+ assert(_inUse > 0);
+ --_inUse;
+
+ assert(_running > 0);
+ --_running;
+
+ return false;
+ }
+ }
+
+ assert(_inUse > 0);
+ --_inUse;
+ }
- while(!_promote)
- {
- wait();
- }
-
- _promote = false;
- }
+ while(!_promote)
+ {
+ wait();
+ }
+
+ _promote = false;
+ }
}
}
@@ -875,32 +875,32 @@ IceInternal::ThreadPool::read(const EventHandlerPtr& handler)
if(stream.b.size() == 0)
{
- stream.b.resize(headerSize);
- stream.i = stream.b.begin();
+ stream.b.resize(headerSize);
+ stream.i = stream.b.begin();
}
if(stream.i != stream.b.end())
{
- handler->read(stream);
- assert(stream.i == stream.b.end());
+ handler->read(stream);
+ assert(stream.i == stream.b.end());
}
ptrdiff_t pos = stream.i - stream.b.begin();
if(pos < headerSize)
{
- //
- // This situation is possible for small UDP packets.
- //
- throw IllegalMessageSizeException(__FILE__, __LINE__);
+ //
+ // This situation is possible for small UDP packets.
+ //
+ throw IllegalMessageSizeException(__FILE__, __LINE__);
}
stream.i = stream.b.begin();
const Byte* m;
stream.readBlob(m, static_cast<Int>(sizeof(magic)));
if(m[0] != magic[0] || m[1] != magic[1] || m[2] != magic[2] || m[3] != magic[3])
{
- BadMagicException ex(__FILE__, __LINE__);
- ex.badMagic = Ice::ByteSeq(&m[0], &m[0] + sizeof(magic));
- throw ex;
+ BadMagicException ex(__FILE__, __LINE__);
+ ex.badMagic = Ice::ByteSeq(&m[0], &m[0] + sizeof(magic));
+ throw ex;
}
Byte pMajor;
Byte pMinor;
@@ -909,12 +909,12 @@ IceInternal::ThreadPool::read(const EventHandlerPtr& handler)
if(pMajor != protocolMajor
|| static_cast<unsigned char>(pMinor) > static_cast<unsigned char>(protocolMinor))
{
- UnsupportedProtocolException ex(__FILE__, __LINE__);
- ex.badMajor = static_cast<unsigned char>(pMajor);
- ex.badMinor = static_cast<unsigned char>(pMinor);
- ex.major = static_cast<unsigned char>(protocolMajor);
- ex.minor = static_cast<unsigned char>(protocolMinor);
- throw ex;
+ UnsupportedProtocolException ex(__FILE__, __LINE__);
+ ex.badMajor = static_cast<unsigned char>(pMajor);
+ ex.badMinor = static_cast<unsigned char>(pMinor);
+ ex.major = static_cast<unsigned char>(protocolMajor);
+ ex.minor = static_cast<unsigned char>(protocolMinor);
+ throw ex;
}
Byte eMajor;
Byte eMinor;
@@ -923,12 +923,12 @@ IceInternal::ThreadPool::read(const EventHandlerPtr& handler)
if(eMajor != encodingMajor
|| static_cast<unsigned char>(eMinor) > static_cast<unsigned char>(encodingMinor))
{
- UnsupportedEncodingException ex(__FILE__, __LINE__);
- ex.badMajor = static_cast<unsigned char>(eMajor);
- ex.badMinor = static_cast<unsigned char>(eMinor);
- ex.major = static_cast<unsigned char>(encodingMajor);
- ex.minor = static_cast<unsigned char>(encodingMinor);
- throw ex;
+ UnsupportedEncodingException ex(__FILE__, __LINE__);
+ ex.badMajor = static_cast<unsigned char>(eMajor);
+ ex.badMinor = static_cast<unsigned char>(eMinor);
+ ex.major = static_cast<unsigned char>(encodingMajor);
+ ex.minor = static_cast<unsigned char>(encodingMinor);
+ throw ex;
}
Byte messageType;
stream.read(messageType);
@@ -938,36 +938,36 @@ IceInternal::ThreadPool::read(const EventHandlerPtr& handler)
stream.read(size);
if(size < headerSize)
{
- throw IllegalMessageSizeException(__FILE__, __LINE__);
+ throw IllegalMessageSizeException(__FILE__, __LINE__);
}
if(size > static_cast<Int>(_instance->messageSizeMax()))
{
- throw MemoryLimitException(__FILE__, __LINE__);
+ throw MemoryLimitException(__FILE__, __LINE__);
}
if(size > static_cast<Int>(stream.b.size()))
{
- stream.b.resize(size);
+ stream.b.resize(size);
}
stream.i = stream.b.begin() + pos;
if(stream.i != stream.b.end())
{
- if(handler->datagram())
- {
- if(_warnUdp)
- {
- Warning out(_instance->initializationData().logger);
- out << "DatagramLimitException: maximum size of " << pos << " exceeded";
- stream.resize(0);
- stream.i = stream.b.begin();
- }
- throw DatagramLimitException(__FILE__, __LINE__);
- }
- else
- {
- handler->read(stream);
- assert(stream.i == stream.b.end());
- }
+ if(handler->datagram())
+ {
+ if(_warnUdp)
+ {
+ Warning out(_instance->initializationData().logger);
+ out << "DatagramLimitException: maximum size of " << pos << " exceeded";
+ stream.resize(0);
+ stream.i = stream.b.begin();
+ }
+ throw DatagramLimitException(__FILE__, __LINE__);
+ }
+ else
+ {
+ handler->read(stream);
+ assert(stream.i == stream.b.end());
+ }
}
}
@@ -988,39 +988,39 @@ IceInternal::ThreadPool::EventHandlerThread::run()
try
{
- promote = _pool->run();
+ promote = _pool->run();
}
catch(const Exception& ex)
- {
- Error out(_pool->_instance->initializationData().logger);
- out << "exception in `" << _pool->_prefix << "':\n" << ex;
- promote = true;
+ {
+ Error out(_pool->_instance->initializationData().logger);
+ out << "exception in `" << _pool->_prefix << "':\n" << ex;
+ promote = true;
}
catch(const std::exception& ex)
{
- Error out(_pool->_instance->initializationData().logger);
- out << "std::exception in `" << _pool->_prefix << "':\n" << ex.what();
- promote = true;
+ Error out(_pool->_instance->initializationData().logger);
+ out << "std::exception in `" << _pool->_prefix << "':\n" << ex.what();
+ promote = true;
}
catch(...)
{
- Error out(_pool->_instance->initializationData().logger);
- out << "unknown exception in `" << _pool->_prefix << "'";
- promote = true;
+ Error out(_pool->_instance->initializationData().logger);
+ out << "unknown exception in `" << _pool->_prefix << "'";
+ promote = true;
}
if(promote && _pool->_sizeMax > 1)
{
- //
- // Promote a follower, but w/o modifying _inUse or creating
- // new threads.
- //
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*_pool.get());
- assert(!_pool->_promote);
- _pool->_promote = true;
- _pool->notify();
- }
+ //
+ // Promote a follower, but w/o modifying _inUse or creating
+ // new threads.
+ //
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*_pool.get());
+ assert(!_pool->_promote);
+ _pool->_promote = true;
+ _pool->notify();
+ }
}
if(_pool->_instance->initializationData().threadHook)
diff --git a/cpp/src/Ice/ThreadPool.h b/cpp/src/Ice/ThreadPool.h
index a0ecc923a46..6cda824ee5e 100644
--- a/cpp/src/Ice/ThreadPool.h
+++ b/cpp/src/Ice/ThreadPool.h
@@ -94,13 +94,13 @@ private:
class EventHandlerThread : public IceUtil::Thread
{
public:
-
- EventHandlerThread(const ThreadPoolPtr&);
- virtual void run();
+
+ EventHandlerThread(const ThreadPoolPtr&);
+ virtual void run();
private:
- ThreadPoolPtr _pool;
+ ThreadPoolPtr _pool;
};
friend class EventHandlerThread;
diff --git a/cpp/src/Ice/TraceUtil.cpp b/cpp/src/Ice/TraceUtil.cpp
index 6dfc11c029c..cc89bf153ee 100644
--- a/cpp/src/Ice/TraceUtil.cpp
+++ b/cpp/src/Ice/TraceUtil.cpp
@@ -53,29 +53,29 @@ printRequestHeader(ostream& s, BasicStream& stream)
s << "\nmode = " << static_cast<int>(mode) << ' ';
switch(mode)
{
- case Normal:
- {
- s << "(normal)";
- break;
- }
-
- case Nonmutating:
- {
- s << "(nonmutating)";
- break;
- }
-
- case Idempotent:
- {
- s << "(idempotent)";
- break;
- }
-
- default:
- {
- s << "(unknown)";
- break;
- }
+ case Normal:
+ {
+ s << "(normal)";
+ break;
+ }
+
+ case Nonmutating:
+ {
+ s << "(nonmutating)";
+ break;
+ }
+
+ case Idempotent:
+ {
+ s << "(idempotent)";
+ break;
+ }
+
+ default:
+ {
+ s << "(unknown)";
+ break;
+ }
}
Int sz;
@@ -83,14 +83,14 @@ printRequestHeader(ostream& s, BasicStream& stream)
s << "\ncontext = ";
while(sz--)
{
- pair<string, string> pair;
- stream.read(pair.first);
- stream.read(pair.second);
- s << pair.first << '/' << pair.second;
- if(sz)
- {
- s << ", ";
- }
+ pair<string, string> pair;
+ stream.read(pair.first);
+ stream.read(pair.second);
+ s << pair.first << '/' << pair.second;
+ if(sz)
+ {
+ s << ", ";
+ }
}
}
@@ -98,7 +98,7 @@ static void
printHeader(ostream& s, BasicStream& stream)
{
Byte magicNumber;
- stream.read(magicNumber); // Don't bother printing the magic number
+ stream.read(magicNumber); // Don't bother printing the magic number
stream.read(magicNumber);
stream.read(magicNumber);
stream.read(magicNumber);
@@ -123,41 +123,41 @@ printHeader(ostream& s, BasicStream& stream)
switch(type)
{
- case requestMsg:
- {
- s << "(request)";
- break;
- }
-
- case requestBatchMsg:
- {
- s << "(batch request)";
- break;
- }
-
- case replyMsg:
- {
- s << "(reply)";
- break;
- }
-
- case closeConnectionMsg:
- {
- s << "(close connection)";
- break;
- }
-
- case validateConnectionMsg:
- {
- s << "(validate connection)";
- break;
- }
-
- default:
- {
- s << "(unknown)";
- break;
- }
+ case requestMsg:
+ {
+ s << "(request)";
+ break;
+ }
+
+ case requestBatchMsg:
+ {
+ s << "(batch request)";
+ break;
+ }
+
+ case replyMsg:
+ {
+ s << "(reply)";
+ break;
+ }
+
+ case closeConnectionMsg:
+ {
+ s << "(close connection)";
+ break;
+ }
+
+ case validateConnectionMsg:
+ {
+ s << "(validate connection)";
+ break;
+ }
+
+ default:
+ {
+ s << "(unknown)";
+ break;
+ }
}
Byte compress;
@@ -166,29 +166,29 @@ printHeader(ostream& s, BasicStream& stream)
switch(compress)
{
- case 0:
- {
- s << "(not compressed; do not compress response, if any)";
- break;
- }
-
- case 1:
- {
- s << "(not compressed; compress response, if any)";
- break;
- }
-
- case 2:
- {
- s << "(compressed; compress response, if any)";
- break;
- }
-
- default:
- {
- s << "(unknown)";
- break;
- }
+ case 0:
+ {
+ s << "(not compressed; do not compress response, if any)";
+ break;
+ }
+
+ case 1:
+ {
+ s << "(not compressed; compress response, if any)";
+ break;
+ }
+
+ case 2:
+ {
+ s << "(compressed; compress response, if any)";
+ break;
+ }
+
+ default:
+ {
+ s << "(unknown)";
+ break;
+ }
}
Int size;
@@ -198,198 +198,198 @@ printHeader(ostream& s, BasicStream& stream)
void
IceInternal::traceHeader(const char* heading, const BasicStream& str, const LoggerPtr& logger,
- const TraceLevelsPtr& tl)
+ const TraceLevelsPtr& tl)
{
if(tl->protocol >= 1)
{
- BasicStream& stream = const_cast<BasicStream&>(str);
- BasicStream::Container::iterator p = stream.i;
- stream.i = stream.b.begin();
+ BasicStream& stream = const_cast<BasicStream&>(str);
+ BasicStream::Container::iterator p = stream.i;
+ stream.i = stream.b.begin();
- ostringstream s;
- s << heading;
- printHeader(s, stream);
+ ostringstream s;
+ s << heading;
+ printHeader(s, stream);
- logger->trace(tl->protocolCat, s.str());
- stream.i = p;
+ logger->trace(tl->protocolCat, s.str());
+ stream.i = p;
}
}
void
IceInternal::traceRequest(const char* heading, const BasicStream& str, const LoggerPtr& logger,
- const TraceLevelsPtr& tl)
+ const TraceLevelsPtr& tl)
{
if(tl->protocol >= 1)
{
- BasicStream& stream = const_cast<BasicStream&>(str);
- BasicStream::Container::iterator p = stream.i;
- stream.i = stream.b.begin();
-
- ostringstream s;
- s << heading;
- printHeader(s, stream);
-
- Int requestId;
- stream.read(requestId);
- s << "\nrequest id = " << requestId;
- if(requestId == 0)
- {
- s << " (oneway)";
- }
-
- printRequestHeader(s, stream);
-
- logger->trace(tl->protocolCat, s.str());
- stream.i = p;
+ BasicStream& stream = const_cast<BasicStream&>(str);
+ BasicStream::Container::iterator p = stream.i;
+ stream.i = stream.b.begin();
+
+ ostringstream s;
+ s << heading;
+ printHeader(s, stream);
+
+ Int requestId;
+ stream.read(requestId);
+ s << "\nrequest id = " << requestId;
+ if(requestId == 0)
+ {
+ s << " (oneway)";
+ }
+
+ printRequestHeader(s, stream);
+
+ logger->trace(tl->protocolCat, s.str());
+ stream.i = p;
}
}
void
IceInternal::traceBatchRequest(const char* heading, const BasicStream& str, const LoggerPtr& logger,
- const TraceLevelsPtr& tl)
+ const TraceLevelsPtr& tl)
{
if(tl->protocol >= 1)
{
- BasicStream& stream = const_cast<BasicStream&>(str);
- BasicStream::Container::iterator p = stream.i;
- stream.i = stream.b.begin();
-
- ostringstream s;
- s << heading;
- printHeader(s, stream);
-
- int batchRequestNum;
- stream.read(batchRequestNum);
- s << "\nnumber of requests = " << batchRequestNum;
-
- for(int i = 0; i < batchRequestNum; ++i)
- {
- s << "\nrequest #" << i << ':';
- printRequestHeader(s, stream);
- stream.skipEncaps();
- }
-
- logger->trace(tl->protocolCat, s.str());
- stream.i = p;
+ BasicStream& stream = const_cast<BasicStream&>(str);
+ BasicStream::Container::iterator p = stream.i;
+ stream.i = stream.b.begin();
+
+ ostringstream s;
+ s << heading;
+ printHeader(s, stream);
+
+ int batchRequestNum;
+ stream.read(batchRequestNum);
+ s << "\nnumber of requests = " << batchRequestNum;
+
+ for(int i = 0; i < batchRequestNum; ++i)
+ {
+ s << "\nrequest #" << i << ':';
+ printRequestHeader(s, stream);
+ stream.skipEncaps();
+ }
+
+ logger->trace(tl->protocolCat, s.str());
+ stream.i = p;
}
}
void
IceInternal::traceReply(const char* heading, const BasicStream& str, const LoggerPtr& logger,
- const TraceLevelsPtr& tl)
+ const TraceLevelsPtr& tl)
{
if(tl->protocol >= 1)
{
- BasicStream& stream = const_cast<BasicStream&>(str);
- BasicStream::Container::iterator p = stream.i;
- stream.i = stream.b.begin();
-
- ostringstream s;
- s << heading;
- printHeader(s, stream);
-
- Int requestId;
- stream.read(requestId);
- s << "\nrequest id = " << requestId;
-
- Byte status;
- stream.read(status);
- s << "\nreply status = " << static_cast<int>(status) << ' ';
- switch(static_cast<DispatchStatus>(status))
- {
- case DispatchOK:
- {
- s << "(ok)";
- break;
- }
-
- case DispatchUserException:
- {
- s << "(user exception)";
- break;
- }
-
- case DispatchObjectNotExist:
- case DispatchFacetNotExist:
- case DispatchOperationNotExist:
- {
- switch(static_cast<DispatchStatus>(status))
- {
- case DispatchObjectNotExist:
- {
- s << "(object not exist)";
- break;
- }
-
- case DispatchFacetNotExist:
- {
- s << "(facet not exist)";
- break;
- }
-
- case DispatchOperationNotExist:
- {
- s << "(operation not exist)";
- break;
- }
-
- default:
- {
- assert(false);
- break;
- }
- }
-
- printIdentityFacetOperation(s, stream);
- break;
- }
-
- case DispatchUnknownException:
- case DispatchUnknownLocalException:
- case DispatchUnknownUserException:
- {
- switch(static_cast<DispatchStatus>(status))
- {
- case DispatchUnknownException:
- {
- s << "(unknown exception)";
- break;
- }
-
- case DispatchUnknownLocalException:
- {
- s << "(unknown local exception)";
- break;
- }
-
- case DispatchUnknownUserException:
- {
- s << "(unknown user exception)";
- break;
- }
-
- default:
- {
- assert(false);
- break;
- }
- }
-
- string unknown;
- stream.read(unknown, false);
- s << "\nunknown = " << unknown;
- break;
- }
-
- default:
- {
- s << "(unknown)";
- break;
- }
- }
-
- logger->trace(tl->protocolCat, s.str());
- stream.i = p;
+ BasicStream& stream = const_cast<BasicStream&>(str);
+ BasicStream::Container::iterator p = stream.i;
+ stream.i = stream.b.begin();
+
+ ostringstream s;
+ s << heading;
+ printHeader(s, stream);
+
+ Int requestId;
+ stream.read(requestId);
+ s << "\nrequest id = " << requestId;
+
+ Byte status;
+ stream.read(status);
+ s << "\nreply status = " << static_cast<int>(status) << ' ';
+ switch(static_cast<DispatchStatus>(status))
+ {
+ case DispatchOK:
+ {
+ s << "(ok)";
+ break;
+ }
+
+ case DispatchUserException:
+ {
+ s << "(user exception)";
+ break;
+ }
+
+ case DispatchObjectNotExist:
+ case DispatchFacetNotExist:
+ case DispatchOperationNotExist:
+ {
+ switch(static_cast<DispatchStatus>(status))
+ {
+ case DispatchObjectNotExist:
+ {
+ s << "(object not exist)";
+ break;
+ }
+
+ case DispatchFacetNotExist:
+ {
+ s << "(facet not exist)";
+ break;
+ }
+
+ case DispatchOperationNotExist:
+ {
+ s << "(operation not exist)";
+ break;
+ }
+
+ default:
+ {
+ assert(false);
+ break;
+ }
+ }
+
+ printIdentityFacetOperation(s, stream);
+ break;
+ }
+
+ case DispatchUnknownException:
+ case DispatchUnknownLocalException:
+ case DispatchUnknownUserException:
+ {
+ switch(static_cast<DispatchStatus>(status))
+ {
+ case DispatchUnknownException:
+ {
+ s << "(unknown exception)";
+ break;
+ }
+
+ case DispatchUnknownLocalException:
+ {
+ s << "(unknown local exception)";
+ break;
+ }
+
+ case DispatchUnknownUserException:
+ {
+ s << "(unknown user exception)";
+ break;
+ }
+
+ default:
+ {
+ assert(false);
+ break;
+ }
+ }
+
+ string unknown;
+ stream.read(unknown, false);
+ s << "\nunknown = " << unknown;
+ break;
+ }
+
+ default:
+ {
+ s << "(unknown)";
+ break;
+ }
+ }
+
+ logger->trace(tl->protocolCat, s.str());
+ stream.i = p;
}
}
@@ -402,9 +402,9 @@ IceInternal::traceSlicing(const char* kind, const string& typeId, const char* sl
static set<string> slicingIds;
if(slicingIds.insert(typeId).second)
{
- string s("unknown ");
- s += kind;
- s += " type `" + typeId + "'";
- logger->trace(slicingCat, s);
+ string s("unknown ");
+ s += kind;
+ s += " type `" + typeId + "'";
+ logger->trace(slicingCat, s);
}
}
diff --git a/cpp/src/Ice/UdpEndpointI.cpp b/cpp/src/Ice/UdpEndpointI.cpp
index d3ca4a84719..6681e8becbf 100644
--- a/cpp/src/Ice/UdpEndpointI.cpp
+++ b/cpp/src/Ice/UdpEndpointI.cpp
@@ -21,7 +21,7 @@ using namespace Ice;
using namespace IceInternal;
IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const string& ho, Int po, bool conn,
- const string& conId, bool co, bool pub) :
+ const string& conId, bool co, bool pub) :
_instance(instance),
_host(ho),
_port(po),
@@ -54,209 +54,209 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin
while(true)
{
- beg = str.find_first_not_of(delim, end);
- if(beg == string::npos)
- {
- break;
- }
-
- end = str.find_first_of(delim, beg);
- if(end == string::npos)
- {
- end = str.length();
- }
-
- string option = str.substr(beg, end - beg);
- if(option.length() != 2 || option[0] != '-')
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
- throw ex;
- }
-
- string argument;
- string::size_type argumentBeg = str.find_first_not_of(delim, end);
- if(argumentBeg != string::npos && str[argumentBeg] != '-')
- {
- beg = argumentBeg;
- end = str.find_first_of(delim + ":", beg);
- if(end == string::npos)
- {
- end = str.length();
- }
- argument = str.substr(beg, end - beg);
- }
-
- switch(option[1])
- {
- case 'v':
- {
- if(argument.empty())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
- throw ex;
- }
-
- string::size_type pos = argument.find('.');
- if(pos == string::npos)
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
- throw ex;
- }
- string majorStr = argument.substr(0, pos);
- string minorStr = argument.substr(pos + 1, string::npos);
-
- istringstream majStr(majorStr);
- Int majVersion;
- if(!(majStr >> majVersion) || !majStr.eof())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
- throw ex;
- }
-
- istringstream minStr(minorStr);
- Int minVersion;
- if(!(minStr >> minVersion) || !minStr.eof())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
- throw ex;
- }
-
- if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255)
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
- throw ex;
- }
-
- if(majVersion != protocolMajor)
- {
- UnsupportedProtocolException ex(__FILE__, __LINE__);
- ex.badMajor = majVersion;
- ex.badMinor = minVersion;
- ex.major = static_cast<unsigned char>(protocolMajor);
- ex.minor = static_cast<unsigned char>(protocolMinor);
- throw ex;
- }
-
- const_cast<Byte&>(_protocolMajor) = majVersion;
- const_cast<Byte&>(_protocolMinor) = minVersion;
-
- break;
- }
-
- case 'e':
- {
- if(argument.empty())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
- throw ex;
- }
- string::size_type pos = argument.find('.');
- string majorStr = argument.substr(0, pos);
- string minorStr = argument.substr(pos + 1, string::npos);
-
- istringstream majStr(majorStr);
- Int majVersion;
- if(!(majStr >> majVersion) || !majStr.eof())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
- throw ex;
- }
-
- istringstream minStr(minorStr);
- Int minVersion;
- if(!(minStr >> minVersion) || !minStr.eof())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
- throw ex;
- }
-
- if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255)
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
- throw ex;
- }
-
- if(majVersion != static_cast<unsigned char>(encodingMajor))
- {
- UnsupportedEncodingException ex(__FILE__, __LINE__);
- ex.badMajor = majVersion;
- ex.badMinor = minVersion;
- ex.major = static_cast<unsigned char>(encodingMajor);
- ex.minor = static_cast<unsigned char>(encodingMinor);
- throw ex;
- }
-
- const_cast<Byte&>(_encodingMajor) = majVersion;
- const_cast<Byte&>(_encodingMinor) = minVersion;
-
- break;
- }
-
- case 'h':
- {
- if(argument.empty())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
- throw ex;
- }
- const_cast<string&>(_host) = argument;
- break;
- }
-
- case 'p':
- {
- istringstream p(argument);
- if(!(p >> const_cast<Int&>(_port)) || !p.eof() || _port < 0 || _port > 65535)
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
- throw ex;
- }
- break;
- }
-
- case 'c':
- {
- if(!argument.empty())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
- throw ex;
- }
- const_cast<bool&>(_connect) = true;
- break;
- }
-
- case 'z':
- {
- if(!argument.empty())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
- throw ex;
- }
- const_cast<bool&>(_compress) = true;
- break;
- }
-
- default:
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
- throw ex;
- }
- }
+ beg = str.find_first_not_of(delim, end);
+ if(beg == string::npos)
+ {
+ break;
+ }
+
+ end = str.find_first_of(delim, beg);
+ if(end == string::npos)
+ {
+ end = str.length();
+ }
+
+ string option = str.substr(beg, end - beg);
+ if(option.length() != 2 || option[0] != '-')
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "udp " + str;
+ throw ex;
+ }
+
+ string argument;
+ string::size_type argumentBeg = str.find_first_not_of(delim, end);
+ if(argumentBeg != string::npos && str[argumentBeg] != '-')
+ {
+ beg = argumentBeg;
+ end = str.find_first_of(delim + ":", beg);
+ if(end == string::npos)
+ {
+ end = str.length();
+ }
+ argument = str.substr(beg, end - beg);
+ }
+
+ switch(option[1])
+ {
+ case 'v':
+ {
+ if(argument.empty())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "udp " + str;
+ throw ex;
+ }
+
+ string::size_type pos = argument.find('.');
+ if(pos == string::npos)
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "udp " + str;
+ throw ex;
+ }
+ string majorStr = argument.substr(0, pos);
+ string minorStr = argument.substr(pos + 1, string::npos);
+
+ istringstream majStr(majorStr);
+ Int majVersion;
+ if(!(majStr >> majVersion) || !majStr.eof())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "udp " + str;
+ throw ex;
+ }
+
+ istringstream minStr(minorStr);
+ Int minVersion;
+ if(!(minStr >> minVersion) || !minStr.eof())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "udp " + str;
+ throw ex;
+ }
+
+ if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255)
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "udp " + str;
+ throw ex;
+ }
+
+ if(majVersion != protocolMajor)
+ {
+ UnsupportedProtocolException ex(__FILE__, __LINE__);
+ ex.badMajor = majVersion;
+ ex.badMinor = minVersion;
+ ex.major = static_cast<unsigned char>(protocolMajor);
+ ex.minor = static_cast<unsigned char>(protocolMinor);
+ throw ex;
+ }
+
+ const_cast<Byte&>(_protocolMajor) = majVersion;
+ const_cast<Byte&>(_protocolMinor) = minVersion;
+
+ break;
+ }
+
+ case 'e':
+ {
+ if(argument.empty())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "udp " + str;
+ throw ex;
+ }
+ string::size_type pos = argument.find('.');
+ string majorStr = argument.substr(0, pos);
+ string minorStr = argument.substr(pos + 1, string::npos);
+
+ istringstream majStr(majorStr);
+ Int majVersion;
+ if(!(majStr >> majVersion) || !majStr.eof())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "udp " + str;
+ throw ex;
+ }
+
+ istringstream minStr(minorStr);
+ Int minVersion;
+ if(!(minStr >> minVersion) || !minStr.eof())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "udp " + str;
+ throw ex;
+ }
+
+ if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255)
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "udp " + str;
+ throw ex;
+ }
+
+ if(majVersion != static_cast<unsigned char>(encodingMajor))
+ {
+ UnsupportedEncodingException ex(__FILE__, __LINE__);
+ ex.badMajor = majVersion;
+ ex.badMinor = minVersion;
+ ex.major = static_cast<unsigned char>(encodingMajor);
+ ex.minor = static_cast<unsigned char>(encodingMinor);
+ throw ex;
+ }
+
+ const_cast<Byte&>(_encodingMajor) = majVersion;
+ const_cast<Byte&>(_encodingMinor) = minVersion;
+
+ break;
+ }
+
+ case 'h':
+ {
+ if(argument.empty())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "udp " + str;
+ throw ex;
+ }
+ const_cast<string&>(_host) = argument;
+ break;
+ }
+
+ case 'p':
+ {
+ istringstream p(argument);
+ if(!(p >> const_cast<Int&>(_port)) || !p.eof() || _port < 0 || _port > 65535)
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "udp " + str;
+ throw ex;
+ }
+ break;
+ }
+
+ case 'c':
+ {
+ if(!argument.empty())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "udp " + str;
+ throw ex;
+ }
+ const_cast<bool&>(_connect) = true;
+ break;
+ }
+
+ case 'z':
+ {
+ if(!argument.empty())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "udp " + str;
+ throw ex;
+ }
+ const_cast<bool&>(_compress) = true;
+ break;
+ }
+
+ default:
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "udp " + str;
+ throw ex;
+ }
+ }
}
}
@@ -280,21 +280,21 @@ IceInternal::UdpEndpointI::UdpEndpointI(BasicStream* s) :
s->read(const_cast<Byte&>(_encodingMinor));
if(_protocolMajor != protocolMajor)
{
- UnsupportedProtocolException ex(__FILE__, __LINE__);
- ex.badMajor = _protocolMajor;
- ex.badMinor = _protocolMinor;
- ex.major = static_cast<unsigned char>(protocolMajor);
- ex.minor = static_cast<unsigned char>(protocolMinor);
- throw ex;
+ UnsupportedProtocolException ex(__FILE__, __LINE__);
+ ex.badMajor = _protocolMajor;
+ ex.badMinor = _protocolMinor;
+ ex.major = static_cast<unsigned char>(protocolMajor);
+ ex.minor = static_cast<unsigned char>(protocolMinor);
+ throw ex;
}
if(_encodingMajor != encodingMajor)
{
- UnsupportedEncodingException ex(__FILE__, __LINE__);
- ex.badMajor = _encodingMajor;
- ex.badMinor = _encodingMinor;
- ex.major = static_cast<unsigned char>(encodingMajor);
- ex.minor = static_cast<unsigned char>(encodingMinor);
- throw ex;
+ UnsupportedEncodingException ex(__FILE__, __LINE__);
+ ex.badMajor = _encodingMajor;
+ ex.badMinor = _encodingMinor;
+ ex.major = static_cast<unsigned char>(encodingMajor);
+ ex.minor = static_cast<unsigned char>(encodingMinor);
+ throw ex;
}
// Not transmitted.
//s->read(const_cast<bool&>(_connect));
@@ -335,28 +335,28 @@ IceInternal::UdpEndpointI::toString() const
if(_protocolMajor != Byte(1) || _protocolMinor != Byte(0))
{
- s << " -v "
- << static_cast<unsigned>(static_cast<unsigned char>(_protocolMajor)) << "."
- << static_cast<unsigned>(static_cast<unsigned char>(_protocolMinor));
+ s << " -v "
+ << static_cast<unsigned>(static_cast<unsigned char>(_protocolMajor)) << "."
+ << static_cast<unsigned>(static_cast<unsigned char>(_protocolMinor));
}
if(_encodingMajor != Byte(1) || _encodingMinor != Byte(0))
{
- s << " -e "
- << static_cast<unsigned>(static_cast<unsigned char>(_encodingMajor)) << "."
- << static_cast<unsigned>(static_cast<unsigned char>(_encodingMinor));
+ s << " -e "
+ << static_cast<unsigned>(static_cast<unsigned char>(_encodingMajor)) << "."
+ << static_cast<unsigned>(static_cast<unsigned char>(_encodingMinor));
}
s << " -h " << _host << " -p " << _port;
if(_connect)
{
- s << " -c";
+ s << " -c";
}
if(_compress)
{
- s << " -z";
+ s << " -z";
}
return s.str();
@@ -385,11 +385,11 @@ IceInternal::UdpEndpointI::connectionId(const string& connectionId) const
{
if(connectionId == _connectionId)
{
- return const_cast<UdpEndpointI*>(this);
+ return const_cast<UdpEndpointI*>(this);
}
else
{
- return new UdpEndpointI(_instance, _host, _port, _connect, connectionId, _compress, _publish);
+ return new UdpEndpointI(_instance, _host, _port, _connect, connectionId, _compress, _publish);
}
}
@@ -404,11 +404,11 @@ IceInternal::UdpEndpointI::compress(bool compress) const
{
if(compress == _compress)
{
- return const_cast<UdpEndpointI*>(this);
+ return const_cast<UdpEndpointI*>(this);
}
else
{
- return new UdpEndpointI(_instance, _host, _port, _connect, _connectionId, compress, _publish);
+ return new UdpEndpointI(_instance, _host, _port, _connect, _connectionId, compress, _publish);
}
}
@@ -487,7 +487,7 @@ IceInternal::UdpEndpointI::expand(bool server) const
for(unsigned int i = 0; i < hosts.size(); ++i)
{
endps.push_back(new UdpEndpointI(_instance, hosts[i], _port, _connect, _connectionId, _compress,
- hosts.size() == 1 || hosts[i] != "127.0.0.1"));
+ hosts.size() == 1 || hosts[i] != "127.0.0.1"));
}
}
else
@@ -509,7 +509,7 @@ IceInternal::UdpEndpointI::equivalent(const TransceiverPtr& transceiver) const
const UdpTransceiver* udpTransceiver = dynamic_cast<const UdpTransceiver*>(transceiver.get());
if(!udpTransceiver)
{
- return false;
+ return false;
}
return udpTransceiver->equivalent(_host, _port);
}
@@ -526,72 +526,72 @@ IceInternal::UdpEndpointI::operator==(const EndpointI& r) const
const UdpEndpointI* p = dynamic_cast<const UdpEndpointI*>(&r);
if(!p)
{
- return false;
+ return false;
}
if(this == p)
{
- return true;
+ return true;
}
if(_port != p->_port)
{
- return false;
+ return false;
}
if(_compress != p->_compress)
{
- return false;
+ return false;
}
if(_connectionId != p->_connectionId)
{
- return false;
+ return false;
}
if(_connect != p->_connect)
{
- return false;
+ return false;
}
if(_protocolMajor != p->_protocolMajor)
{
- return false;
+ return false;
}
if(_protocolMinor != p->_protocolMinor)
{
- return false;
+ return false;
}
if(_encodingMajor != p->_encodingMajor)
{
- return false;
+ return false;
}
if(_encodingMinor != p->_encodingMinor)
{
- return false;
+ return false;
}
if(_host != p->_host)
{
- //
- // We do the most time-consuming part of the comparison last.
- //
- struct sockaddr_in laddr;
- struct sockaddr_in raddr;
- try
- {
- getAddress(_host, _port, laddr);
- getAddress(p->_host, p->_port, raddr);
- }
- catch(const DNSException&)
- {
- return false;
- }
+ //
+ // We do the most time-consuming part of the comparison last.
+ //
+ struct sockaddr_in laddr;
+ struct sockaddr_in raddr;
+ try
+ {
+ getAddress(_host, _port, laddr);
+ getAddress(p->_host, p->_port, raddr);
+ }
+ catch(const DNSException&)
+ {
+ return false;
+ }
- return compareAddress(laddr, raddr);
+ return compareAddress(laddr, raddr);
}
return true;
@@ -614,112 +614,112 @@ IceInternal::UdpEndpointI::operator<(const EndpointI& r) const
if(this == p)
{
- return false;
+ return false;
}
if(_port < p->_port)
{
- return true;
+ return true;
}
else if(p->_port < _port)
{
- return false;
+ return false;
}
if(_connectionId < p->_connectionId)
{
- return true;
+ return true;
}
else if(p->_connectionId < _connectionId)
{
- return false;
+ return false;
}
if(!_compress && p->_compress)
{
- return true;
+ return true;
}
else if(p->_compress < _compress)
{
- return false;
+ return false;
}
if(!_connect && p->_connect)
{
- return true;
+ return true;
}
else if(!p->_connect && _connect)
{
- return false;
+ return false;
}
if(_protocolMajor < p->_protocolMajor)
{
- return true;
+ return true;
}
else if(p->_protocolMajor < _protocolMajor)
{
- return false;
+ return false;
}
if(_protocolMinor < p->_protocolMinor)
{
- return true;
+ return true;
}
else if(p->_protocolMinor < _protocolMinor)
{
- return false;
+ return false;
}
if(_encodingMajor < p->_encodingMajor)
{
- return true;
+ return true;
}
else if(p->_encodingMajor < _encodingMajor)
{
- return false;
+ return false;
}
if(_encodingMinor < p->_encodingMinor)
{
- return true;
+ return true;
}
else if(p->_encodingMinor < _encodingMinor)
{
- return false;
+ return false;
}
if(_host != p->_host)
{
- //
- // We do the most time-consuming part of the comparison last.
- //
- struct sockaddr_in laddr;
- try
- {
- getAddress(_host, _port, laddr);
- }
- catch(const DNSException&)
- {
- }
-
- struct sockaddr_in raddr;
- try
- {
- getAddress(p->_host, p->_port, raddr);
- }
- catch(const DNSException&)
- {
- }
-
- if(laddr.sin_addr.s_addr < raddr.sin_addr.s_addr)
- {
- return true;
- }
- else if(raddr.sin_addr.s_addr < laddr.sin_addr.s_addr)
- {
- return false;
- }
+ //
+ // We do the most time-consuming part of the comparison last.
+ //
+ struct sockaddr_in laddr;
+ try
+ {
+ getAddress(_host, _port, laddr);
+ }
+ catch(const DNSException&)
+ {
+ }
+
+ struct sockaddr_in raddr;
+ try
+ {
+ getAddress(p->_host, p->_port, raddr);
+ }
+ catch(const DNSException&)
+ {
+ }
+
+ if(laddr.sin_addr.s_addr < raddr.sin_addr.s_addr)
+ {
+ return true;
+ }
+ else if(raddr.sin_addr.s_addr < laddr.sin_addr.s_addr)
+ {
+ return false;
+ }
}
return false;
diff --git a/cpp/src/Ice/UdpTransceiver.cpp b/cpp/src/Ice/UdpTransceiver.cpp
index f7e26883e38..4853d98aaa9 100644
--- a/cpp/src/Ice/UdpTransceiver.cpp
+++ b/cpp/src/Ice/UdpTransceiver.cpp
@@ -33,8 +33,8 @@ IceInternal::UdpTransceiver::close()
{
if(_traceLevels->network >= 1)
{
- Trace out(_logger, _traceLevels->networkCat);
- out << "closing udp connection\n" << toString();
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "closing udp connection\n" << toString();
}
assert(_fd != INVALID_SOCKET);
@@ -52,8 +52,8 @@ IceInternal::UdpTransceiver::shutdownReadWrite()
{
if(_traceLevels->network >= 2)
{
- Trace out(_logger, _traceLevels->networkCat);
- out << "shutting down udp connection for reading and writing\n" << toString();
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "shutting down udp connection for reading and writing\n" << toString();
}
//
@@ -84,10 +84,10 @@ IceInternal::UdpTransceiver::shutdownReadWrite()
//
if(!_connect)
{
- struct sockaddr_in unspec;
- memset(&unspec, 0, sizeof(unspec));
- unspec.sin_family = AF_UNSPEC;
- ::connect(_fd, reinterpret_cast<struct sockaddr*>(&unspec), int(sizeof(unspec)));
+ struct sockaddr_in unspec;
+ memset(&unspec, 0, sizeof(unspec));
+ unspec.sin_family = AF_UNSPEC;
+ ::connect(_fd, reinterpret_cast<struct sockaddr*>(&unspec), int(sizeof(unspec)));
}
//
@@ -117,10 +117,10 @@ IceInternal::UdpTransceiver::write(Buffer& buf, int)
const int packetSize = min(_maxPacketSize, _sndSize - _udpOverhead);
if(packetSize < static_cast<int>(buf.b.size()))
{
- //
- // We don't log a warning here because the client gets an exception anyway.
- //
- throw DatagramLimitException(__FILE__, __LINE__);
+ //
+ // We don't log a warning here because the client gets an exception anyway.
+ //
+ throw DatagramLimitException(__FILE__, __LINE__);
}
repeat:
@@ -128,62 +128,62 @@ repeat:
assert(_fd != INVALID_SOCKET);
#ifdef _WIN32
ssize_t ret = ::send(_fd, reinterpret_cast<const char*>(&buf.b[0]),
- static_cast<int>(buf.b.size()), 0);
+ static_cast<int>(buf.b.size()), 0);
#else
ssize_t ret = ::send(_fd, reinterpret_cast<const char*>(&buf.b[0]),
- buf.b.size(), 0);
+ buf.b.size(), 0);
#endif
if(ret == SOCKET_ERROR)
{
- if(interrupted())
- {
- goto repeat;
- }
+ if(interrupted())
+ {
+ goto repeat;
+ }
- if(wouldBlock())
- {
- repeatSelect:
+ if(wouldBlock())
+ {
+ repeatSelect:
- assert(_fd != INVALID_SOCKET);
+ assert(_fd != INVALID_SOCKET);
#ifdef _WIN32
- FD_SET(_fd, &_wFdSet);
- int rs = ::select(static_cast<int>(_fd + 1), 0, &_wFdSet, 0, 0);
+ FD_SET(_fd, &_wFdSet);
+ int rs = ::select(static_cast<int>(_fd + 1), 0, &_wFdSet, 0, 0);
#else
- struct pollfd fdSet[1];
- fdSet[0].fd = _fd;
- fdSet[0].events = POLLOUT;
- int rs = ::poll(fdSet, 1, -1);
+ struct pollfd fdSet[1];
+ fdSet[0].fd = _fd;
+ fdSet[0].events = POLLOUT;
+ int rs = ::poll(fdSet, 1, -1);
#endif
- if(rs == SOCKET_ERROR)
- {
- if(interrupted())
- {
- goto repeatSelect;
- }
-
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
-
- goto repeat;
- }
-
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ if(rs == SOCKET_ERROR)
+ {
+ if(interrupted())
+ {
+ goto repeatSelect;
+ }
+
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+
+ goto repeat;
+ }
+
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
if(_traceLevels->network >= 3)
{
- Trace out(_logger, _traceLevels->networkCat);
- out << "sent " << ret << " bytes via udp\n" << toString();
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "sent " << ret << " bytes via udp\n" << toString();
}
if(_stats)
{
- _stats->bytesSent(type(), static_cast<Int>(ret));
+ _stats->bytesSent(type(), static_cast<Int>(ret));
}
assert(ret == static_cast<ssize_t>(buf.b.size()));
@@ -203,16 +203,16 @@ IceInternal::UdpTransceiver::read(Buffer& buf, int)
const int packetSize = min(_maxPacketSize, _rcvSize - _udpOverhead);
if(packetSize < static_cast<int>(buf.b.size()))
{
- //
- // We log a warning here because this is the server side -- without the
- // the warning, there would only be silence.
- //
- if(_warn)
- {
- Warning out(_logger);
- out << "DatagramLimitException: maximum size of " << packetSize << " exceeded";
- }
- throw DatagramLimitException(__FILE__, __LINE__);
+ //
+ // We log a warning here because this is the server side -- without the
+ // the warning, there would only be silence.
+ //
+ if(_warn)
+ {
+ Warning out(_logger);
+ out << "DatagramLimitException: maximum size of " << packetSize << " exceeded";
+ }
+ throw DatagramLimitException(__FILE__, __LINE__);
}
buf.b.resize(packetSize);
buf.i = buf.b.begin();
@@ -223,107 +223,107 @@ repeat:
// Check the shutdown flag.
//
{
- IceUtil::Mutex::Lock sync(_shutdownReadWriteMutex);
- if(_shutdownReadWrite)
- {
- throw ConnectionLostException(__FILE__, __LINE__);
- }
+ IceUtil::Mutex::Lock sync(_shutdownReadWriteMutex);
+ if(_shutdownReadWrite)
+ {
+ throw ConnectionLostException(__FILE__, __LINE__);
+ }
}
ssize_t ret;
if(_connect)
{
- //
- // If we must connect, then we connect to the first peer that
- // sends us a packet.
- //
- struct sockaddr_in peerAddr;
- memset(&peerAddr, 0, sizeof(struct sockaddr_in));
- socklen_t len = static_cast<socklen_t>(sizeof(peerAddr));
- assert(_fd != INVALID_SOCKET);
- ret = recvfrom(_fd, reinterpret_cast<char*>(&buf.b[0]), packetSize,
- 0, reinterpret_cast<struct sockaddr*>(&peerAddr), &len);
- if(ret != SOCKET_ERROR)
- {
- doConnect(_fd, peerAddr, -1);
- _connect = false; // We are connected now.
-
- if(_traceLevels->network >= 1)
- {
- Trace out(_logger, _traceLevels->networkCat);
- out << "connected udp socket\n" << toString();
- }
- }
+ //
+ // If we must connect, then we connect to the first peer that
+ // sends us a packet.
+ //
+ struct sockaddr_in peerAddr;
+ memset(&peerAddr, 0, sizeof(struct sockaddr_in));
+ socklen_t len = static_cast<socklen_t>(sizeof(peerAddr));
+ assert(_fd != INVALID_SOCKET);
+ ret = recvfrom(_fd, reinterpret_cast<char*>(&buf.b[0]), packetSize,
+ 0, reinterpret_cast<struct sockaddr*>(&peerAddr), &len);
+ if(ret != SOCKET_ERROR)
+ {
+ doConnect(_fd, peerAddr, -1);
+ _connect = false; // We are connected now.
+
+ if(_traceLevels->network >= 1)
+ {
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "connected udp socket\n" << toString();
+ }
+ }
}
else
{
- assert(_fd != INVALID_SOCKET);
- ret = ::recv(_fd, reinterpret_cast<char*>(&buf.b[0]), packetSize, 0);
+ assert(_fd != INVALID_SOCKET);
+ ret = ::recv(_fd, reinterpret_cast<char*>(&buf.b[0]), packetSize, 0);
}
if(ret == SOCKET_ERROR)
{
- if(interrupted())
- {
- goto repeat;
- }
-
- if(wouldBlock())
- {
- repeatSelect:
-
- assert(_fd != INVALID_SOCKET);
+ if(interrupted())
+ {
+ goto repeat;
+ }
+
+ if(wouldBlock())
+ {
+ repeatSelect:
+
+ assert(_fd != INVALID_SOCKET);
#ifdef _WIN32
- FD_SET(_fd, &_rFdSet);
- int rs = ::select(static_cast<int>(_fd + 1), &_rFdSet, 0, 0, 0);
+ FD_SET(_fd, &_rFdSet);
+ int rs = ::select(static_cast<int>(_fd + 1), &_rFdSet, 0, 0, 0);
#else
- struct pollfd fdSet[1];
- fdSet[0].fd = _fd;
- fdSet[0].events = POLLIN;
- int rs = ::poll(fdSet, 1, -1);
+ struct pollfd fdSet[1];
+ fdSet[0].fd = _fd;
+ fdSet[0].events = POLLIN;
+ int rs = ::poll(fdSet, 1, -1);
#endif
- if(rs == SOCKET_ERROR)
- {
- if(interrupted())
- {
- goto repeatSelect;
- }
-
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
-
- goto repeat;
- }
-
- if(recvTruncated())
- {
- DatagramLimitException ex(__FILE__, __LINE__);
- if(_warn)
- {
- Warning out(_logger);
- out << "DatagramLimitException: maximum size of " << packetSize << " exceeded";
- }
- throw ex;
-
- }
-
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ if(rs == SOCKET_ERROR)
+ {
+ if(interrupted())
+ {
+ goto repeatSelect;
+ }
+
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+
+ goto repeat;
+ }
+
+ if(recvTruncated())
+ {
+ DatagramLimitException ex(__FILE__, __LINE__);
+ if(_warn)
+ {
+ Warning out(_logger);
+ out << "DatagramLimitException: maximum size of " << packetSize << " exceeded";
+ }
+ throw ex;
+
+ }
+
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
if(_traceLevels->network >= 3)
{
- Trace out(_logger, _traceLevels->networkCat);
- out << "received " << ret << " bytes via udp\n" << toString();
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "received " << ret << " bytes via udp\n" << toString();
}
if(_stats)
{
- _stats->bytesReceived(type(), static_cast<Int>(ret));
+ _stats->bytesReceived(type(), static_cast<Int>(ret));
}
buf.b.resize(ret);
@@ -352,12 +352,12 @@ IceInternal::UdpTransceiver::checkSendSize(const Buffer& buf, size_t messageSize
{
if(buf.b.size() > messageSizeMax)
{
- throw MemoryLimitException(__FILE__, __LINE__);
+ throw MemoryLimitException(__FILE__, __LINE__);
}
const int packetSize = min(_maxPacketSize, _sndSize - _udpOverhead);
if(packetSize < static_cast<int>(buf.b.size()))
{
- throw DatagramLimitException(__FILE__, __LINE__);
+ throw DatagramLimitException(__FILE__, __LINE__);
}
}
@@ -386,23 +386,23 @@ IceInternal::UdpTransceiver::UdpTransceiver(const InstancePtr& instance, const s
{
try
{
- _fd = createSocket(true);
- setBufSize(instance);
- setBlock(_fd, false);
- getAddress(host, port, _addr);
- doConnect(_fd, _addr, -1);
- _connect = false; // We're connected now
-
- if(_traceLevels->network >= 1)
- {
- Trace out(_logger, _traceLevels->networkCat);
- out << "starting to send udp packets\n" << toString();
- }
+ _fd = createSocket(true);
+ setBufSize(instance);
+ setBlock(_fd, false);
+ getAddress(host, port, _addr);
+ doConnect(_fd, _addr, -1);
+ _connect = false; // We're connected now
+
+ if(_traceLevels->network >= 1)
+ {
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "starting to send udp packets\n" << toString();
+ }
}
catch(...)
{
- _fd = INVALID_SOCKET;
- throw;
+ _fd = INVALID_SOCKET;
+ throw;
}
#ifdef _WIN32
@@ -422,27 +422,27 @@ IceInternal::UdpTransceiver::UdpTransceiver(const InstancePtr& instance, const s
{
try
{
- _fd = createSocket(true);
- setBufSize(instance);
- setBlock(_fd, false);
- getAddress(host, port, _addr);
- if(_traceLevels->network >= 2)
- {
- Trace out(_logger, _traceLevels->networkCat);
- out << "attempting to bind to udp socket " << addrToString(_addr);
- }
- doBind(_fd, _addr);
-
- if(_traceLevels->network >= 1)
- {
- Trace out(_logger, _traceLevels->networkCat);
- out << "starting to receive udp packets\n" << toString();
- }
+ _fd = createSocket(true);
+ setBufSize(instance);
+ setBlock(_fd, false);
+ getAddress(host, port, _addr);
+ if(_traceLevels->network >= 2)
+ {
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "attempting to bind to udp socket " << addrToString(_addr);
+ }
+ doBind(_fd, _addr);
+
+ if(_traceLevels->network >= 1)
+ {
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "starting to receive udp packets\n" << toString();
+ }
}
catch(...)
{
- _fd = INVALID_SOCKET;
- throw;
+ _fd = INVALID_SOCKET;
+ throw;
}
#ifdef _WIN32
@@ -467,66 +467,66 @@ IceInternal::UdpTransceiver::setBufSize(const InstancePtr& instance)
for(int i = 0; i < 2; ++i)
{
- string direction;
- string prop;
- int* addr;
- int dfltSize;
- if(i == 0)
- {
- direction = "receive";
- prop = "Ice.UDP.RcvSize";
- addr = &_rcvSize;
- dfltSize = getRecvBufferSize(_fd);
- _rcvSize = dfltSize;
- }
- else
- {
- direction = "send";
- prop = "Ice.UDP.SndSize";
- addr = &_sndSize;
- dfltSize = getSendBufferSize(_fd);
- _sndSize = dfltSize;
- }
-
- //
- // Get property for buffer size and check for sanity.
- //
- Int sizeRequested = instance->initializationData().properties->getPropertyAsIntWithDefault(prop, dfltSize);
- if(sizeRequested < _udpOverhead)
- {
- Warning out(_logger);
- out << "Invalid " << prop << " value of " << sizeRequested << " adjusted to " << dfltSize;
- sizeRequested = dfltSize;
- }
-
- if(sizeRequested != dfltSize)
- {
- //
- // Try to set the buffer size. The kernel will silently adjust
- // the size to an acceptable value. Then read the size back to
- // get the size that was actually set.
- //
- if(i == 0)
- {
- setRecvBufferSize(_fd, sizeRequested);
- *addr = getRecvBufferSize(_fd);
- }
- else
- {
- setSendBufferSize(_fd, sizeRequested);
- *addr = getSendBufferSize(_fd);
- }
-
- //
- // Warn if the size that was set is less than the requested size.
- //
- if(*addr < sizeRequested)
- {
- Warning out(_logger);
- out << "UDP " << direction << " buffer size: requested size of "
- << sizeRequested << " adjusted to " << *addr;
- }
- }
+ string direction;
+ string prop;
+ int* addr;
+ int dfltSize;
+ if(i == 0)
+ {
+ direction = "receive";
+ prop = "Ice.UDP.RcvSize";
+ addr = &_rcvSize;
+ dfltSize = getRecvBufferSize(_fd);
+ _rcvSize = dfltSize;
+ }
+ else
+ {
+ direction = "send";
+ prop = "Ice.UDP.SndSize";
+ addr = &_sndSize;
+ dfltSize = getSendBufferSize(_fd);
+ _sndSize = dfltSize;
+ }
+
+ //
+ // Get property for buffer size and check for sanity.
+ //
+ Int sizeRequested = instance->initializationData().properties->getPropertyAsIntWithDefault(prop, dfltSize);
+ if(sizeRequested < _udpOverhead)
+ {
+ Warning out(_logger);
+ out << "Invalid " << prop << " value of " << sizeRequested << " adjusted to " << dfltSize;
+ sizeRequested = dfltSize;
+ }
+
+ if(sizeRequested != dfltSize)
+ {
+ //
+ // Try to set the buffer size. The kernel will silently adjust
+ // the size to an acceptable value. Then read the size back to
+ // get the size that was actually set.
+ //
+ if(i == 0)
+ {
+ setRecvBufferSize(_fd, sizeRequested);
+ *addr = getRecvBufferSize(_fd);
+ }
+ else
+ {
+ setSendBufferSize(_fd, sizeRequested);
+ *addr = getSendBufferSize(_fd);
+ }
+
+ //
+ // Warn if the size that was set is less than the requested size.
+ //
+ if(*addr < sizeRequested)
+ {
+ Warning out(_logger);
+ out << "UDP " << direction << " buffer size: requested size of "
+ << sizeRequested << " adjusted to " << *addr;
+ }
+ }
}
}
diff --git a/cpp/src/Ice/UnknownEndpointI.cpp b/cpp/src/Ice/UnknownEndpointI.cpp
index 80a3b5c5b1d..12a46a347dc 100644
--- a/cpp/src/Ice/UnknownEndpointI.cpp
+++ b/cpp/src/Ice/UnknownEndpointI.cpp
@@ -153,12 +153,12 @@ IceInternal::UnknownEndpointI::operator==(const EndpointI& r) const
const UnknownEndpointI* p = dynamic_cast<const UnknownEndpointI*>(&r);
if(!p)
{
- return false;
+ return false;
}
if(this == p)
{
- return true;
+ return true;
}
if(_type != p->_type)
@@ -168,7 +168,7 @@ IceInternal::UnknownEndpointI::operator==(const EndpointI& r) const
if(_rawBytes != p->_rawBytes)
{
- return false;
+ return false;
}
return true;
@@ -191,25 +191,25 @@ IceInternal::UnknownEndpointI::operator<(const EndpointI& r) const
if(this == p)
{
- return false;
+ return false;
}
if(_type < p->_type)
{
- return true;
+ return true;
}
else if(p->_type < _type)
{
- return false;
+ return false;
}
if(_rawBytes < p->_rawBytes)
{
- return true;
+ return true;
}
else if(p->_rawBytes < _rawBytes)
{
- return false;
+ return false;
}
return false;