Chromium Code Reviews| 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 thest the |
|
siva
2012/06/04 21:41:12
s/thest/test/
hausner
2012/06/04 22:28:16
Oops, forgot to update. Thanks.
|
| + // 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. |
|
siva
2012/06/04 21:41:12
There is another way to handle this. If you set th
siva
2012/06/04 21:43:23
that should be TCP_NODELAY
On 2012/06/04 21:41:12
hausner
2012/06/04 22:28:16
Ok good idea. But I don't want to add stuff to the
|
| + { |
| + 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); |
| } |