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

Unified Diff: runtime/bin/dbg_connection.cc

Issue 10515015: Fix handling of long JSON messages (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/ddbg.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/dbg_connection.cc
===================================================================
--- runtime/bin/dbg_connection.cc (revision 8261)
+++ runtime/bin/dbg_connection.cc (working copy)
@@ -202,7 +202,36 @@
void DebuggerConnectionHandler::SendMsg(dart::TextBuffer* msg) {
ASSERT(debugger_fd_ >= 0);
- Socket::Write(debugger_fd_, msg->buf(), msg->length());
+ ASSERT(IsValidJSON(msg->buf()));
+ // Sending messages in short pieces can be used to stress test the
+ // debugger front-end's message handling code.
+ const bool send_in_pieces = false;
+ if (send_in_pieces) {
+ intptr_t remaining = msg->length();
+ intptr_t sent = 0;
+ const intptr_t max_piece_len = 122; // Pretty arbitrary, not a power of 2.
+ dart::Monitor sleep;
+ while (remaining > 0) {
+ intptr_t piece_len = remaining;
+ if (piece_len > max_piece_len) {
+ piece_len = max_piece_len;
+ }
+ intptr_t written =
+ Socket::Write(debugger_fd_, msg->buf() + sent, piece_len);
+ ASSERT(written == piece_len);
+ sent += written;
+ remaining -= written;
+ // Wait briefly so the OS does not coalesce message fragments.
+ {
+ MonitorLocker ml(&sleep);
+ ml.Wait(10);
+ }
+ }
+ return;
+ }
+ intptr_t bytes_written =
+ Socket::Write(debugger_fd_, msg->buf(), msg->length());
+ ASSERT(msg->length() == bytes_written);
// TODO(hausner): Error checking. Probably just shut down the debugger
// session if we there is an error while writing.
}
@@ -725,8 +754,7 @@
msg.Printf("{ \"event\": \"paused\", \"params\": { ");
FormatCallFrames(&msg, trace);
msg.Printf("}}");
- Socket::Write(debugger_fd_, msg.buf(), msg.length());
- ASSERT(IsValidJSON(msg.buf()));
+ SendMsg(&msg);
}
« no previous file with comments | « no previous file | tools/ddbg.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698