| Index: runtime/bin/vmservice_impl.cc
|
| diff --git a/runtime/bin/vmservice_impl.cc b/runtime/bin/vmservice_impl.cc
|
| index 99e8148065a153e0dd889e632f04a3b76568ceec..43a662f46fa725677a82e9c51d2b860ae43741f4 100644
|
| --- a/runtime/bin/vmservice_impl.cc
|
| +++ b/runtime/bin/vmservice_impl.cc
|
| @@ -130,27 +130,11 @@ static Dart_NativeFunction VmServiceIONativeResolver(Dart_Handle name,
|
|
|
| const char* VmService::error_msg_ = NULL;
|
|
|
| -bool VmService::Start(const char *server_ip, intptr_t server_port) {
|
| - bool r = _Start(server_ip, server_port);
|
| - if (!r) {
|
| - return r;
|
| - }
|
| - // Start processing messages in a new thread.
|
| - Thread::Start(ThreadMain, static_cast<uword>(NULL));
|
| - return true;
|
| -}
|
| -
|
|
|
| -bool VmService::_Start(const char *server_ip, intptr_t server_port) {
|
| - ASSERT(Dart_CurrentIsolate() == NULL);
|
| - Dart_Isolate isolate = Dart_GetServiceIsolate(NULL);
|
| - if (isolate == NULL) {
|
| - error_msg_ = "Dart_GetServiceIsolate failed.";
|
| - return false;
|
| - }
|
| - Dart_EnterIsolate(isolate);
|
| - Dart_EnterScope();
|
| - // Install our own library tag handler.
|
| +bool VmService::SetupIsolate(const char* server_ip, intptr_t server_port) {
|
| + Dart_Isolate isolate = Dart_CurrentIsolate();
|
| + ASSERT(isolate != NULL);
|
| + // Install our own library tag handler.
|
| Dart_SetLibraryTagHandler(LibraryTagHandler);
|
| Dart_Handle result;
|
| Dart_Handle library;
|
| @@ -173,8 +157,9 @@ bool VmService::_Start(const char *server_ip, intptr_t server_port) {
|
| Dart_EnterIsolate(isolate);
|
| Dart_EnterScope();
|
| library = Dart_RootLibrary();
|
| + SHUTDOWN_ON_ERROR(library);
|
| result = Dart_SetNativeResolver(library, VmServiceIONativeResolver, NULL);
|
| - ASSERT(!Dart_IsError(result));
|
| + SHUTDOWN_ON_ERROR(result);
|
| // Set requested TCP port.
|
| DartUtils::SetStringField(library, "_ip", server_ip);
|
| // If we have a port specified, start the server immediately.
|
| @@ -186,31 +171,35 @@ bool VmService::_Start(const char *server_ip, intptr_t server_port) {
|
| }
|
| // Set initial state.
|
| DartUtils::SetIntegerField(library, "_port", server_port);
|
| - Dart_SetField(library,
|
| - DartUtils::NewString("_autoStart"),
|
| - Dart_NewBoolean(auto_start));
|
| + result = Dart_SetField(library,
|
| + DartUtils::NewString("_autoStart"),
|
| + Dart_NewBoolean(auto_start));
|
| + SHUTDOWN_ON_ERROR(result);
|
| // We cannot register for signals on windows.
|
| #if defined(TARGET_OS_WINDOWS)
|
| Dart_Handle is_windows = Dart_True();
|
| #else
|
| Dart_Handle is_windows = Dart_False();
|
| #endif
|
| - Dart_SetField(library, DartUtils::NewString("_isWindows"), is_windows);
|
| -
|
| + result =
|
| + Dart_SetField(library, DartUtils::NewString("_isWindows"), is_windows);
|
| + SHUTDOWN_ON_ERROR(result);
|
|
|
| // Get _getWatchSignalInternal from dart:io.
|
| Dart_Handle dart_io_str = Dart_NewStringFromCString(DartUtils::kIOLibURL);
|
| + 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);
|
| - // Invoke main.
|
| - result = Dart_Invoke(library, DartUtils::NewString("main"), 1, &signal_watch);
|
| - SHUTDOWN_ON_ERROR(result);
|
| -
|
| - Dart_ExitScope();
|
| - Dart_ExitIsolate();
|
| -
|
| + 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;
|
| }
|
|
|
| @@ -338,20 +327,5 @@ Dart_Handle VmService::LibraryTagHandler(Dart_LibraryTag tag,
|
| }
|
|
|
|
|
| -void VmService::ThreadMain(uword parameters) {
|
| - ASSERT(Dart_CurrentIsolate() == NULL);
|
| - Dart_Isolate service_isolate = Dart_GetServiceIsolate(NULL);
|
| - Dart_EnterIsolate(service_isolate);
|
| - Dart_EnterScope();
|
| - Dart_Handle result = Dart_RunLoop();
|
| - if (Dart_IsError(result)) {
|
| - printf("Service exited with an error:\n%s\n", Dart_GetError(result));
|
| - }
|
| - Dart_ExitScope();
|
| - Dart_ExitIsolate();
|
| -}
|
| -
|
| -
|
| -
|
| } // namespace bin
|
| } // namespace dart
|
|
|