summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/ProxyFactory.cpp9
-rw-r--r--cpp/src/IceUtil/Timer.cpp14
2 files changed, 19 insertions, 4 deletions
diff --git a/cpp/src/Ice/ProxyFactory.cpp b/cpp/src/Ice/ProxyFactory.cpp
index 48e9460bada..2fc5316eb6d 100644
--- a/cpp/src/Ice/ProxyFactory.cpp
+++ b/cpp/src/Ice/ProxyFactory.cpp
@@ -248,7 +248,14 @@ IceInternal::ProxyFactory::checkRetryAfterException(const LocalException& ex,
{
if(out)
{
- _instance->timer()->schedule(new RetryTask(out), IceUtil::Time::milliSeconds(interval));
+ try
+ {
+ _instance->timer()->schedule(new RetryTask(out), IceUtil::Time::milliSeconds(interval));
+ }
+ catch(const IceUtil::IllegalArgumentException&) // Expected if the communicator destroyed the timer.
+ {
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ }
}
else
{
diff --git a/cpp/src/IceUtil/Timer.cpp b/cpp/src/IceUtil/Timer.cpp
index 8a70432709d..a5b2175c425 100644
--- a/cpp/src/IceUtil/Timer.cpp
+++ b/cpp/src/IceUtil/Timer.cpp
@@ -32,7 +32,15 @@ Timer::destroy()
_tasks.clear();
_tokens.clear();
}
- getThreadControl().join();
+
+ if(getThreadControl() == ThreadControl())
+ {
+ getThreadControl().detach();
+ }
+ else
+ {
+ getThreadControl().join();
+ }
}
void
@@ -41,7 +49,7 @@ Timer::schedule(const TimerTaskPtr& task, const IceUtil::Time& delay)
IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor);
if(_destroyed)
{
- return;
+ throw IllegalArgumentException(__FILE__, __LINE__, "timer destroyed");
}
IceUtil::Time time = IceUtil::Time::now(IceUtil::Time::Monotonic) + delay;
@@ -64,7 +72,7 @@ Timer::scheduleRepeated(const TimerTaskPtr& task, const IceUtil::Time& delay)
IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor);
if(_destroyed)
{
- return;
+ throw IllegalArgumentException(__FILE__, __LINE__, "timer destroyed");
}
const Token token(IceUtil::Time::now(IceUtil::Time::Monotonic) + delay, delay, task);