96ff3276f4
Work towards https://github.com/flutter/flutter/issues/46724 Background: on the latest versions of iOS today, we have to use mdns to discover the observatory port and authentication code. For a variety of reasons this can fail, leaving us with no way to connect. An alternative approach is to specify the observatory port and disable the authentication code. If binding to this port fails, however, we would still like to attempt connecting with mdns. Overview: This adds a new flag to the dart SDK, --enable-service-port-fallback. This amends the behavior of the vmservice with a specified port. After failing to bind 3 times to a non-zero port, update the port selection to 0. Results: Tested locally two dart VMs with the same specified port: ``` jonahwilliams@jonahwilliams0:~/Documents/engine/src/out/host_debug_unopt$ ./dart --enable-service-port-fallback --observe=8080 example.dart Observatory server failed to start after 1 tries Falling back to automatic port selection vm-service: isolate(2785434094928835) 'main' has no debugger attached and is paused at exit. Connect to Observatory to debug. Observatory listening on http://127.0.0.1:45663/62A5IHjmv9E=/ ``` Change-Id: I582ab402a457330928e5b490f9718fcd52b56720 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133434 Reviewed-by: Ben Konyi <bkonyi@google.com> Commit-Queue: Jonah Williams <jonahwilliams@google.com>
51 lines
1.4 KiB
C++
51 lines
1.4 KiB
C++
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
#ifndef RUNTIME_BIN_VMSERVICE_IMPL_H_
|
|
#define RUNTIME_BIN_VMSERVICE_IMPL_H_
|
|
|
|
#include "include/dart_api.h"
|
|
|
|
#include "platform/globals.h"
|
|
|
|
namespace dart {
|
|
namespace bin {
|
|
|
|
class VmService {
|
|
public:
|
|
static bool Setup(const char* server_ip,
|
|
intptr_t server_port,
|
|
bool dev_mode_server,
|
|
bool auth_codes_disabled,
|
|
const char* write_service_info_filename,
|
|
bool trace_loading,
|
|
bool deterministic,
|
|
bool enable_service_port_fallback);
|
|
|
|
static void SetNativeResolver();
|
|
|
|
// Error message if startup failed.
|
|
static const char* GetErrorMessage();
|
|
|
|
// HTTP Server's address.
|
|
static const char* GetServerAddress() { return &server_uri_[0]; }
|
|
|
|
private:
|
|
static const intptr_t kServerUriStringBufferSize = 1024;
|
|
friend void NotifyServerState(Dart_NativeArguments args);
|
|
|
|
static void SetServerAddress(const char* server_uri_);
|
|
|
|
static const char* error_msg_;
|
|
static char server_uri_[kServerUriStringBufferSize];
|
|
|
|
DISALLOW_ALLOCATION();
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(VmService);
|
|
};
|
|
|
|
} // namespace bin
|
|
} // namespace dart
|
|
|
|
#endif // RUNTIME_BIN_VMSERVICE_IMPL_H_
|