1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-01 06:05:24 +02:00

Provide a timeout for query that might run in UI thread.

GdbReverseToggleCommand extends AbstractDebugCommand so as to be able to
block without risking a deadlock.  However, this only applies to
doExecute() and isExecutable().

GdbReverseToggleCommand has two other methods that use queries, and
those are at risk of a deadlock: isReverseToggled() and
getReverseDebugMethod().  Those queries must have a timeout to avoid any
risk of deadlock.

Change-Id: Ia410b8f102638965ccbf8ac9deda06dc4efc5f0d
This commit is contained in:
Marc Khouzam 2016-03-29 10:45:43 -04:00 committed by Gerrit Code Review @ Eclipse.org
parent b08253b70a
commit 9655088708

View file

@ -279,12 +279,15 @@ public class GdbReverseToggleCommand extends AbstractDebugCommand implements ICh
}; };
try { try {
fExecutor.execute(isToggledQuery); fExecutor.execute(isToggledQuery);
return isToggledQuery.get(); return isToggledQuery.get(500, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) { } catch (InterruptedException e) {
} catch (ExecutionException e) { } catch (ExecutionException e) {
} catch (RejectedExecutionException e) { } catch (RejectedExecutionException e) {
// Can be thrown if the session is shutdown // Can be thrown if the session is shutdown
} } catch (TimeoutException e) {
// If we timeout, we default to false.
// This is to avoid a deadlock
}
return false; return false;
} }
@ -390,6 +393,8 @@ public class GdbReverseToggleCommand extends AbstractDebugCommand implements ICh
} catch (ExecutionException e) { } catch (ExecutionException e) {
} catch (RejectedExecutionException e) { } catch (RejectedExecutionException e) {
} catch (TimeoutException e) { } catch (TimeoutException e) {
// If we timeout, we default to OFF.
// This is to avoid a deadlock
} }
return ReverseDebugMethod.OFF; return ReverseDebugMethod.OFF;