OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "bin/vmstats_impl.h" | 5 #include "bin/vmstats_impl.h" |
6 | 6 |
7 #include "bin/file.h" | 7 #include "bin/file.h" |
8 #include "bin/log.h" | 8 #include "bin/log.h" |
9 #include "bin/platform.h" | 9 #include "bin/platform.h" |
10 #include "bin/resources.h" | 10 #include "bin/resources.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 ASSERT(instance_monitor_ != NULL); | 48 ASSERT(instance_monitor_ != NULL); |
49 Socket::Initialize(); | 49 Socket::Initialize(); |
50 | 50 |
51 if (root_dir != NULL) { | 51 if (root_dir != NULL) { |
52 instance_->root_directory_ = root_dir; | 52 instance_->root_directory_ = root_dir; |
53 } | 53 } |
54 | 54 |
55 // TODO(tball): allow host to be specified. | 55 // TODO(tball): allow host to be specified. |
56 char* host = const_cast<char*>(DEFAULT_HOST); | 56 char* host = const_cast<char*>(DEFAULT_HOST); |
57 OSError* os_error; | 57 OSError* os_error; |
58 const char* host_ip = Socket::LookupIPv4Address(host, &os_error); | 58 SocketAddresses* addresses = Socket::LookupAddress(host, -1, &os_error); |
59 if (host_ip == NULL) { | 59 if (addresses == NULL) { |
60 Log::PrintErr("Failed IP lookup of VmStats host %s: %s\n", | 60 Log::PrintErr("Failed IP lookup of VmStats host %s: %s\n", |
61 host, os_error->message()); | 61 host, os_error->message()); |
62 return; | 62 return; |
63 } | 63 } |
64 | |
65 const intptr_t BACKLOG = 128; // Default value from HttpServer.dart | 64 const intptr_t BACKLOG = 128; // Default value from HttpServer.dart |
66 int64_t address = ServerSocket::CreateBindListen(host_ip, port, BACKLOG); | 65 int64_t address = ServerSocket::CreateBindListen( |
| 66 addresses->GetAt(0)->addr(), port, BACKLOG); |
67 if (address < 0) { | 67 if (address < 0) { |
68 Log::PrintErr("Failed binding VmStats socket: %s:%d\n", host, port); | 68 Log::PrintErr("Failed binding VmStats socket: %s:%d\n", host, port); |
69 return; | 69 return; |
70 } | 70 } |
71 instance_->bind_address_ = address; | 71 instance_->bind_address_ = address; |
72 Log::Print("VmStats URL: http://%s:%"Pd"/\n", host, Socket::GetPort(address)); | 72 Log::Print("VmStats URL: http://%s:%"Pd"/\n", host, Socket::GetPort(address)); |
73 | 73 |
74 MonitorLocker ml(instance_monitor_); | 74 MonitorLocker ml(instance_monitor_); |
75 instance_->running_ = true; | 75 instance_->running_ = true; |
76 int err = dart::Thread::Start(WebServer, address); | 76 int err = dart::Thread::Start(WebServer, address); |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 VmStatusPlugin* plugin = instance_->registered_plugin_list_; | 465 VmStatusPlugin* plugin = instance_->registered_plugin_list_; |
466 while (plugin != NULL) { | 466 while (plugin != NULL) { |
467 char* result = (plugin->callback())(request); | 467 char* result = (plugin->callback())(request); |
468 if (result != NULL) { | 468 if (result != NULL) { |
469 return result; | 469 return result; |
470 } | 470 } |
471 plugin = plugin->next(); | 471 plugin = plugin->next(); |
472 } | 472 } |
473 return NULL; | 473 return NULL; |
474 } | 474 } |
OLD | NEW |