summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2018-11-12 13:16:10 +0100
committerBenoit Foucher <benoit@zeroc.com>2018-11-12 13:16:10 +0100
commit17543bdb79d56062d05491229f492feaa7a1eaa5 (patch)
tree53e39686bb4aa8d448aaf8ecab1b189c28e62643
parentFixed bogus whitespaces (diff)
downloadice-17543bdb79d56062d05491229f492feaa7a1eaa5.tar.bz2
ice-17543bdb79d56062d05491229f492feaa7a1eaa5.tar.xz
ice-17543bdb79d56062d05491229f492feaa7a1eaa5.zip
Fixed rare race condition which could trigger an assert on OA destruction, fixes #291
-rw-r--r--cpp/src/Ice/ConnectionFactory.cpp20
-rw-r--r--csharp/src/Ice/ConnectionFactory.cs13
-rw-r--r--java-compat/src/Ice/src/main/java/IceInternal/IncomingConnectionFactory.java22
-rw-r--r--java/src/Ice/src/main/java/com/zeroc/IceInternal/IncomingConnectionFactory.java10
4 files changed, 30 insertions, 35 deletions
diff --git a/cpp/src/Ice/ConnectionFactory.cpp b/cpp/src/Ice/ConnectionFactory.cpp
index e61c0ac6f35..3e0aca17ba8 100644
--- a/cpp/src/Ice/ConnectionFactory.cpp
+++ b/cpp/src/Ice/ConnectionFactory.cpp
@@ -1566,6 +1566,16 @@ IceInternal::IncomingConnectionFactory::finished(ThreadPoolCurrent&, bool close)
{
closeAcceptor();
}
+
+ //
+ // If the acceptor hasn't been explicitly stopped (which is the case if the acceptor got closed
+ // because of an unexpected error), try to restart the acceptor in 1 second.
+ //
+ if(!_acceptorStopped)
+ {
+ _instance->timer()->schedule(ICE_MAKE_SHARED(StartAcceptor, ICE_SHARED_FROM_THIS, _instance),
+ IceUtil::Time::seconds(1));
+ }
return;
}
@@ -1925,14 +1935,4 @@ IceInternal::IncomingConnectionFactory::closeAcceptor()
_acceptorStarted = false;
_acceptor->close();
-
- //
- // If the acceptor hasn't been explicitly stopped (which is the case if the acceptor got closed
- // because of an unexpected error), try to restart the acceptor in 1 second.
- //
- if(!_acceptorStopped && (_state == StateHolding || _state == StateActive))
- {
- _instance->timer()->schedule(ICE_MAKE_SHARED(StartAcceptor, ICE_SHARED_FROM_THIS, _instance),
- IceUtil::Time::seconds(1));
- }
}
diff --git a/csharp/src/Ice/ConnectionFactory.cs b/csharp/src/Ice/ConnectionFactory.cs
index 091c0eae16a..fdfe0485537 100644
--- a/csharp/src/Ice/ConnectionFactory.cs
+++ b/csharp/src/Ice/ConnectionFactory.cs
@@ -1507,6 +1507,10 @@ namespace IceInternal
{
if(_state < StateClosed)
{
+ //
+ // If the acceptor got closed because of an un-expected error, try to restart it in 1 second.
+ //
+ _instance.timer().schedule(new StartAcceptor(this), 1000);
return;
}
Debug.Assert(_state == StateClosed);
@@ -1796,15 +1800,6 @@ namespace IceInternal
_acceptorStarted = false;
_acceptor.close();
-
- //
- // If the acceptor hasn't been explicitly stopped (which is the case if the acceptor got closed
- // because of an unexpected error), try to restart the acceptor in 5 seconds.
- //
- if(_state == StateHolding || _state == StateActive)
- {
- _instance.timer().schedule(new StartAcceptor(this), 1000);
- }
}
private void warning(Ice.LocalException ex)
diff --git a/java-compat/src/Ice/src/main/java/IceInternal/IncomingConnectionFactory.java b/java-compat/src/Ice/src/main/java/IceInternal/IncomingConnectionFactory.java
index 6646e435d15..6c041f0a76b 100644
--- a/java-compat/src/Ice/src/main/java/IceInternal/IncomingConnectionFactory.java
+++ b/java-compat/src/Ice/src/main/java/IceInternal/IncomingConnectionFactory.java
@@ -373,6 +373,17 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice
{
closeAcceptor();
}
+
+ //
+ // If the acceptor got closed because of an un-expected error, try to restart it in 1 second.
+ //
+ _instance.timer().schedule(new Runnable()
+ {
+ public void run()
+ {
+ startAcceptor();
+ }
+ }, 1, java.util.concurrent.TimeUnit.SECONDS);
return;
}
@@ -718,17 +729,6 @@ public final class IncomingConnectionFactory extends EventHandler implements Ice
_acceptorStarted = false;
_acceptor.close();
-
- if(_state == StateHolding || _state == StateActive)
- {
- _instance.timer().schedule(new Runnable()
- {
- public void run()
- {
- startAcceptor();
- }
- }, 1, java.util.concurrent.TimeUnit.SECONDS);
- }
}
private void
diff --git a/java/src/Ice/src/main/java/com/zeroc/IceInternal/IncomingConnectionFactory.java b/java/src/Ice/src/main/java/com/zeroc/IceInternal/IncomingConnectionFactory.java
index c35ce0c44ea..3e24b6ccfde 100644
--- a/java/src/Ice/src/main/java/com/zeroc/IceInternal/IncomingConnectionFactory.java
+++ b/java/src/Ice/src/main/java/com/zeroc/IceInternal/IncomingConnectionFactory.java
@@ -369,6 +369,11 @@ public final class IncomingConnectionFactory extends EventHandler implements Con
{
closeAcceptor();
}
+
+ //
+ // If the acceptor got closed because of an un-expected error, try to restart it in 1 second.
+ //
+ _instance.timer().schedule(() -> startAcceptor(), 1, java.util.concurrent.TimeUnit.SECONDS);
return;
}
@@ -715,11 +720,6 @@ public final class IncomingConnectionFactory extends EventHandler implements Con
_acceptorStarted = false;
_acceptor.close();
-
- if(_state == StateHolding || _state == StateActive)
- {
- _instance.timer().schedule(() -> startAcceptor(), 1, java.util.concurrent.TimeUnit.SECONDS);
- }
}
private void