Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: runtime/bin/vmstats_impl.cc

Issue 12390041: Set vmstats socket as blocking. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <sstream> 7 #include <sstream>
8 8
9 #include "bin/file.h" 9 #include "bin/file.h"
10 #include "bin/log.h" 10 #include "bin/log.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 dart::Monitor m; 142 dart::Monitor m;
143 MonitorLocker ml(&m); 143 MonitorLocker ml(&m);
144 ml.Wait(RETRY_PAUSE); 144 ml.Wait(RETRY_PAUSE);
145 145
146 continue; 146 continue;
147 } 147 }
148 if (socket < 0) { 148 if (socket < 0) {
149 // Stop() closed the socket. 149 // Stop() closed the socket.
150 return; 150 return;
151 } 151 }
152 Socket::SetBlocking(socket);
152 153
153 // TODO(tball): rewrite this to use STL, so as to eliminate the static 154 // TODO(tball): rewrite this to use STL, so as to eliminate the static
154 // buffer and support resource URLs that are longer than BUFSIZE. 155 // buffer and support resource URLs that are longer than BUFSIZE.
155 156
156 // Read request. 157 // Read request.
157 char buffer[BUFSIZE + 1]; 158 char buffer[BUFSIZE + 1];
158 intptr_t len = Socket::Read(socket, buffer, BUFSIZE); 159 intptr_t len = Socket::Read(socket, buffer, BUFSIZE);
159 if (len <= 0) { 160 if (len <= 0) {
160 // Invalid HTTP request, ignore. 161 // Invalid HTTP request, ignore.
161 continue; 162 continue;
162 } 163 }
163 intptr_t n;
164 while ((n = Socket::Read(socket, buffer + len, BUFSIZE - len)) > 0) {
165 len += n;
166 }
167 buffer[len] = '\0'; 164 buffer[len] = '\0';
168 165
169 // Verify it's a GET request. 166 // Verify it's a GET request.
170 // TODO(tball): support POST requests. 167 // TODO(tball): support POST requests.
171 if (strncmp("GET ", buffer, 4) != 0 && strncmp("get ", buffer, 4) != 0) { 168 if (strncmp("GET ", buffer, 4) != 0 && strncmp("get ", buffer, 4) != 0) {
172 Log::PrintErr("Unsupported HTTP request type"); 169 Log::PrintErr("Unsupported HTTP request type");
173 const char* response = "HTTP/1.1 403 Forbidden\n" 170 const char* response = "HTTP/1.1 403 Forbidden\n"
174 "Content-Length: 120\n" 171 "Content-Length: 120\n"
175 "Connection: close\n" 172 "Connection: close\n"
176 "Content-Type: text/html\n\n" 173 "Content-Type: text/html\n\n"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 VmStatusPlugin* plugin = instance_->registered_plugin_list_; 323 VmStatusPlugin* plugin = instance_->registered_plugin_list_;
327 while (plugin != NULL) { 324 while (plugin != NULL) {
328 char* result = (plugin->callback())(request); 325 char* result = (plugin->callback())(request);
329 if (result != NULL) { 326 if (result != NULL) {
330 return result; 327 return result;
331 } 328 }
332 plugin = plugin->next(); 329 plugin = plugin->next();
333 } 330 }
334 return NULL; 331 return NULL;
335 } 332 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698