diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/CommunicatorI.cpp | 4 | ||||
-rw-r--r-- | cpp/src/Ice/CommunicatorI.h | 2 | ||||
-rw-r--r-- | cpp/src/Ice/Initialize.cpp | 4 | ||||
-rw-r--r-- | cpp/src/Ice/Instance.cpp | 10 | ||||
-rw-r--r-- | cpp/src/Ice/Instance.h | 2 | ||||
-rw-r--r-- | cpp/src/Ice/OutgoingAsync.cpp | 40 | ||||
-rw-r--r-- | cpp/src/Ice/PropertiesI.cpp | 7 |
7 files changed, 38 insertions, 31 deletions
diff --git a/cpp/src/Ice/CommunicatorI.cpp b/cpp/src/Ice/CommunicatorI.cpp index 920c3e419f1..0434bb90a7a 100644 --- a/cpp/src/Ice/CommunicatorI.cpp +++ b/cpp/src/Ice/CommunicatorI.cpp @@ -344,13 +344,13 @@ Ice::CommunicatorI::flushBatchRequests() _instance->flushBatchRequests(); } -Ice::CommunicatorI::CommunicatorI(int& argc, char* argv[], const PropertiesPtr& properties) : +Ice::CommunicatorI::CommunicatorI(const PropertiesPtr& properties) : _destroyed(false) { __setNoDelete(true); try { - _instance = new Instance(this, argc, argv, properties); + _instance = new Instance(this, properties); // // Keep a reference to the dynamic library list to ensure diff --git a/cpp/src/Ice/CommunicatorI.h b/cpp/src/Ice/CommunicatorI.h index 3ad1cbeb605..46706472850 100644 --- a/cpp/src/Ice/CommunicatorI.h +++ b/cpp/src/Ice/CommunicatorI.h @@ -61,7 +61,7 @@ public: private: - CommunicatorI(int&, char*[], const PropertiesPtr&); + CommunicatorI(const PropertiesPtr&); virtual ~CommunicatorI(); // diff --git a/cpp/src/Ice/Initialize.cpp b/cpp/src/Ice/Initialize.cpp index cfb13655806..c2721f7c4b7 100644 --- a/cpp/src/Ice/Initialize.cpp +++ b/cpp/src/Ice/Initialize.cpp @@ -49,7 +49,7 @@ Ice::initialize(int& argc, char* argv[], Int version) #endif PropertiesPtr defaultProperties = getDefaultProperties(argc, argv); - CommunicatorI* communicatorI = new CommunicatorI(argc, argv, defaultProperties); + CommunicatorI* communicatorI = new CommunicatorI(defaultProperties); CommunicatorPtr result = communicatorI; // For exception safety. communicatorI->finishSetup(argc, argv); return result; @@ -65,7 +65,7 @@ Ice::initializeWithProperties(int& argc, char* argv[], const PropertiesPtr& prop } #endif - CommunicatorI* communicatorI = new CommunicatorI(argc, argv, properties); + CommunicatorI* communicatorI = new CommunicatorI(properties); CommunicatorPtr result = communicatorI; // For exception safety. communicatorI->finishSetup(argc, argv); return result; diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp index 098a4fe7898..af79598ef68 100644 --- a/cpp/src/Ice/Instance.cpp +++ b/cpp/src/Ice/Instance.cpp @@ -368,21 +368,13 @@ IceInternal::Instance::flushBatchRequests() adapterFactory->flushBatchRequests(); } -IceInternal::Instance::Instance(const CommunicatorPtr& communicator, int& argc, char* argv[], - const PropertiesPtr& properties) : +IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const PropertiesPtr& properties) : _destroyed(false), _properties(properties) { IceUtil::Mutex::Lock sync(*_globalStateMutex); ++_globalStateCounter; - // - // Convert command-line options to properties. - // - StringSeq args = argsToStringSeq(argc, argv); - args = _properties->parseIceCommandLineOptions(args); - stringSeqToArgs(args, argc, argv); - try { __setNoDelete(true); diff --git a/cpp/src/Ice/Instance.h b/cpp/src/Ice/Instance.h index 4f31513345f..cc50529d042 100644 --- a/cpp/src/Ice/Instance.h +++ b/cpp/src/Ice/Instance.h @@ -78,7 +78,7 @@ public: private: - Instance(const Ice::CommunicatorPtr&, int&, char*[], const Ice::PropertiesPtr&); + Instance(const Ice::CommunicatorPtr&, const Ice::PropertiesPtr&); virtual ~Instance(); void finishSetup(int&, char*[]); void destroy(); diff --git a/cpp/src/Ice/OutgoingAsync.cpp b/cpp/src/Ice/OutgoingAsync.cpp index b1ba114f417..cafdaec4a5f 100644 --- a/cpp/src/Ice/OutgoingAsync.cpp +++ b/cpp/src/Ice/OutgoingAsync.cpp @@ -35,8 +35,7 @@ void IceInternal::decRef(AMI_Object_ice_invoke* p) { p->__decRef(); } IceInternal::OutgoingAsync::OutgoingAsync() : __is(0), - __os(0), - _cnt(0) + __os(0) { } @@ -155,14 +154,24 @@ IceInternal::OutgoingAsync::__finished(BasicStream& is) void IceInternal::OutgoingAsync::__finished(const LocalException& exc) { - bool retry = false; if(_reference->locatorInfo) { _reference->locatorInfo->clearObjectCache(_reference); } - if(dynamic_cast<const CloseConnectionException*>(&exc)) + // + // 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 Nonmutating or Idempotent. + // + bool canRetry = _mode == Nonmutating || _mode == Idempotent || dynamic_cast<const CloseConnectionException*>(&exc); + bool doRetry = false; + + if(canRetry) { try { @@ -176,14 +185,14 @@ IceInternal::OutgoingAsync::__finished(const LocalException& exc) exc.ice_throw(); // The communicator is already destroyed, so we cannot retry. } - retry = true; + doRetry = true; } catch(const LocalException&) { } } - if(retry) + if(doRetry) { _connection->decProxyCount(); _connection = 0; @@ -236,19 +245,20 @@ IceInternal::OutgoingAsync::__prepare(const ReferencePtr& ref, const string& ope _connection = _reference->getConnection(); _connection->incProxyCount(); - assert(_cnt == 0); - assert(!__is); __is = new BasicStream(_reference->instance.get()); assert(!__os); __os = new BasicStream(_reference->instance.get()); + _cnt = 0; + _mode = mode; + _connection->prepareRequest(__os); _reference->identity.__write(__os); __os->write(_reference->facet); __os->write(operation); - __os->write(static_cast<Byte>(mode)); + __os->write(static_cast<Byte>(_mode)); __os->writeSize(Int(context.size())); Context::const_iterator p; for(p = context.begin(); p != context.end(); ++p) @@ -263,11 +273,6 @@ IceInternal::OutgoingAsync::__prepare(const ReferencePtr& ref, const string& ope void IceInternal::OutgoingAsync::__send() { - if(_connection->timeout() >= 0) - { - _absoluteTimeout = IceUtil::Time::now() + IceUtil::Time::milliSeconds(_connection->timeout()); - } - try { while(true) @@ -278,6 +283,11 @@ IceInternal::OutgoingAsync::__send() _connection->incProxyCount(); } + if(_connection->timeout() >= 0) + { + _absoluteTimeout = IceUtil::Time::now() + IceUtil::Time::milliSeconds(_connection->timeout()); + } + try { _connection->sendAsyncRequest(__os, this); @@ -351,8 +361,6 @@ IceInternal::OutgoingAsync::cleanup() _connection->decProxyCount(); _connection = 0; - _cnt = 0; - assert(__is); delete __is; __is = 0; diff --git a/cpp/src/Ice/PropertiesI.cpp b/cpp/src/Ice/PropertiesI.cpp index 5a8a4a2416c..21e522ea7ee 100644 --- a/cpp/src/Ice/PropertiesI.cpp +++ b/cpp/src/Ice/PropertiesI.cpp @@ -13,6 +13,7 @@ // ********************************************************************** #include <Ice/PropertiesI.h> +#include <Ice/Initialize.h> #include <Ice/LocalException.h> #include <fstream> @@ -500,6 +501,8 @@ Ice::PropertiesI::PropertiesI(StringSeq& args) } loadConfig(); + + args = parseIceCommandLineOptions(args); } Ice::PropertiesI::PropertiesI(int& argc, char* argv[]) @@ -524,6 +527,10 @@ Ice::PropertiesI::PropertiesI(int& argc, char* argv[]) loadConfig(); + StringSeq args = argsToStringSeq(argc, argv); + args = parseIceCommandLineOptions(args); + stringSeqToArgs(args, argc, argv); + if(argc > 0) { string name = getProperty("Ice.ProgramName"); |