summaryrefslogtreecommitdiffstats
path: root/net/socket
diff options
context:
space:
mode:
Diffstat (limited to 'net/socket')
-rw-r--r--net/socket/ssl_client_socket_nss.cc22
-rw-r--r--net/socket/ssl_client_socket_nss.h3
-rw-r--r--net/socket/tcp_client_socket_libevent.cc12
3 files changed, 17 insertions, 20 deletions
diff --git a/net/socket/ssl_client_socket_nss.cc b/net/socket/ssl_client_socket_nss.cc
index 75de2c9..18b4e58 100644
--- a/net/socket/ssl_client_socket_nss.cc
+++ b/net/socket/ssl_client_socket_nss.cc
@@ -452,7 +452,6 @@ SSLClientSocketNSS::SSLClientSocketNSS(ClientSocketHandle* transport_socket,
completed_handshake_(false),
eset_mitm_detected_(false),
predicted_cert_chain_correct_(false),
- peername_initialized_(false),
next_handshake_state_(STATE_NONE),
nss_fd_(NULL),
nss_bufs_(NULL),
@@ -575,14 +574,10 @@ int SSLClientSocketNSS::Connect(CompletionCallback* callback) {
return rv;
}
- // Attempt to initialize the peer name. In the case of TCP FastOpen,
- // we don't have the peer yet.
- if (!UsingTCPFastOpen()) {
- rv = InitializeSSLPeerName();
- if (rv != OK) {
- net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv);
- return rv;
- }
+ rv = InitializeSSLPeerName();
+ if (rv != OK) {
+ net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv);
+ return rv;
}
if (ssl_config_.cached_info_enabled && ssl_host_info_.get()) {
@@ -640,7 +635,6 @@ void SSLClientSocketNSS::Disconnect() {
eset_mitm_detected_ = false;
start_cert_verification_time_ = base::TimeTicks();
predicted_cert_chain_correct_ = false;
- peername_initialized_ = false;
nss_bufs_ = NULL;
client_certs_.clear();
client_auth_cert_needed_ = false;
@@ -967,7 +961,7 @@ int SSLClientSocketNSS::InitializeSSLOptions() {
SSL_SetURL(nss_fd_, host_and_port_.host().c_str());
// Tell SSL we're a client; needed if not letting NSPR do socket I/O
- SSL_ResetHandshake(nss_fd_, 0);
+ SSL_ResetHandshake(nss_fd_, PR_FALSE);
return OK;
}
@@ -1004,7 +998,6 @@ int SSLClientSocketNSS::InitializeSSLPeerName() {
if (rv != SECSuccess)
LogFailedNSSFunction(net_log_, "SSL_SetSockPeerID", peer_id.c_str());
- peername_initialized_ = true;
return OK;
}
@@ -1755,11 +1748,6 @@ int SSLClientSocketNSS::BufferSend(void) {
void SSLClientSocketNSS::BufferSendComplete(int result) {
EnterFunction(result);
-
- // In the case of TCP FastOpen, connect is now finished.
- if (!peername_initialized_ && UsingTCPFastOpen())
- InitializeSSLPeerName();
-
memio_PutWriteResult(nss_bufs_, MapErrorToNSS(result));
transport_send_busy_ = false;
OnSendComplete(result);
diff --git a/net/socket/ssl_client_socket_nss.h b/net/socket/ssl_client_socket_nss.h
index c6fffc4..1c5d80e 100644
--- a/net/socket/ssl_client_socket_nss.h
+++ b/net/socket/ssl_client_socket_nss.h
@@ -226,9 +226,6 @@ class SSLClientSocketNSS : public SSLClientSocket {
// that we found the prediction to be correct.
bool predicted_cert_chain_correct_;
- // True if the peer name has been initialized.
- bool peername_initialized_;
-
// The time when we started waiting for DNSSEC records.
base::Time dnssec_wait_start_time_;
diff --git a/net/socket/tcp_client_socket_libevent.cc b/net/socket/tcp_client_socket_libevent.cc
index 8540342..38c3446 100644
--- a/net/socket/tcp_client_socket_libevent.cc
+++ b/net/socket/tcp_client_socket_libevent.cc
@@ -384,6 +384,15 @@ bool TCPClientSocketLibevent::IsConnected() const {
if (socket_ == kInvalidSocket || waiting_connect())
return false;
+ if (use_tcp_fastopen_ && !tcp_fastopen_connected_) {
+ // With TCP FastOpen, we pretend that the socket is connected.
+ // This allows GetPeerAddress() to return current_ai_ as the peer
+ // address. Since we don't fail over to the next address if
+ // sendto() fails, current_ai_ is the only possible peer address.
+ CHECK(current_ai_);
+ return true;
+ }
+
// Check if connection is alive.
char c;
int rv = HANDLE_EINTR(recv(socket_, &c, 1, MSG_PEEK));
@@ -401,6 +410,9 @@ bool TCPClientSocketLibevent::IsConnectedAndIdle() const {
if (socket_ == kInvalidSocket || waiting_connect())
return false;
+ // TODO(wtc): should we also handle the TCP FastOpen case here,
+ // as we do in IsConnected()?
+
// Check if connection is alive and we haven't received any data
// unexpectedly.
char c;