From 8db0d770f900755f66a20abedc26c8a314d730e9 Mon Sep 17 00:00:00 2001 From: Marc Laukien Date: Tue, 28 Feb 2006 22:55:43 +0000 Subject: retry fix --- cpp/src/Ice/ProxyFactory.cpp | 95 ++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 53 deletions(-) (limited to 'cpp/src/Ice/ProxyFactory.cpp') diff --git a/cpp/src/Ice/ProxyFactory.cpp b/cpp/src/Ice/ProxyFactory.cpp index 0666f4b2777..b9352ae41c9 100644 --- a/cpp/src/Ice/ProxyFactory.cpp +++ b/cpp/src/Ice/ProxyFactory.cpp @@ -111,24 +111,25 @@ IceInternal::ProxyFactory::checkRetryAfterException(const LocalException& ex, co // // There is no point in retrying an operation that resulted in a - // MarshalException. This must have been raised locally (because if - // it happened in a server it would result in an UnknownLocalException - // instead), which means there was a problem in this process that will - // not change if we try again. + // MarshalException. This must have been raised locally (because + // if it happened in a server it would result in an + // UnknownLocalException instead), which means there was a problem + // in this process that will not change if we try again. // // The most likely cause for a MarshalException is exceeding the // maximum message size, which is represented by the the subclass - // MemoryLimitException. For example, a client can attempt to send a - // message that exceeds the maximum memory size, or accumulate enough - // batch requests without flushing that the maximum size is reached. + // MemoryLimitException. For example, a client can attempt to send + // a message that exceeds the maximum memory size, or accumulate + // enough batch requests without flushing that the maximum size is + // reached. // - // This latter case is especially problematic, because if we were to - // retry a batch request after a MarshalException, we would in fact - // silently discard the accumulated requests and allow new batch - // requests to accumulate. If the subsequent batched requests do not - // exceed the maximum message size, it appears to the client that all - // of the batched requests were accepted, when in reality only the - // last few are actually sent. + // This latter case is especially problematic, because if we were + // to retry a batch request after a MarshalException, we would in + // fact silently discard the accumulated requests and allow new + // batch requests to accumulate. If the subsequent batched + // requests do not exceed the maximum message size, it appears to + // the client that all of the batched requests were accepted, when + // in reality only the last few are actually sent. // if(dynamic_cast(&ex)) { @@ -136,52 +137,40 @@ IceInternal::ProxyFactory::checkRetryAfterException(const LocalException& ex, co } ++cnt; + assert(cnt > 0); TraceLevelsPtr traceLevels = _instance->traceLevels(); LoggerPtr logger = _instance->logger(); - // - // Instance components may be null if the communicator has been - // destroyed. - // - if(traceLevels && logger) + if(cnt > static_cast(_retryIntervals.size())) { - if(cnt > static_cast(_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 << "re-trying operation call"; - if(cnt > 0 && _retryIntervals[cnt - 1] > 0) - { - out << " in " << _retryIntervals[cnt - 1] << "ms"; - } - out << " because of exception\n" << ex; - } - - if(cnt > 0) - { - // - // Sleep before retrying. - // - IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(_retryIntervals[cnt - 1])); - } + 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(); } - else + + int interval = _retryIntervals[cnt - 1]; + + if(traceLevels->retry >= 1) { - // - // Impossible to retry after the communicator has been - // destroyed. - // - ex.ice_throw(); + Trace out(logger, traceLevels->retryCat); + out << "re-trying 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)); } } -- cgit v1.2.3