Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "net/socket/tcp_socket.h" | 5 #include "net/socket/tcp_socket.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <netinet/tcp.h> | 8 #include <netinet/tcp.h> |
| 9 #include <sys/socket.h> | 9 #include <sys/socket.h> |
| 10 | 10 |
| (...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 715 return; | 715 return; |
| 716 } | 716 } |
| 717 | 717 |
| 718 bool getsockopt_success = false; | 718 bool getsockopt_success = false; |
| 719 bool server_acked_data = false; | 719 bool server_acked_data = false; |
| 720 #if defined(TCP_INFO) | 720 #if defined(TCP_INFO) |
| 721 // Probe to see the if the socket used TCP FastOpen. | 721 // Probe to see the if the socket used TCP FastOpen. |
| 722 tcp_info info; | 722 tcp_info info; |
| 723 socklen_t info_len = sizeof(tcp_info); | 723 socklen_t info_len = sizeof(tcp_info); |
| 724 getsockopt_success = getsockopt(socket_->socket_fd(), IPPROTO_TCP, TCP_INFO, | 724 getsockopt_success = getsockopt(socket_->socket_fd(), IPPROTO_TCP, TCP_INFO, |
| 725 &info, &info_len) == 0 && | 725 &info, &info_len) == 0 && |
|
mmenke
2015/07/07 19:53:49
Can we just make this into a method?
It's a bit m
Bryan McQuade
2015/07/07 21:05:10
Done.
| |
| 726 info_len == sizeof(tcp_info); | 726 info_len == sizeof(tcp_info); |
| 727 server_acked_data = getsockopt_success && | 727 server_acked_data = getsockopt_success && |
| 728 (info.tcpi_options & TCPI_OPT_SYN_DATA); | 728 (info.tcpi_options & TCPI_OPT_SYN_DATA); |
| 729 #endif | 729 #endif |
| 730 | 730 |
| 731 if (getsockopt_success) { | 731 if (getsockopt_success) { |
| 732 if (tcp_fastopen_status_ == TCP_FASTOPEN_FAST_CONNECT_RETURN) { | 732 if (tcp_fastopen_status_ == TCP_FASTOPEN_FAST_CONNECT_RETURN) { |
| 733 tcp_fastopen_status_ = (server_acked_data ? | 733 tcp_fastopen_status_ = (server_acked_data ? |
| 734 TCP_FASTOPEN_SYN_DATA_ACK : | 734 TCP_FASTOPEN_SYN_DATA_ACK : |
| 735 TCP_FASTOPEN_SYN_DATA_NACK); | 735 TCP_FASTOPEN_SYN_DATA_NACK); |
| 736 } else { | 736 } else { |
| 737 tcp_fastopen_status_ = (server_acked_data ? | 737 tcp_fastopen_status_ = (server_acked_data ? |
| 738 TCP_FASTOPEN_NO_SYN_DATA_ACK : | 738 TCP_FASTOPEN_NO_SYN_DATA_ACK : |
| 739 TCP_FASTOPEN_NO_SYN_DATA_NACK); | 739 TCP_FASTOPEN_NO_SYN_DATA_NACK); |
| 740 } | 740 } |
| 741 } else { | 741 } else { |
| 742 tcp_fastopen_status_ = | 742 tcp_fastopen_status_ = |
| 743 (tcp_fastopen_status_ == TCP_FASTOPEN_FAST_CONNECT_RETURN ? | 743 (tcp_fastopen_status_ == TCP_FASTOPEN_FAST_CONNECT_RETURN ? |
| 744 TCP_FASTOPEN_SYN_DATA_GETSOCKOPT_FAILED : | 744 TCP_FASTOPEN_SYN_DATA_GETSOCKOPT_FAILED : |
| 745 TCP_FASTOPEN_NO_SYN_DATA_GETSOCKOPT_FAILED); | 745 TCP_FASTOPEN_NO_SYN_DATA_GETSOCKOPT_FAILED); |
| 746 } | 746 } |
| 747 } | 747 } |
| 748 | 748 |
| 749 bool TCPSocketLibevent::GetEstimatedRoundTripTime(base::TimeDelta* out_rtt) { | |
|
mmenke
2015/07/07 19:53:50
How do you intend to use this to inform future cod
Bryan McQuade
2015/07/07 21:03:33
I'm mostly interested in understanding TCP RTT in
| |
| 750 DCHECK(out_rtt); | |
| 751 if (!socket_ || !socket_->IsConnected()) { | |
|
mmenke
2015/07/07 19:53:50
The IsConnected() check seems concerning - if the
Bryan McQuade
2015/07/07 21:03:32
Yes, good point. I had added that to prevent loggi
| |
| 752 return false; | |
| 753 } | |
|
mmenke
2015/07/07 19:53:49
nit: Remove braces.
Bryan McQuade
2015/07/07 21:03:33
Done.
| |
| 754 | |
| 755 bool success = false; | |
| 756 #if defined(TCP_INFO) | |
| 757 tcp_info info; | |
| 758 socklen_t info_len = sizeof(tcp_info); | |
| 759 success = getsockopt(socket_->socket_fd(), IPPROTO_TCP, TCP_INFO, &info, | |
| 760 &info_len) == 0 && | |
| 761 info_len == sizeof(tcp_info); | |
| 762 if (success) { | |
| 763 *out_rtt = base::TimeDelta::FromMicroseconds(info.tcpi_rtt); | |
|
mmenke
2015/07/07 19:53:49
Suggest getting rid of success variable, and just
Bryan McQuade
2015/07/07 21:03:33
Done.
| |
| 764 } | |
|
mmenke
2015/07/07 19:53:50
nit: Remove braces.
Bryan McQuade
2015/07/07 21:03:32
Done.
| |
| 765 #endif | |
|
mmenke
2015/07/07 19:53:49
nit: #endif // defined(TCP_INFO)
(Not done in m
Bryan McQuade
2015/07/07 21:03:32
Done.
| |
| 766 | |
| 767 return success; | |
| 768 } | |
| 769 | |
| 749 } // namespace net | 770 } // namespace net |
| OLD | NEW |