Wait for InstrumentationService.shutdown() before exit(0).

Otherwise we don't get the last portion of instrumentation data in the
file at all.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1413403007 .
This commit is contained in:
Konstantin Shcheglov 2015-11-04 10:08:20 -08:00
parent 1ea74a407b
commit d49d0f7e06
4 changed files with 16 additions and 12 deletions

View file

@ -428,11 +428,11 @@ class Driver implements ServerStarter {
}
_captureExceptions(service, () {
stdioServer.serveStdio().then((_) {
stdioServer.serveStdio().then((_) async {
if (serve_http) {
httpServer.close();
}
service.shutdown();
await service.shutdown();
exit(0);
});
},

View file

@ -4,6 +4,7 @@
library file_instrumentation;
import 'dart:async';
import 'dart:io';
import 'package:analyzer/instrumentation/instrumentation.dart';
@ -30,8 +31,8 @@ class FileInstrumentationServer implements InstrumentationServer {
}
@override
void shutdown() {
_sink.close();
Future shutdown() async {
await _sink.close();
_sink = null;
}
}

View file

@ -4,6 +4,7 @@
library instrumentation;
import 'dart:async';
import 'dart:convert';
import 'package:analyzer/task/model.dart';
@ -43,7 +44,7 @@ abstract class InstrumentationServer {
* server. This method should be invoked exactly one time and no other methods
* should be invoked on this instance after this method has been invoked.
*/
void shutdown();
Future shutdown();
}
/**
@ -83,7 +84,7 @@ class InstrumentationService {
int _subprocessCounter = 0;
/**
* Initialize a newly created instrumentation service to comunicate with the
* Initialize a newly created instrumentation service to communicate with the
* given [instrumentationServer].
*/
InstrumentationService(this._instrumentationServer);
@ -216,7 +217,7 @@ class InstrumentationService {
/**
* Log the result of executing a subprocess. [subprocessId] should be the
* unique IDreturned by [logSubprocessStart].
* unique ID returned by [logSubprocessStart].
*/
void logSubprocessResult(
int subprocessId, int exitCode, String stdout, String stderr) {
@ -290,9 +291,9 @@ class InstrumentationService {
* server. This method should be invoked exactly one time and no other methods
* should be invoked on this instance after this method has been invoked.
*/
void shutdown() {
Future shutdown() async {
if (_instrumentationServer != null) {
_instrumentationServer.shutdown();
await _instrumentationServer.shutdown();
_instrumentationServer = null;
}
}
@ -373,9 +374,9 @@ class MulticastInstrumentationServer implements InstrumentationServer {
}
@override
void shutdown() {
Future shutdown() async {
for (InstrumentationServer server in _servers) {
server.shutdown();
await server.shutdown();
}
}
}

View file

@ -4,6 +4,8 @@
library test.instrumentation;
import 'dart:async';
import 'package:analyzer/instrumentation/instrumentation.dart';
import 'package:unittest/unittest.dart';
@ -174,7 +176,7 @@ class TestInstrumentationServer implements InstrumentationServer {
}
@override
void shutdown() {
Future shutdown() async {
// Ignored
}
}