Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1937)

Unified Diff: pkg/analysis_server/lib/src/analysis_server.dart

Issue 678413003: Avoid analysis server crash when reanalyze invoked during analysis. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Change bool to only be true when performOperation pending. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/test/analysis_server_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/analysis_server.dart
diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart
index c343d22dae5efd29914ec674b0d9c9bf6e01a76b..2ad03fdf3bd3238c32d9a395288e584e401cafb8 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -180,14 +180,15 @@ class AnalysisServer {
/**
* A queue of the operations to perform in this server.
- *
- * Invariant: when this queue is non-empty, there is exactly one pending call
- * to [performOperation] on the event queue. When this list is empty, there are
- * no calls to [performOperation] on the event queue.
*/
ServerOperationQueue operationQueue;
/**
+ * True if there is a pending future which will execute [performOperation].
+ */
+ bool performOperationPending = false;
+
+ /**
* A set of the [ServerService]s to send notifications for.
*/
Set<ServerService> serverServices = new HashSet<ServerService>();
@@ -268,9 +269,8 @@ class AnalysisServer {
* Schedules execution of the given [ServerOperation].
*/
void scheduleOperation(ServerOperation operation) {
- bool wasEmpty = operationQueue.isEmpty;
addOperation(operation);
- if (wasEmpty) {
+ if (!performOperationPending) {
_schedulePerformOperation();
}
}
@@ -485,6 +485,8 @@ class AnalysisServer {
* Perform the next available [ServerOperation].
*/
void performOperation() {
+ assert(performOperationPending);
+ performOperationPending = false;
if (!running) {
// An error has occurred, or the connection to the client has been
// closed, since this method was scheduled on the event queue. So
@@ -494,6 +496,12 @@ class AnalysisServer {
}
// prepare next operation
ServerOperation operation = operationQueue.take();
+ if (operation == null) {
+ // This can happen if the operation queue is cleared while the operation
+ // loop is in progress. No problem; we just need to exit the operation
+ // loop and wait for the next operation to be added.
+ return;
+ }
sendStatusNotification(operation);
// perform the operation
try {
@@ -911,7 +919,9 @@ class AnalysisServer {
* Schedules [performOperation] exection.
*/
void _schedulePerformOperation() {
+ assert (!performOperationPending);
new Future(performOperation);
+ performOperationPending = true;
}
/**
« no previous file with comments | « no previous file | pkg/analysis_server/test/analysis_server_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698