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

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

Issue 235953019: Exit stdio-based analysis server when stdin closed. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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
Index: pkg/analysis_server/lib/http_server.dart
diff --git a/pkg/analysis_server/lib/http_server.dart b/pkg/analysis_server/lib/http_server.dart
index 752e77573e56e9e0a5ba09f38012c11217d04708..af63b70ccd725b05afc64eda9b219dc98a8625e8 100644
--- a/pkg/analysis_server/lib/http_server.dart
+++ b/pkg/analysis_server/lib/http_server.dart
@@ -4,6 +4,7 @@
library http.server;
+import 'dart:async';
import 'dart:io';
import 'package:analysis_server/src/channel.dart';
@@ -33,6 +34,11 @@ class HttpAnalysisServer {
HttpAnalysisServer(this.socketServer);
/**
+ * Future that is completed with the HTTP server once it is running.
+ */
+ Future<HttpServer> _server;
+
+ /**
* Attach a listener to a newly created HTTP server.
*/
void _handleServer(HttpServer httServer) {
@@ -84,6 +90,13 @@ class HttpAnalysisServer {
* Begin serving HTTP requests over the given port.
*/
void serveHttp(int port) {
- HttpServer.bind(InternetAddress.LOOPBACK_IP_V4, port).then(_handleServer);
+ _server = HttpServer.bind(InternetAddress.LOOPBACK_IP_V4, port);
+ _server.then(_handleServer);
+ }
+
+ void close() {
+ _server.then((HttpServer server) {
+ server.close();
+ });
}
}

Powered by Google App Engine
This is Rietveld 408576698