diff options
-rw-r--r-- | net/tools/quic/quic_simple_client.cc | 13 | ||||
-rw-r--r-- | net/tools/quic/quic_simple_client.h | 4 |
2 files changed, 15 insertions, 2 deletions
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<QuicPacketReader> packet_reader_; + bool packet_reader_started_; + base::WeakPtrFactory<QuicSimpleClient> weak_factory_; DISALLOW_COPY_AND_ASSIGN(QuicSimpleClient); |