diff options
author | Benoit Foucher <benoit@zeroc.com> | 2014-11-24 17:45:03 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2014-11-24 17:45:03 +0100 |
commit | c8a70e2f7ff3ec3392a45aeebfbbc6aa3d12bf41 (patch) | |
tree | 54edfad39dc88f804452a2407579dcd97796041e /cpp/src/Ice/Outgoing.cpp | |
parent | Another fix for ICE-5751: retry test failure (diff) | |
download | ice-c8a70e2f7ff3ec3392a45aeebfbbc6aa3d12bf41.tar.bz2 ice-c8a70e2f7ff3ec3392a45aeebfbbc6aa3d12bf41.tar.xz ice-c8a70e2f7ff3ec3392a45aeebfbbc6aa3d12bf41.zip |
ICE-5751: final fix for retry test failure
Diffstat (limited to 'cpp/src/Ice/Outgoing.cpp')
-rw-r--r-- | cpp/src/Ice/Outgoing.cpp | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/cpp/src/Ice/Outgoing.cpp b/cpp/src/Ice/Outgoing.cpp index 1e466b51f23..5f0361ba1ba 100644 --- a/cpp/src/Ice/Outgoing.cpp +++ b/cpp/src/Ice/Outgoing.cpp @@ -326,30 +326,37 @@ Outgoing::invoke() if(invocationTimeout > 0) { IceUtil::Time now = Time::now(Time::Monotonic); - if(_invocationTimeoutDeadline > now) + IceUtil::Time retryDeadline = now + interval; + + // + // Wait until either the retry and invocation timeout deadline is reached. + // Note that we're using a loop here because sleep() precision isn't as + // good as the motonic clock and it can return few hundred micro-seconds + // earlier which breaks the check for the invocation timeout. + // + while(retryDeadline > now && _invocationTimeoutDeadline > now) { - Time deadline = _invocationTimeoutDeadline - now; - if(deadline < interval) + if(retryDeadline < _invocationTimeoutDeadline) { - interval = deadline; + ThreadControl::sleep(retryDeadline - now); } - ThreadControl::sleep(interval); - if(_invocationTimeoutDeadline > Time::now(Time::Monotonic)) + else if(_invocationTimeoutDeadline > now) { - _observer.retried(); + ThreadControl::sleep(_invocationTimeoutDeadline - now); } + now = Time::now(Time::Monotonic); + } + if(now >= _invocationTimeoutDeadline) + { + throw Ice::InvocationTimeoutException(__FILE__, __LINE__); } } else { ThreadControl::sleep(interval); - _observer.retried(); } } - else - { - _observer.retried(); - } + _observer.retried(); } catch(const Ice::Exception& ex) { |