From c40ba9f6df3d590a17389c646a3a89a82a186a48 Mon Sep 17 00:00:00 2001 From: rtenneti Date: Fri, 14 Aug 2015 13:47:47 -0700 Subject: QUIC - bug fix for quic_client - start the packet_reader if it is not started. Fix provided by Dmitry Adamushko . R=rch@chromium.org Review URL: https://codereview.chromium.org/1295853002 Cr-Commit-Position: refs/heads/master@{#343487} --- net/tools/quic/quic_simple_client.cc | 13 +++++++++++-- net/tools/quic/quic_simple_client.h | 4 ++++ 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'net') diff --git a/net/tools/quic/quic_simple_client.cc b/net/tools/quic/quic_simple_client.cc index e22eed9..261086b 100644 --- a/net/tools/quic/quic_simple_client.cc +++ b/net/tools/quic/quic_simple_client.cc @@ -43,8 +43,8 @@ QuicSimpleClient::QuicSimpleClient(IPEndPoint server_address, helper_(CreateQuicConnectionHelper()), initialized_(false), supported_versions_(supported_versions), - weak_factory_(this) { -} + packet_reader_started_(false), + weak_factory_(this) {} QuicSimpleClient::QuicSimpleClient(IPEndPoint server_address, const QuicServerId& server_id, @@ -62,6 +62,7 @@ QuicSimpleClient::QuicSimpleClient(IPEndPoint server_address, num_sent_client_hellos_(0), connection_error_(QUIC_NO_ERROR), connected_or_attempting_connect_(false), + packet_reader_started_(false), weak_factory_(this) {} QuicSimpleClient::~QuicSimpleClient() { @@ -166,12 +167,20 @@ bool QuicSimpleClient::CreateUDPSocket() { return true; } +void QuicSimpleClient::StartPacketReaderIfNotStarted() { + if (!packet_reader_started_) { + packet_reader_->StartReading(); + packet_reader_started_ = true; + } +} + bool QuicSimpleClient::Connect() { // Attempt multiple connects until the maximum number of client hellos have // been sent. while (!connected() && GetNumSentClientHellos() <= QuicCryptoClientStream::kMaxClientHellos) { StartConnect(); + StartPacketReaderIfNotStarted(); while (EncryptionBeingEstablished()) { WaitForEvents(); } diff --git a/net/tools/quic/quic_simple_client.h b/net/tools/quic/quic_simple_client.h index b8be29b..b94f8c2 100644 --- a/net/tools/quic/quic_simple_client.h +++ b/net/tools/quic/quic_simple_client.h @@ -314,6 +314,8 @@ class QuicSimpleClient : public QuicDataStream::Visitor, // Read a UDP packet and hand it to the framer. bool ReadAndProcessPacket(); + void StartPacketReaderIfNotStarted(); + // Used by |helper_| to time alarms. QuicClock clock_; @@ -419,6 +421,8 @@ class QuicSimpleClient : public QuicDataStream::Visitor, scoped_ptr packet_reader_; + bool packet_reader_started_; + base::WeakPtrFactory weak_factory_; DISALLOW_COPY_AND_ASSIGN(QuicSimpleClient); -- cgit v1.1