summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2017-06-13 14:39:41 +0200
committerBenoit Foucher <benoit@zeroc.com>2017-06-13 14:39:41 +0200
commitc43d26cb98eb2ab48910f96600b9f402a15af499 (patch)
treefde5db315a9d2da61235938f70c0be38cadc0bf1
parentOnly install zeroc.ice.v140 when ICE_BIN_DIST == cpp (diff)
downloadice-c43d26cb98eb2ab48910f96600b9f402a15af499.tar.bz2
ice-c43d26cb98eb2ab48910f96600b9f402a15af499.tar.xz
ice-c43d26cb98eb2ab48910f96600b9f402a15af499.zip
Another fix for ICE-8015 - clearing connections from ACM monitor
-rw-r--r--cpp/src/Ice/ACM.cpp19
-rw-r--r--cpp/src/Ice/ACM.h2
-rw-r--r--csharp/src/Ice/ACM.cs20
-rw-r--r--java-compat/src/Ice/src/main/java/IceInternal/FactoryACMMonitor.java36
-rw-r--r--java/src/Ice/src/main/java/com/zeroc/IceInternal/FactoryACMMonitor.java30
5 files changed, 106 insertions, 1 deletions
diff --git a/cpp/src/Ice/ACM.cpp b/cpp/src/Ice/ACM.cpp
index 9392df6aacc..bb620d07430 100644
--- a/cpp/src/Ice/ACM.cpp
+++ b/cpp/src/Ice/ACM.cpp
@@ -94,8 +94,26 @@ IceInternal::FactoryACMMonitor::destroy()
return;
}
+ //
+ // Cancel the scheduled timer task and schedule it again now to clear the
+ // connection set from the timer thread.
+ //
+ if(!_connections.empty())
+ {
+ _instance->timer()->cancel(ICE_SHARED_FROM_THIS);
+ _instance->timer()->schedule(ICE_SHARED_FROM_THIS, IceUtil::Time());
+ }
+
_instance = 0;
_changes.clear();
+
+ //
+ // Wait for the connection set to be cleared by the timer thread.
+ //
+ while(!_connections.empty())
+ {
+ wait();
+ }
}
void
@@ -187,6 +205,7 @@ IceInternal::FactoryACMMonitor::runTimerTask()
if(!_instance)
{
_connections.clear();
+ notify();
return;
}
diff --git a/cpp/src/Ice/ACM.h b/cpp/src/Ice/ACM.h
index 169efd984db..77ca93a121a 100644
--- a/cpp/src/Ice/ACM.h
+++ b/cpp/src/Ice/ACM.h
@@ -50,7 +50,7 @@ public:
virtual Ice::ACM getACM() = 0;
};
-class FactoryACMMonitor : public ACMMonitor, public IceUtil::Mutex
+class FactoryACMMonitor : public ACMMonitor, public IceUtil::Monitor<IceUtil::Mutex>
#ifdef ICE_CPP11_MAPPING
, public std::enable_shared_from_this<FactoryACMMonitor>
#endif
diff --git a/csharp/src/Ice/ACM.cs b/csharp/src/Ice/ACM.cs
index b8af4ddff49..eb262b1e0da 100644
--- a/csharp/src/Ice/ACM.cs
+++ b/csharp/src/Ice/ACM.cs
@@ -111,8 +111,27 @@ namespace IceInternal
{
return;
}
+
+ if(_connections.Count > 0)
+ {
+ //
+ // Cancel the scheduled timer task and schedule it again now to clear the
+ // connection set from the timer thread.
+ //
+ _instance.timer().cancel(this);
+ _instance.timer().schedule(this, 0);
+ }
+
_instance = null;
_changes.Clear();
+
+ //
+ // Wait for the connection set to be cleared by the timer thread.
+ //
+ while(_connections.Count > 0)
+ {
+ System.Threading.Monitor.Wait(this);
+ }
}
}
@@ -209,6 +228,7 @@ namespace IceInternal
if(_instance == null)
{
_connections.Clear();
+ System.Threading.Monitor.Pulse(this);
return;
}
diff --git a/java-compat/src/Ice/src/main/java/IceInternal/FactoryACMMonitor.java b/java-compat/src/Ice/src/main/java/IceInternal/FactoryACMMonitor.java
index 79cb7b200ef..901491f966d 100644
--- a/java-compat/src/Ice/src/main/java/IceInternal/FactoryACMMonitor.java
+++ b/java-compat/src/Ice/src/main/java/IceInternal/FactoryACMMonitor.java
@@ -57,8 +57,42 @@ class FactoryACMMonitor implements ACMMonitor
{
return;
}
+
+ if(!_connections.isEmpty())
+ {
+ //
+ // Cancel the scheduled timer task and schedule it again now to clear the
+ // connection set from the timer thread.
+ //
+ assert(_future != null);
+ _future.cancel(false);
+ _future = null;
+
+ _instance.timer().schedule(new Runnable() {
+ @Override
+ public void run()
+ {
+ monitorConnections();
+ }
+ }, 0, java.util.concurrent.TimeUnit.MILLISECONDS);
+ }
+
_instance = null;
_changes.clear();
+
+ //
+ // Wait for the connection set to be cleared by the timer thread.
+ //
+ while(!_connections.isEmpty())
+ {
+ try
+ {
+ wait();
+ }
+ catch(InterruptedException ex)
+ {
+ }
+ }
}
@Override
@@ -72,6 +106,7 @@ class FactoryACMMonitor implements ACMMonitor
synchronized(this)
{
+ assert(_instance != null);
if(_connections.isEmpty())
{
_connections.add(connection);
@@ -168,6 +203,7 @@ class FactoryACMMonitor implements ACMMonitor
if(_instance == null)
{
_connections.clear();
+ notify();
return;
}
diff --git a/java/src/Ice/src/main/java/com/zeroc/IceInternal/FactoryACMMonitor.java b/java/src/Ice/src/main/java/com/zeroc/IceInternal/FactoryACMMonitor.java
index ba3a1b3c884..46bf10b1733 100644
--- a/java/src/Ice/src/main/java/com/zeroc/IceInternal/FactoryACMMonitor.java
+++ b/java/src/Ice/src/main/java/com/zeroc/IceInternal/FactoryACMMonitor.java
@@ -57,8 +57,36 @@ class FactoryACMMonitor implements ACMMonitor
{
return;
}
+
+ if(!_connections.isEmpty())
+ {
+ //
+ // Cancel the scheduled timer task and schedule it again now to clear the
+ // connection set from the timer thread.
+ //
+ assert(_future != null);
+ _future.cancel(false);
+ _future = null;
+
+ _instance.timer().schedule(() -> { monitorConnections(); }, 0, java.util.concurrent.TimeUnit.MILLISECONDS);
+ }
+
_instance = null;
_changes.clear();
+
+ //
+ // Wait for the connection set to be cleared by the timer thread.
+ //
+ while(!_connections.isEmpty())
+ {
+ try
+ {
+ wait();
+ }
+ catch(InterruptedException ex)
+ {
+ }
+ }
}
@Override
@@ -72,6 +100,7 @@ class FactoryACMMonitor implements ACMMonitor
synchronized(this)
{
+ assert(_instance != null);
if(_connections.isEmpty())
{
_connections.add(connection);
@@ -165,6 +194,7 @@ class FactoryACMMonitor implements ACMMonitor
if(_instance == null)
{
_connections.clear();
+ notify();
return;
}