1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

[291877] Potential deadlock because traces were using the executor.

This commit is contained in:
Marc Khouzam 2009-10-13 13:03:42 +00:00
parent 271832d5e4
commit 42ae2748df

View file

@ -79,7 +79,7 @@ public abstract class AbstractMIControl extends AbstractDsfService
// MI did not always support the --thread/--frame options
// This boolean is used to know if we should use -thread-select and -stack-select-frame instead
private boolean fUseThreadAndFrameOptions;
private final boolean fUseThreadAndFrameOptions;
// currentStackLevel and currentThreadId are only necessary when
// we must use -thread-select and -stack-select-frame
private int fCurrentStackLevel = -1;
@ -142,14 +142,14 @@ public abstract class AbstractMIControl extends AbstractDsfService
* to disable tracing.
* @since 2.0
*/
protected void setMITracingStream(OutputStream tracingStream) {
protected synchronized void setMITracingStream(OutputStream tracingStream) {
fTracingStream = tracingStream;
}
/**
* Returns the MI tracing stream.
*/
private OutputStream getMITracingStream() {
private synchronized OutputStream getMITracingStream() {
return fTracingStream;
}
@ -564,26 +564,22 @@ public abstract class AbstractMIControl extends AbstractDsfService
fOutputStream.flush();
GdbPlugin.debug(GdbPlugin.getDebugTime() + MI_TRACE_IDENTIFIER + str);
getExecutor().execute(new DsfRunnable() {
public void run() {
if (getMITracingStream() != null) {
try {
String message = GdbPlugin.getDebugTime() + " " + str; //$NON-NLS-1$
while (message.length() > 100) {
String partial = message.substring(0, 100) + "\\\n"; //$NON-NLS-1$
message = message.substring(100);
getMITracingStream().write(partial.getBytes());
}
getMITracingStream().write(message.getBytes());
} catch (IOException e) {
// The tracing stream could be closed at any time
// since the user can set a preference to turn off
// this tracing.
setMITracingStream(null);
}
if (getMITracingStream() != null) {
try {
String message = GdbPlugin.getDebugTime() + " " + str; //$NON-NLS-1$
while (message.length() > 100) {
String partial = message.substring(0, 100) + "\\\n"; //$NON-NLS-1$
message = message.substring(100);
getMITracingStream().write(partial.getBytes());
}
getMITracingStream().write(message.getBytes());
} catch (IOException e) {
// The tracing stream could be closed at any time
// since the user can set a preference to turn off
// this tracing.
setMITracingStream(null);
}
});
}
}
} catch (IOException e) {
// Shutdown thread in case of IO error.
@ -618,26 +614,22 @@ public abstract class AbstractMIControl extends AbstractDsfService
GdbPlugin.debug(GdbPlugin.getDebugTime() + MI_TRACE_IDENTIFIER + line + "\n"); //$NON-NLS-1$
final String finalLine = line;
getExecutor().execute(new DsfRunnable() {
public void run() {
if (getMITracingStream() != null) {
try {
String message = GdbPlugin.getDebugTime() + " " + finalLine + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
while (message.length() > 100) {
String partial = message.substring(0, 100) + "\\\n"; //$NON-NLS-1$
message = message.substring(100);
getMITracingStream().write(partial.getBytes());
}
getMITracingStream().write(message.getBytes());
} catch (IOException e) {
// The tracing stream could be closed at any time
// since the user can set a preference to turn off
// this tracing.
setMITracingStream(null);
}
}
if (getMITracingStream() != null) {
try {
String message = GdbPlugin.getDebugTime() + " " + finalLine + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
while (message.length() > 100) {
String partial = message.substring(0, 100) + "\\\n"; //$NON-NLS-1$
message = message.substring(100);
getMITracingStream().write(partial.getBytes());
}
getMITracingStream().write(message.getBytes());
} catch (IOException e) {
// The tracing stream could be closed at any time
// since the user can set a preference to turn off
// this tracing.
setMITracingStream(null);
}
});
}
processMIOutput(line);
}