diff options
author | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-03 23:39:05 +0000 |
---|---|---|
committer | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-03 23:39:05 +0000 |
commit | 27161fb71d092296d5c779d708095ee7bbef981c (patch) | |
tree | 0da7dbee4a3a519459becf43d7ff2732136470e6 /net | |
parent | eef576fd62fc6be5a23e276353f8cbae217d87ff (diff) | |
download | chromium_src-27161fb71d092296d5c779d708095ee7bbef981c.zip chromium_src-27161fb71d092296d5c779d708095ee7bbef981c.tar.gz chromium_src-27161fb71d092296d5c779d708095ee7bbef981c.tar.bz2 |
More instrumentation.
Review URL: http://codereview.chromium.org/9064
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4520 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/client_socket.h | 5 | ||||
-rw-r--r-- | net/base/ssl_client_socket.h | 5 | ||||
-rw-r--r-- | net/http/http_network_transaction.cc | 75 | ||||
-rw-r--r-- | net/http/http_network_transaction.h | 14 |
4 files changed, 74 insertions, 25 deletions
diff --git a/net/base/client_socket.h b/net/base/client_socket.h index 97495dd..f2f39cd 100644 --- a/net/base/client_socket.h +++ b/net/base/client_socket.h @@ -43,6 +43,11 @@ class ClientSocket : public Socket { // connection wasn't established or the connection is dead. virtual bool IsConnected() const = 0; + // TODO(eroman): Temporary for 3772 bug investigation. + virtual bool IsSSL() const { + return false; + } + #if defined(OS_LINUX) // Identical to posix system call getpeername(). // Needed by ssl_client_socket_nss. diff --git a/net/base/ssl_client_socket.h b/net/base/ssl_client_socket.h index dca5ef3..53412a5 100644 --- a/net/base/ssl_client_socket.h +++ b/net/base/ssl_client_socket.h @@ -22,6 +22,11 @@ class SSLClientSocket : public ClientSocket { public: // Gets the SSL connection information of the socket. virtual void GetSSLInfo(SSLInfo* ssl_info) = 0; + + // TODO(eroman): Temporary for 3772 bug investigation. + virtual bool IsSSL() const { + return true; + } }; } // namespace net diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc index 2417995..b25c884f 100644 --- a/net/http/http_network_transaction.cc +++ b/net/http/http_network_transaction.cc @@ -30,6 +30,9 @@ using base::Time; +// TODO(eroman): Temporary 3772 bug investigation. +#define CRASH() *((int *)0xbbadbeef) = 0 + namespace net { //----------------------------------------------------------------------------- @@ -426,6 +429,13 @@ int HttpNetworkTransaction::DoInitConnectionComplete(int result) { // trying to reuse a keep-alive connection. reused_socket_ = (connection_.socket() != NULL); if (reused_socket_) { + DCHECK(!using_ssl_ || connection_.socket()->IsSSL()); + + // TODO(eroman): Temporary for 3772 bug investigation. + if (using_ssl_ && !connection_.socket()->IsSSL()) { + CRASH(); + } + next_state_ = STATE_WRITE_HEADERS; } else { next_state_ = STATE_RESOLVE_HOST; @@ -493,12 +503,9 @@ int HttpNetworkTransaction::DoConnectComplete(int result) { if (result == OK) { next_state_ = STATE_WRITE_HEADERS; - if (using_tunnel_) { + if (using_tunnel_) establishing_tunnel_ = true; - bug_3772_.true_count++; - } } else { - bug_3772_.connect_result = result; result = HandleSSLHandshakeError(result); if (result != OK) result = ReconsiderProxyAfterError(result); @@ -689,13 +696,9 @@ int HttpNetworkTransaction::DoReadHeadersComplete(int result) { header_buf_body_offset_ = 0; } } - - // TODO(eroman): temp instrumentation for bug hunting. - Bug3772 bug_3772 = this->bug_3772_; - bug_3772.reused_socket = reused_socket_; // And, we are done with the Start or the SSL tunnel CONNECT sequence. - return DidReadResponseHeaders(&bug_3772); + return DidReadResponseHeaders(); } int HttpNetworkTransaction::DoReadBody() { @@ -763,6 +766,11 @@ int HttpNetworkTransaction::DoReadBodyComplete(int result) { // Clean up the HttpConnection if we are done. if (done) { + // TODO(eroman): Temporary for 3772 bug investigation. + if (keep_alive && using_ssl_ && !connection_.socket()->IsSSL()) { + // It is invalid to be recycling a TCPClientSocket. + CrashFor3772(); + } if (!keep_alive) connection_.set_socket(NULL); connection_.Reset(); @@ -776,11 +784,49 @@ int HttpNetworkTransaction::DoReadBodyComplete(int result) { return result; } -int HttpNetworkTransaction::DidReadResponseHeaders(Bug3772* bug_3772) { - // Make sure compiler doesn't optimize away the variable. - if (bug_3772 == reinterpret_cast<Bug3772*>(11)) - *reinterpret_cast<int*>(bug_3772) += 11; +// TODO(eroman): Temporary for 3772 bug investigation. +// --------------------------------------------------------------------------- +struct InfoFor3772 { + bool establishing_tunnel; + bool using_tunnel; + bool using_proxy; + bool reused_socket; + char url[256]; + int response_code; + int64 content_length; + HttpVersion parsed_http_version; + HttpVersion http_version; +}; + +static void KeepDataAlive(InfoFor3772* info) { + char* ptr = reinterpret_cast<char*>(info); + if (ptr == reinterpret_cast<char*>(11)) { + for (size_t i = 0; i < sizeof(InfoFor3772); ++i) + ptr[i] += 11; + } +} + +void HttpNetworkTransaction::CrashFor3772() { + // Copy some data onto the stack so it shows up in mini-dump. + InfoFor3772 info; + info.establishing_tunnel = establishing_tunnel_; + info.using_tunnel = using_tunnel_; + info.using_proxy = using_proxy_; + info.reused_socket = reused_socket_; + base::strlcpy(info.url, request_->url.spec().c_str(), 256); + info.response_code = response_.headers->response_code(); + info.content_length = response_.headers->GetContentLength(); + info.parsed_http_version = response_.headers->GetParsedHttpVersion(); + info.http_version = response_.headers->GetHttpVersion(); + + CRASH(); + + KeepDataAlive(&info); +} + +// --------------------------------------------------------------------------- +int HttpNetworkTransaction::DidReadResponseHeaders() { scoped_refptr<HttpResponseHeaders> headers; if (has_found_status_line_start()) { headers = new HttpResponseHeaders( @@ -831,7 +877,6 @@ int HttpNetworkTransaction::DidReadResponseHeaders(Bug3772* bug_3772) { request_headers_bytes_sent_ = 0; header_buf_len_ = 0; header_buf_body_offset_ = 0; - bug_3772_.false_count++; establishing_tunnel_ = false; return OK; } @@ -868,6 +913,7 @@ int HttpNetworkTransaction::DidReadResponseHeaders(Bug3772* bug_3772) { } if (using_ssl_ && !establishing_tunnel_) { + DCHECK(connection_.socket()->IsSSL()); SSLClientSocket* ssl_socket = reinterpret_cast<SSLClientSocket*>(connection_.socket()); ssl_socket->GetSSLInfo(&response_.ssl_info); @@ -901,6 +947,7 @@ int HttpNetworkTransaction::HandleCertificateError(int error) { } if (error != OK) { + DCHECK(connection_.socket()->IsSSL()); SSLClientSocket* ssl_socket = reinterpret_cast<SSLClientSocket*>(connection_.socket()); ssl_socket->GetSSLInfo(&response_.ssl_info); diff --git a/net/http/http_network_transaction.h b/net/http/http_network_transaction.h index 147c0fc..1ba2a89 100644 --- a/net/http/http_network_transaction.h +++ b/net/http/http_network_transaction.h @@ -77,19 +77,11 @@ class HttpNetworkTransaction : public HttpTransaction { int DoReadBody(); int DoReadBodyComplete(int result); - // TODO(eroman): temp instrumentation to track down a bug. - struct Bug3772 { - unsigned char true_count; - unsigned char false_count; - int connect_result; - bool reused_socket; - Bug3772() : true_count(0), false_count(0), connect_result(0), - reused_socket(false) { } - }; - Bug3772 bug_3772_; + // TODO(eroman): Temporary for 3772 bug investigation. + void CrashFor3772(); // Called when header_buf_ contains the complete response headers. - int DidReadResponseHeaders(Bug3772* /*temp hack*/); + int DidReadResponseHeaders(); // Called to handle a certificate error. Returns OK if the error should be // ignored. Otherwise, stores the certificate in response_.ssl_info and |