summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaspar De Groot2010-08-08 23:17:06 (EDT)
committerCaspar De Groot2010-08-08 23:17:06 (EDT)
commit0e71cdc9d02fe58ec654ed3481879b760cc225cd (patch)
tree9b8516ecc591f12ad377f48a8711bc3e07c0269a
parentc998af19078971058b7aaf2ed14264a66797dd9e (diff)
downloadcdo-0e71cdc9d02fe58ec654ed3481879b760cc225cd.zip
cdo-0e71cdc9d02fe58ec654ed3481879b760cc225cd.tar.gz
cdo-0e71cdc9d02fe58ec654ed3481879b760cc225cd.tar.bz2
[321193] CDOServerProtocol can get deactivated while associated Signals are still executing
https://bugs.eclipse.org/bugs/show_bug.cgi?id=321193
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java24
1 files changed, 11 insertions, 13 deletions
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java
index c78e8ca..4c0c2b0 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java
@@ -280,17 +280,23 @@ public class SignalProtocol<INFRA_STRUCTURE> extends Protocol<INFRA_STRUCTURE> i
}
@Override
- protected void doDeactivate() throws Exception
+ protected void doBeforeDeactivate() throws Exception
{
- for (Signal signal : getSignals())
+ synchronized (signals)
{
- if (signal instanceof RequestWithConfirmation<?>)
+ // Wait at most 10 seconds for running signals to finish
+ int waitMillis = 10 * 1000;
+ long stop = System.currentTimeMillis() + waitMillis;
+ while (!signals.isEmpty() && System.currentTimeMillis() < stop)
{
- RequestWithConfirmation<?> request = (RequestWithConfirmation<?>)signal;
- request.setRemoteException(new IllegalStateException("Request canceled due to protocol deactivation"), false); //$NON-NLS-1$
+ signals.wait(1000L);
}
}
+ }
+ @Override
+ protected void doDeactivate() throws Exception
+ {
synchronized (signals)
{
signals.clear();
@@ -358,14 +364,6 @@ public class SignalProtocol<INFRA_STRUCTURE> extends Protocol<INFRA_STRUCTURE> i
return null;
}
- private Signal[] getSignals()
- {
- synchronized (signals)
- {
- return signals.values().toArray(new Signal[signals.size()]);
- }
- }
-
synchronized int getNextCorrelationID()
{
int correlationID = nextCorrelationID;