From 1fb9cfcdb197c108c1bd80f031c488242d761a1b Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 24 Apr 2012 03:41:49 +0200 Subject: [PATCH] v8: debug: fix error handling in SendConnectMessage() The old error handling code checked if the return value of Socket::Send() != 0, which is wrong because Socket::Send() can write less bytes than requested or return -1 on error. --- deps/v8/src/debug-agent.cc | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/deps/v8/src/debug-agent.cc b/deps/v8/src/debug-agent.cc index 511663d8ee..bdc7a578ac 100644 --- a/deps/v8/src/debug-agent.cc +++ b/deps/v8/src/debug-agent.cc @@ -323,41 +323,41 @@ bool DebuggerAgentUtil::SendConnectMessage(const Socket* conn, const char* embedding_host) { static const int kBufferSize = 80; char buffer[kBufferSize]; // Sending buffer. - bool ok; int len; + int r; // Send the header. len = OS::SNPrintF(Vector(buffer, kBufferSize), "Type: connect\r\n"); - ok = conn->Send(buffer, len); - if (!ok) return false; + r = conn->Send(buffer, len); + if (r != len) return false; len = OS::SNPrintF(Vector(buffer, kBufferSize), "V8-Version: %s\r\n", v8::V8::GetVersion()); - ok = conn->Send(buffer, len); - if (!ok) return false; + r = conn->Send(buffer, len); + if (r != len) return false; len = OS::SNPrintF(Vector(buffer, kBufferSize), "Protocol-Version: 1\r\n"); - ok = conn->Send(buffer, len); - if (!ok) return false; + r = conn->Send(buffer, len); + if (r != len) return false; if (embedding_host != NULL) { len = OS::SNPrintF(Vector(buffer, kBufferSize), "Embedding-Host: %s\r\n", embedding_host); - ok = conn->Send(buffer, len); - if (!ok) return false; + r = conn->Send(buffer, len); + if (r != len) return false; } len = OS::SNPrintF(Vector(buffer, kBufferSize), "%s: 0\r\n", kContentLength); - ok = conn->Send(buffer, len); - if (!ok) return false; + r = conn->Send(buffer, len); + if (r != len) return false; // Terminate header with empty line. len = OS::SNPrintF(Vector(buffer, kBufferSize), "\r\n"); - ok = conn->Send(buffer, len); - if (!ok) return false; + r = conn->Send(buffer, len); + if (r != len) return false; // No body for connect message.