| Index: tools/testing/dart/http_server.dart
|
| diff --git a/tools/testing/dart/http_server.dart b/tools/testing/dart/http_server.dart
|
| index d70da115d58b060005f0969286e37414f6246b44..820f07ba16a733b6a18a429e7152005b3c9cc93e 100644
|
| --- a/tools/testing/dart/http_server.dart
|
| +++ b/tools/testing/dart/http_server.dart
|
| @@ -5,11 +5,16 @@
|
| #library('http_server');
|
|
|
| #import('dart:io');
|
| +#import('dart:isolate');
|
| #import('test_suite.dart'); // For TestUtils.
|
|
|
| HttpServer _httpServer;
|
|
|
| -startHttpServer(String host, int port) {
|
| +// TODO(ager): Get rid of this when we get the Mac to behave.
|
| +int _retries = 10;
|
| +
|
| +Future<bool> startHttpServer(String host, int port) {
|
| + var completer = new Completer();
|
| var basePath = TestUtils.dartDir();
|
| _httpServer = new HttpServer();
|
| _httpServer.onError = (e) {
|
| @@ -40,7 +45,22 @@ startHttpServer(String host, int port) {
|
| });
|
| }
|
| };
|
| - _httpServer.listen(host, port);
|
| +
|
| + // TODO(ager): Get rid of this when we get the mac to behave.
|
| + // Even though we have set the SO_REUSEADDR the mac is not
|
| + // happy and gives us address alread in use errors.
|
| + try {
|
| + _httpServer.listen(host, port);
|
| + completer.complete(true);
|
| + } catch (e) {
|
| + if (_retries-- == 0) {
|
| + completer.completeException(e);
|
| + }
|
| + new Timer(1000, (t) {
|
| + startHttpServer(host, port).then((r) => completer.complete(r));
|
| + });
|
| + }
|
| + return completer.future;
|
| }
|
|
|
| terminateHttpServer() {
|
|
|