summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-27 01:44:16 +0000
committervandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-27 01:44:16 +0000
commit85aa75c358eded70e4ebe9038d5133847d335b7f (patch)
tree7221ebd67f0f9cce51926ec7f622311c1f7f371e
parent89f023bd9d81f77f14399c2e0bbe8a8c638b75bc (diff)
downloadchromium_src-85aa75c358eded70e4ebe9038d5133847d335b7f.zip
chromium_src-85aa75c358eded70e4ebe9038d5133847d335b7f.tar.gz
chromium_src-85aa75c358eded70e4ebe9038d5133847d335b7f.tar.bz2
Work around 3rd party problem causing bug 27870.
Check that we report that we wrote no more than we requested to write. Remove some debugging. BUG=27870 TEST=none Review URL: http://codereview.chromium.org/660194 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40197 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--net/base/net_error_list.h4
-rw-r--r--net/http/http_stream_parser.cc7
-rw-r--r--net/http/http_stream_parser.h3
-rw-r--r--net/socket/tcp_client_socket_win.cc37
4 files changed, 32 insertions, 19 deletions
diff --git a/net/base/net_error_list.h b/net/base/net_error_list.h
index b79658c..b676986 100644
--- a/net/base/net_error_list.h
+++ b/net/base/net_error_list.h
@@ -140,6 +140,10 @@ NET_ERROR(END_OF_STREAM, -122)
// The peer sent an SSL no_renegotiation alert message.
NET_ERROR(SSL_NO_RENEGOTIATION, -123)
+// Winsock sometimes reports more data written than passed. This is probably
+// due to a broken LSP.
+NET_ERROR(WINSOCK_UNEXPECTED_WRITTEN_BYTES, -124)
+
// Certificate error codes
//
// The values of certificate error codes must be consecutive.
diff --git a/net/http/http_stream_parser.cc b/net/http/http_stream_parser.cc
index b16c1bf..02b09f0 100644
--- a/net/http/http_stream_parser.cc
+++ b/net/http/http_stream_parser.cc
@@ -20,7 +20,6 @@ HttpStreamParser::HttpStreamParser(ClientSocketHandle* connection,
request_(NULL),
request_headers_(NULL),
request_body_(NULL),
- expected_request_body_result_(0),
read_buf_(read_buffer),
read_buf_unused_offset_(0),
response_header_start_offset_(-1),
@@ -208,15 +207,11 @@ int HttpStreamParser::DoSendHeaders(int result) {
}
int HttpStreamParser::DoSendBody(int result) {
- if (result > 0) {
- CHECK(result <= expected_request_body_result_) <<
- expected_request_body_result_;
+ if (result > 0)
request_body_->DidConsume(result);
- }
if (!request_body_->eof()) {
int buf_len = static_cast<int>(request_body_->buf_len());
- expected_request_body_result_ = buf_len;
result = connection_->socket()->Write(request_body_->buf(), buf_len,
&io_callback_);
} else {
diff --git a/net/http/http_stream_parser.h b/net/http/http_stream_parser.h
index fb8c393..c47d09e 100644
--- a/net/http/http_stream_parser.h
+++ b/net/http/http_stream_parser.h
@@ -120,9 +120,6 @@ class HttpStreamParser {
// The request body data.
scoped_ptr<UploadDataStream> request_body_;
- // TODO(vandebo) expected_result is only for debugging. Bug 27870
- int expected_request_body_result_;
-
// Temporary buffer for reading.
scoped_refptr<GrowableIOBuffer> read_buf_;
diff --git a/net/socket/tcp_client_socket_win.cc b/net/socket/tcp_client_socket_win.cc
index a2159ce..1f13d9f 100644
--- a/net/socket/tcp_client_socket_win.cc
+++ b/net/socket/tcp_client_socket_win.cc
@@ -147,8 +147,7 @@ class TCPClientSocketWin::Core : public base::RefCounted<Core> {
WSABUF write_buffer_;
scoped_refptr<IOBuffer> read_iobuffer_;
scoped_refptr<IOBuffer> write_iobuffer_;
- // TODO(vandebo) remove when bug 27870 is resolved.
- size_t write_buffer_length_;
+ int write_buffer_length_;
// Throttle the read size based on our current slow start state.
// Returns the throttled read size.
@@ -505,7 +504,7 @@ int TCPClientSocketWin::Write(IOBuffer* buf,
core_->write_buffer_.len = buf_len;
core_->write_buffer_.buf = buf->data();
- core_->write_buffer_length_ = static_cast<size_t>(buf_len);
+ core_->write_buffer_length_ = buf_len;
TRACE_EVENT_BEGIN("socket.write", this, "");
// TODO(wtc): Remove the CHECK after enough testing.
@@ -516,10 +515,18 @@ int TCPClientSocketWin::Write(IOBuffer* buf,
&core_->write_overlapped_, NULL);
if (rv == 0) {
if (ResetEventIfSignaled(core_->write_overlapped_.hEvent)) {
- TRACE_EVENT_END("socket.write", this, StringPrintf("%d bytes", num));
+ rv = static_cast<int>(num);
+ if (rv > buf_len || rv < 0) {
+ // It seems that some winsock interceptors report that more was written
+ // than was available. Treat this as an error. http://crbug.com/27870
+ LOG(ERROR) << "Detected broken LSP: Asked to write " << buf_len
+ << " bytes, but " << rv << " bytes reported.";
+ return ERR_WINSOCK_UNEXPECTED_WRITTEN_BYTES;
+ }
+ TRACE_EVENT_END("socket.write", this, StringPrintf("%d bytes", rv));
static StatsCounter write_bytes("tcp.write_bytes");
- write_bytes.Add(num);
- return static_cast<int>(num);
+ write_bytes.Add(rv);
+ return rv;
}
} else {
int os_error = WSAGetLastError();
@@ -696,12 +703,22 @@ void TCPClientSocketWin::DidCompleteWrite() {
WSAResetEvent(core_->write_overlapped_.hEvent);
TRACE_EVENT_END("socket.write", this, StringPrintf("%d bytes", num_bytes));
waiting_write_ = false;
- if (ok) {
- CHECK(num_bytes <= core_->write_buffer_length_) <<
- core_->write_buffer_length_;
+ int rv;
+ if (!ok) {
+ rv = MapWinsockError(WSAGetLastError());
+ } else {
+ rv = static_cast<int>(num_bytes);
+ if (rv > core_->write_buffer_length_ || rv < 0) {
+ // It seems that some winsock interceptors report that more was written
+ // than was available. Treat this as an error. http://crbug.com/27870
+ LOG(ERROR) << "Detected broken LSP: Asked to write "
+ << core_->write_buffer_length_ << " bytes, but " << rv
+ << " bytes reported.";
+ rv = ERR_WINSOCK_UNEXPECTED_WRITTEN_BYTES;
+ }
}
core_->write_iobuffer_ = NULL;
- DoWriteCallback(ok ? num_bytes : MapWinsockError(WSAGetLastError()));
+ DoWriteCallback(rv);
}
} // namespace net