Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPawel Piech2010-01-13 00:05:37 +0000
committerPawel Piech2010-01-13 00:05:37 +0000
commitb5ee81a4ee827e54ed4cc1e94a07235bc05433f7 (patch)
tree07bf2a21d90f2bd4be0d51baa86c42513893c6a5 /org.eclipse.debug.core
parentdf85f9a844428fe1d3c97a6ec17c2a1eb4b201a4 (diff)
downloadeclipse.platform.debug-b5ee81a4ee827e54ed4cc1e94a07235bc05433f7.tar.gz
eclipse.platform.debug-b5ee81a4ee827e54ed4cc1e94a07235bc05433f7.tar.xz
eclipse.platform.debug-b5ee81a4ee827e54ed4cc1e94a07235bc05433f7.zip
Bug 299444 - Deadlock in RuntimeProcess
Diffstat (limited to 'org.eclipse.debug.core')
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java6
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StreamsProxy.java31
2 files changed, 27 insertions, 10 deletions
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java
index 206e082f8..6df7e9c10 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java
@@ -230,10 +230,10 @@ public class RuntimeProcess extends PlatformObject implements IProcess {
* has terminated.
*/
protected void terminated() {
+ if (fStreamsProxy instanceof StreamsProxy) {
+ ((StreamsProxy)fStreamsProxy).close();
+ }
synchronized (this) {
- if (fStreamsProxy instanceof StreamsProxy) {
- ((StreamsProxy)fStreamsProxy).close();
- }
fTerminated= true;
try {
fExitValue = fProcess.exitValue();
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StreamsProxy.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StreamsProxy.java
index 8820f682c..5dff6b3a8 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StreamsProxy.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StreamsProxy.java
@@ -37,9 +37,10 @@ public class StreamsProxy implements IStreamsProxy, IStreamsProxy2 {
private InputStreamMonitor fInputMonitor;
/**
* Records the open/closed state of communications with
- * the underlying streams.
+ * the underlying streams. Note: fClosed is initialized to
+ * <code>false</code> by default.
*/
- private boolean fClosed= false;
+ private boolean fClosed;
/**
* Creates a <code>StreamsProxy</code> on the streams
* of the given system process.
@@ -66,8 +67,7 @@ public class StreamsProxy implements IStreamsProxy, IStreamsProxy2 {
* in the streams is read.
*/
public void close() {
- if (!fClosed) {
- fClosed= true;
+ if (!isClosed(true)) {
fOutputMonitor.close();
fErrorMonitor.close();
fInputMonitor.close();
@@ -75,13 +75,30 @@ public class StreamsProxy implements IStreamsProxy, IStreamsProxy2 {
}
/**
+ * Returns whether the proxy is currently closed. This method
+ * synchronizes access to the <code>fClosed</code> flag.
+ *
+ * @param setClosed If <code>true</code> this method will also set the
+ * <code>fClosed</code> flag to true. Otherwise, the <code>fClosed</code>
+ * flag is not modified.
+ * @return Returns whether the stream proxy was already closed.
+ */
+ private synchronized boolean isClosed(boolean setClosed) {
+ boolean closed = fClosed;
+ fClosed = setClosed;
+ return closed;
+ }
+
+ /**
* Causes the proxy to close all
* communications between it and the
* underlying streams immediately.
* Data remaining in the streams is lost.
*/
public void kill() {
- fClosed= true;
+ synchronized (this) {
+ fClosed= true;
+ }
fOutputMonitor.kill();
fErrorMonitor.kill();
fInputMonitor.close();
@@ -105,7 +122,7 @@ public class StreamsProxy implements IStreamsProxy, IStreamsProxy2 {
* @see IStreamsProxy#write(String)
*/
public void write(String input) throws IOException {
- if (!fClosed) {
+ if (!isClosed(false)) {
fInputMonitor.write(input);
} else {
throw new IOException();
@@ -116,7 +133,7 @@ public class StreamsProxy implements IStreamsProxy, IStreamsProxy2 {
* @see org.eclipse.debug.core.model.IStreamsProxy2#closeInputStream()
*/
public void closeInputStream() throws IOException {
- if (!fClosed) {
+ if (!isClosed(false)) {
fInputMonitor.closeInputStream();
} else {
throw new IOException();

Back to the top