OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // OpenSSL binding for SSLClientSocket. The class layout and general principle | 5 // OpenSSL binding for SSLClientSocket. The class layout and general principle |
6 // of operation is derived from SSLClientSocketNSS. | 6 // of operation is derived from SSLClientSocketNSS. |
7 | 7 |
8 #include "net/socket/ssl_client_socket_openssl.h" | 8 #include "net/socket/ssl_client_socket_openssl.h" |
9 | 9 |
10 #include <errno.h> | 10 #include <errno.h> |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 return transport_->socket()->IsConnected(); | 532 return transport_->socket()->IsConnected(); |
533 } | 533 } |
534 | 534 |
535 bool SSLClientSocketOpenSSL::IsConnectedAndIdle() const { | 535 bool SSLClientSocketOpenSSL::IsConnectedAndIdle() const { |
536 // If the handshake has not yet completed. | 536 // If the handshake has not yet completed. |
537 if (!completed_connect_) | 537 if (!completed_connect_) |
538 return false; | 538 return false; |
539 // If an asynchronous operation is still pending. | 539 // If an asynchronous operation is still pending. |
540 if (user_read_buf_.get() || user_write_buf_.get()) | 540 if (user_read_buf_.get() || user_write_buf_.get()) |
541 return false; | 541 return false; |
542 // If there is data waiting to be sent, or data read from the network that | 542 |
543 // has not yet been consumed. | 543 // If there is data read from the network that has not yet been consumed, do |
544 if (BIO_pending(transport_bio_) > 0 || | 544 // not treat the connection as idle. |
545 BIO_wpending(transport_bio_) > 0) { | 545 // |
| 546 // Note that this does not check |BIO_pending|, whether there is ciphertext |
| 547 // that has not yet been flushed to the network. |Write| returns early, so |
| 548 // this can cause race conditions which cause a socket to not be treated |
| 549 // reusable when it should be. See https://crbug.com/466147. |
| 550 if (BIO_wpending(transport_bio_) > 0) |
546 return false; | 551 return false; |
547 } | |
548 | 552 |
549 return transport_->socket()->IsConnectedAndIdle(); | 553 return transport_->socket()->IsConnectedAndIdle(); |
550 } | 554 } |
551 | 555 |
552 int SSLClientSocketOpenSSL::GetPeerAddress(IPEndPoint* addressList) const { | 556 int SSLClientSocketOpenSSL::GetPeerAddress(IPEndPoint* addressList) const { |
553 return transport_->socket()->GetPeerAddress(addressList); | 557 return transport_->socket()->GetPeerAddress(addressList); |
554 } | 558 } |
555 | 559 |
556 int SSLClientSocketOpenSSL::GetLocalAddress(IPEndPoint* addressList) const { | 560 int SSLClientSocketOpenSSL::GetLocalAddress(IPEndPoint* addressList) const { |
557 return transport_->socket()->GetLocalAddress(addressList); | 561 return transport_->socket()->GetLocalAddress(addressList); |
(...skipping 1354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1912 | 1916 |
1913 return result; | 1917 return result; |
1914 } | 1918 } |
1915 | 1919 |
1916 scoped_refptr<X509Certificate> | 1920 scoped_refptr<X509Certificate> |
1917 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { | 1921 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { |
1918 return server_cert_; | 1922 return server_cert_; |
1919 } | 1923 } |
1920 | 1924 |
1921 } // namespace net | 1925 } // namespace net |
OLD | NEW |