Skip to content

Commit

Permalink
Allow SIGQUIT to toggle the vm-service server a la command line Dart. (
Browse files Browse the repository at this point in the history
  • Loading branch information
rmacnak-google authored Jul 10, 2017
1 parent a4fa558 commit d67b614
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
15 changes: 8 additions & 7 deletions runtime/dart_init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,16 @@ Dart_Isolate ServiceIsolateCreateCallback(const char* script_uri,
DartUI::InitForIsolate();
DartRuntimeHooks::Install(DartRuntimeHooks::SecondaryIsolate, script_uri);
const Settings& settings = Settings::Get();
std::string ip = settings.ipv6 ? "::1" : "127.0.0.1";
intptr_t port = -1;
if (settings.enable_observatory) {
std::string ip = settings.ipv6 ? "::1" : "127.0.0.1";
const intptr_t port = settings.observatory_port;
const bool disable_websocket_origin_check = false;
const bool service_isolate_booted = DartServiceIsolate::Startup(
ip, port, tonic::DartState::HandleLibraryTag,
IsRunningPrecompiledCode(), disable_websocket_origin_check, error);
FTL_CHECK(service_isolate_booted) << error;
port = settings.observatory_port;
}
const bool disable_websocket_origin_check = false;
const bool service_isolate_booted = DartServiceIsolate::Startup(
ip, port, tonic::DartState::HandleLibraryTag,
IsRunningPrecompiledCode(), disable_websocket_origin_check, error);
FTL_CHECK(service_isolate_booted) << error;

if (g_service_isolate_hook)
g_service_isolate_hook(IsRunningPrecompiledCode());
Expand Down
18 changes: 17 additions & 1 deletion runtime/dart_service_isolate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ bool DartServiceIsolate::Startup(std::string server_ip,
// port when the HTTP server is started.
server_port = 0;
}
// Set the HTTP's servers port.
// Set the HTTP server's port.
result = Dart_SetField(library, Dart_NewStringFromCString("_port"),
Dart_NewInteger(server_port));
SHUTDOWN_ON_ERROR(result);
Expand All @@ -171,6 +171,22 @@ bool DartServiceIsolate::Startup(std::string server_ip,
Dart_SetField(library, Dart_NewStringFromCString("_originCheckDisabled"),
Dart_NewBoolean(disable_origin_check));
SHUTDOWN_ON_ERROR(result);

// Get _getWatchSignalInternal from dart:io.
Dart_Handle dart_io_str = Dart_NewStringFromCString("dart:io");
SHUTDOWN_ON_ERROR(dart_io_str);
Dart_Handle io_lib = Dart_LookupLibrary(dart_io_str);
SHUTDOWN_ON_ERROR(io_lib);
Dart_Handle function_name =
Dart_NewStringFromCString("_getWatchSignalInternal");
SHUTDOWN_ON_ERROR(function_name);
Dart_Handle signal_watch = Dart_Invoke(io_lib, function_name, 0, NULL);
SHUTDOWN_ON_ERROR(signal_watch);
Dart_Handle field_name = Dart_NewStringFromCString("_signalWatch");
SHUTDOWN_ON_ERROR(field_name);
result = Dart_SetField(library, field_name, signal_watch);
SHUTDOWN_ON_ERROR(field_name);

return true;
}

Expand Down

0 comments on commit d67b614

Please sign in to comment.