| Index: net/tools/quic/quic_client.cc
|
| diff --git a/net/tools/quic/quic_client.cc b/net/tools/quic/quic_client.cc
|
| index f0aee5bc9aefe0406ed4d61873e0c45178d0d8d4..ec5e4e0bcb918f5e04f8c44f734267282a4a95ee 100644
|
| --- a/net/tools/quic/quic_client.cc
|
| +++ b/net/tools/quic/quic_client.cc
|
| @@ -74,6 +74,7 @@ QuicClient::QuicClient(IPEndPoint server_address,
|
| initialized_(false),
|
| packets_dropped_(0),
|
| overflow_supported_(false),
|
| + use_recvmmsg_(false),
|
| store_response_(false),
|
| latest_response_code_(-1),
|
| packet_reader_(CreateQuicPacketReader()) {}
|
| @@ -93,6 +94,14 @@ QuicClient::~QuicClient() {
|
| bool QuicClient::Initialize() {
|
| QuicClientBase::Initialize();
|
|
|
| +#if MMSG_MORE
|
| + use_recvmmsg_ = true;
|
| +#endif
|
| +
|
| + set_num_sent_client_hellos(0);
|
| + set_num_stateless_rejects_received(0);
|
| + set_connection_error(QUIC_NO_ERROR);
|
| +
|
| // If an initial flow control window has not explicitly been set, then use the
|
| // same values that Chrome uses.
|
| const uint32_t kSessionMaxRecvWindowSize = 15 * 1024 * 1024; // 15 MB
|
| @@ -385,15 +394,16 @@ void QuicClient::OnEvent(int fd, EpollEvent* event) {
|
| DCHECK_EQ(fd, GetLatestFD());
|
|
|
| if (event->in_events & EPOLLIN) {
|
| - while (connected()) {
|
| - if (
|
| -#if MMSG_MORE
|
| - !ReadAndProcessPackets()
|
| -#else
|
| - !ReadAndProcessPacket()
|
| -#endif
|
| - ) {
|
| - break;
|
| + bool more_to_read = true;
|
| + while (connected() && more_to_read) {
|
| + if (use_recvmmsg_) {
|
| + more_to_read = packet_reader_->ReadAndDispatchPackets(
|
| + GetLatestFD(), QuicClient::GetLatestClientAddress().port(), this,
|
| + overflow_supported_ ? &packets_dropped_ : nullptr);
|
| + } else {
|
| + more_to_read = QuicPacketReader::ReadAndDispatchSinglePacket(
|
| + GetLatestFD(), QuicClient::GetLatestClientAddress().port(), this,
|
| + overflow_supported_ ? &packets_dropped_ : nullptr);
|
| }
|
| }
|
| }
|
| @@ -470,44 +480,8 @@ QuicPacketWriter* QuicClient::CreateQuicPacketWriter() {
|
| }
|
|
|
| QuicPacketReader* QuicClient::CreateQuicPacketReader() {
|
| - // TODO(rtenneti): Add support for QuicPacketReader.
|
| - // return new QuicPacketReader();
|
| - return nullptr;
|
| -}
|
| -
|
| -bool QuicClient::ReadAndProcessPacket() {
|
| - // Allocate some extra space so we can send an error if the server goes over
|
| - // the limit.
|
| - char buf[2 * kMaxPacketSize];
|
| -
|
| - IPEndPoint server_address;
|
| - IPAddress client_ip;
|
| -
|
| - int bytes_read = QuicSocketUtils::ReadPacket(
|
| - GetLatestFD(), buf, arraysize(buf),
|
| - overflow_supported_ ? &packets_dropped_ : nullptr, &client_ip,
|
| - &server_address);
|
| -
|
| - if (bytes_read < 0) {
|
| - return false;
|
| - }
|
| -
|
| - QuicEncryptedPacket packet(buf, bytes_read, false);
|
| -
|
| - IPEndPoint client_address(client_ip,
|
| - QuicClient::GetLatestClientAddress().port());
|
| -
|
| - session()->ProcessUdpPacket(client_address, server_address, packet);
|
| - return true;
|
| -}
|
| -
|
| -/*
|
| -bool QuicClient::ReadAndProcessPackets() {
|
| - return packet_reader_->ReadAndDispatchPackets(
|
| - GetLatestFD(), QuicClient::GetLatestClientAddress().port(), this,
|
| - overflow_supported_ ? &packets_dropped_ : nullptr);
|
| + return new QuicPacketReader();
|
| }
|
| -*/
|
|
|
| const IPEndPoint QuicClient::GetLatestClientAddress() const {
|
| if (fd_address_map_.empty()) {
|
|
|