Skip to content

Commit

Permalink
Expose enable-service-port-fallback switch (flutter#16366)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahwilliams committed Feb 4, 2020
1 parent 7c9b11a commit 7e1d144
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions common/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ struct Settings {
// the VM service.
bool disable_service_auth_codes = true;

// Determine whether the vmservice should fallback to automatic port selection
// after failing to bind to a specified port.
bool enable_service_port_fallback = false;

// Font settings
bool use_test_fonts = false;

Expand Down
4 changes: 3 additions & 1 deletion runtime/dart_isolate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,9 @@ Dart_Isolate DartIsolate::DartCreateAndStartServiceIsolate(
tonic::DartState::HandleLibraryTag, // embedder library tag handler
false, // disable websocket origin check
settings.disable_service_auth_codes, // disable VM service auth codes
error // error (out)
settings.enable_service_port_fallback, // enable fallback to port 0
// when bind fails.
error // error (out)
)) {
// Error is populated by call to startup.
FML_DLOG(ERROR) << *error;
Expand Down
4 changes: 4 additions & 0 deletions runtime/dart_service_isolate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ bool DartServiceIsolate::Startup(std::string server_ip,
Dart_LibraryTagHandler embedder_tag_handler,
bool disable_origin_check,
bool disable_service_auth_codes,
bool enable_service_port_fallback,
char** error) {
Dart_Isolate isolate = Dart_CurrentIsolate();
FML_CHECK(isolate);
Expand Down Expand Up @@ -196,6 +197,9 @@ bool DartServiceIsolate::Startup(std::string server_ip,
Dart_SetField(library, Dart_NewStringFromCString("_authCodesDisabled"),
Dart_NewBoolean(disable_service_auth_codes));
SHUTDOWN_ON_ERROR(result);
result = Dart_SetField(
library, Dart_NewStringFromCString("_enableServicePortFallback"),
Dart_NewBoolean(enable_service_port_fallback));
return true;
}

Expand Down
1 change: 1 addition & 0 deletions runtime/dart_service_isolate.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class DartServiceIsolate {
Dart_LibraryTagHandler embedder_tag_handler,
bool disable_origin_check,
bool disable_service_auth_codes,
bool enable_service_port_fallback,
char** error);

using CallbackHandle = ptrdiff_t;
Expand Down
5 changes: 5 additions & 0 deletions shell/common/switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ Settings SettingsFromCommandLine(const fml::CommandLine& command_line) {
settings.disable_service_auth_codes =
command_line.HasOption(FlagForSwitch(Switch::DisableServiceAuthCodes));

// Allow fallback to automatic port selection if binding to a specified port
// fails.
settings.enable_service_port_fallback =
command_line.HasOption(FlagForSwitch(Switch::EnableServicePortFallback));

// Checked mode overrides.
settings.disable_dart_asserts =
command_line.HasOption(FlagForSwitch(Switch::DisableDartAsserts));
Expand Down
4 changes: 4 additions & 0 deletions shell/common/switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ DEF_SWITCH(DisableServiceAuthCodes,
"disable-service-auth-codes",
"Disable the requirement for authentication codes for communicating"
" with the VM service.")
DEF_SWITCH(EnableServicePortFallback,
"enable-service-port-fallback",
"Allow the VM service to fallback to automatic port selection if"
" binding to a specified port fails.")
DEF_SWITCH(StartPaused,
"start-paused",
"Start the application paused in the Dart debugger.")
Expand Down

0 comments on commit 7e1d144

Please sign in to comment.