Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: net/quic/core/quic_buffered_packet_store.h

Issue 2310543002: Limits only 16 new QUIC connections can be opened per epoll event. (Closed)
Patch Set: Limits only 16 new QUIC connections can be opened per epoll event. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | net/quic/core/quic_buffered_packet_store.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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 #ifndef NET_QUIC_QUIC_BUFFERED_PACKET_STORE_H_ 5 #ifndef NET_QUIC_QUIC_BUFFERED_PACKET_STORE_H_
6 #define NET_QUIC_QUIC_BUFFERED_PACKET_STORE_H_ 6 #define NET_QUIC_QUIC_BUFFERED_PACKET_STORE_H_
7 7
8 #include "net/base/ip_address.h" 8 #include "net/base/ip_address.h"
9 #include "net/base/linked_hash_map.h" 9 #include "net/base/linked_hash_map.h"
10 #include "net/quic/core/quic_alarm.h" 10 #include "net/quic/core/quic_alarm.h"
11 #include "net/quic/core/quic_alarm_factory.h" 11 #include "net/quic/core/quic_alarm_factory.h"
12 #include "net/quic/core/quic_clock.h" 12 #include "net/quic/core/quic_clock.h"
13 #include "net/quic/core/quic_protocol.h" 13 #include "net/quic/core/quic_protocol.h"
14 #include "net/quic/core/quic_time.h" 14 #include "net/quic/core/quic_time.h"
15 15
16 namespace net { 16 namespace net {
17 17
18 namespace test { 18 namespace test {
19 class QuicBufferedPacketStorePeer; 19 class QuicBufferedPacketStorePeer;
20 } // namespace test 20 } // namespace test
21 21
22 // This class buffers undeliverable packets for each connection until either 22 // This class buffers packets for each connection until either
23 // 1) They are requested to be delivered via DeliverPacket(), or 23 // 1) They are requested to be delivered via
24 // DeliverPacket()/DeliverPacketsForNextConnection(), or
24 // 2) They expire after exceeding their lifetime in the store. 25 // 2) They expire after exceeding their lifetime in the store.
26 //
27 // It can only buffer packets on certain number of connections. It has two pools
28 // of connections: connections with CHLO buffered and those without CHLO. The
29 // latter has its own upper limit along with the max number of connections this
30 // store can hold. The former pool can grow till this store is full.
25 class NET_EXPORT_PRIVATE QuicBufferedPacketStore { 31 class NET_EXPORT_PRIVATE QuicBufferedPacketStore {
26 public: 32 public:
27 enum EnqueuePacketResult { 33 enum EnqueuePacketResult {
28 SUCCESS = 0, 34 SUCCESS = 0,
29 TOO_MANY_PACKETS, // Too many packets stored up for a certain connection. 35 TOO_MANY_PACKETS, // Too many packets stored up for a certain connection.
30 TOO_MANY_CONNECTIONS // Too many connections stored up in the store. 36 TOO_MANY_CONNECTIONS // Too many connections stored up in the store.
31 }; 37 };
32 38
33 // A packets with client/server address. 39 // A packets with client/server address.
34 struct NET_EXPORT_PRIVATE BufferedPacket { 40 struct NET_EXPORT_PRIVATE BufferedPacket {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 QuicBufferedPacketStore(const QuicBufferedPacketStore&) = delete; 84 QuicBufferedPacketStore(const QuicBufferedPacketStore&) = delete;
79 85
80 ~QuicBufferedPacketStore(); 86 ~QuicBufferedPacketStore();
81 87
82 QuicBufferedPacketStore& operator=(const QuicBufferedPacketStore&) = delete; 88 QuicBufferedPacketStore& operator=(const QuicBufferedPacketStore&) = delete;
83 89
84 // Adds a copy of packet into packet queue for given connection. 90 // Adds a copy of packet into packet queue for given connection.
85 EnqueuePacketResult EnqueuePacket(QuicConnectionId connection_id, 91 EnqueuePacketResult EnqueuePacket(QuicConnectionId connection_id,
86 const QuicReceivedPacket& packet, 92 const QuicReceivedPacket& packet,
87 IPEndPoint server_address, 93 IPEndPoint server_address,
88 IPEndPoint client_address); 94 IPEndPoint client_address,
95 bool is_chlo);
89 96
90 // Returns true if there are any packets buffered for |connection_id|. 97 // Returns true if there are any packets buffered for |connection_id|.
91 bool HasBufferedPackets(QuicConnectionId connection_id) const; 98 bool HasBufferedPackets(QuicConnectionId connection_id) const;
92 99
93 // Returns the list of buffered packets for |connection_id| and removes them 100 // Returns the list of buffered packets for |connection_id| and removes them
94 // from the store. Returns an empty list if no early arrived packets for this 101 // from the store. Returns an empty list if no early arrived packets for this
95 // connection are present. 102 // connection are present.
96 std::list<BufferedPacket> DeliverPackets(QuicConnectionId connection_id); 103 std::list<BufferedPacket> DeliverPackets(QuicConnectionId connection_id);
97 104
98 // Examines how long packets have been buffered in the store for each 105 // Examines how long packets have been buffered in the store for each
99 // connection. If they stay too long, removes them for new coming packets and 106 // connection. If they stay too long, removes them for new coming packets and
100 // calls |visitor_|'s OnPotentialConnectionExpire(). 107 // calls |visitor_|'s OnPotentialConnectionExpire().
101 // Resets the alarm at the end. 108 // Resets the alarm at the end.
102 void OnExpirationTimeout(); 109 void OnExpirationTimeout();
103 110
111 // Delivers buffered packets for next connection with CHLO to open.
112 // Return connection id for next connection in |connection_id|
113 // and all buffered packets including CHLO.
114 // The returned std::list should at least has one packet(CHLO) if
115 // store does have any connection to open. If no connection in the store has
116 // received CHLO yet, empty std::list will be returned.
117 std::list<BufferedPacket> DeliverPacketsForNextConnection(
118 QuicConnectionId* connection_id);
119
120 // Is given connection already buffered in the store?
121 bool HasChloForConnection(QuicConnectionId connection_id);
122
123 // Is there any CHLO buffered in the store?
124 bool HasChlosBuffered() const;
125
104 private: 126 private:
105 friend class test::QuicBufferedPacketStorePeer; 127 friend class test::QuicBufferedPacketStorePeer;
106 128
107 // Set expiration alarm if it hasn't been set. 129 // Set expiration alarm if it hasn't been set.
108 void MaybeSetExpirationAlarm(); 130 void MaybeSetExpirationAlarm();
109 131
110 // Return true if number of connections in the store reaches maximum. 132 // Return true if add an extra packet will go beyond allowed max connection
111 bool IsFull(); 133 // limit. The limit for non-CHLO packet and CHLO packet is different.
134 bool ShouldBufferPacket(bool is_chlo);
112 135
113 // A map to store packet queues with creation time for each connection. 136 // A map to store packet queues with creation time for each connection.
114 BufferedPacketMap undecryptable_packets_; 137 BufferedPacketMap undecryptable_packets_;
115 138
116 // The max time the packets of a connection can be buffer in the store. 139 // The max time the packets of a connection can be buffer in the store.
117 QuicTime::Delta connection_life_span_; 140 QuicTime::Delta connection_life_span_;
118 141
119 VisitorInterface* visitor_; // Unowned. 142 VisitorInterface* visitor_; // Unowned.
120 143
121 const QuicClock* clock_; // Unowned. 144 const QuicClock* clock_; // Unowned.
122 145
123 // This alarm fires every |connection_life_span_| to clean up 146 // This alarm fires every |connection_life_span_| to clean up
124 // packets staying in the store for too long. 147 // packets staying in the store for too long.
125 std::unique_ptr<QuicAlarm> expiration_alarm_; 148 std::unique_ptr<QuicAlarm> expiration_alarm_;
149
150 // Keeps track of connection with CHLO buffered up already and the order they
151 // arrive.
152 linked_hash_map<QuicConnectionId, bool> connections_with_chlo_;
126 }; 153 };
127 154
128 } // namespace net 155 } // namespace net
129 156
130 #endif // NET_QUIC_QUIC_BUFFERED_PACKET_STORE_H_ 157 #endif // NET_QUIC_QUIC_BUFFERED_PACKET_STORE_H_
OLDNEW
« no previous file with comments | « no previous file | net/quic/core/quic_buffered_packet_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698