OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Handles packets for guids in time wait state by discarding the packet and | 5 // Handles packets for guids in time wait state by discarding the packet and |
6 // sending the clients a public reset packet with exponential backoff. | 6 // sending the clients a public reset packet with exponential backoff. |
7 | 7 |
8 #ifndef NET_TOOLS_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_ | 8 #ifndef NET_TOOLS_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_ |
9 #define NET_TOOLS_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_ | 9 #define NET_TOOLS_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_ |
10 | 10 |
11 #include <deque> | 11 #include <deque> |
12 | 12 |
| 13 #include "base/basictypes.h" |
13 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
14 #include "base/strings/string_piece.h" | 15 #include "base/strings/string_piece.h" |
15 #include "net/quic/quic_blocked_writer_interface.h" | 16 #include "net/quic/quic_blocked_writer_interface.h" |
16 #include "net/quic/quic_framer.h" | 17 #include "net/quic/quic_framer.h" |
17 #include "net/quic/quic_packet_writer.h" | 18 #include "net/quic/quic_packet_writer.h" |
18 #include "net/quic/quic_protocol.h" | 19 #include "net/quic/quic_protocol.h" |
19 #include "net/tools/epoll_server/epoll_server.h" | 20 #include "net/tools/epoll_server/epoll_server.h" |
20 #include "net/tools/quic/quic_epoll_clock.h" | 21 #include "net/tools/quic/quic_epoll_clock.h" |
21 | 22 |
22 namespace net { | 23 namespace net { |
23 namespace tools { | 24 namespace tools { |
24 | 25 |
25 class GuidCleanUpAlarm; | 26 class GuidCleanUpAlarm; |
| 27 class QuicServerSessionVisitor; |
26 | 28 |
27 namespace test { | 29 namespace test { |
28 class QuicTimeWaitListManagerPeer; | 30 class QuicTimeWaitListManagerPeer; |
29 } // namespace test | 31 } // namespace test |
30 | 32 |
31 // Maintains a list of all guids that have been recently closed. A guid lives in | 33 // Maintains a list of all guids that have been recently closed. A guid lives in |
32 // this state for kTimeWaitPeriod. All packets received for guids in this state | 34 // this state for kTimeWaitPeriod. All packets received for guids in this state |
33 // are handed over to the QuicTimeWaitListManager by the QuicDispatcher. | 35 // are handed over to the QuicTimeWaitListManager by the QuicDispatcher. |
34 // Decides whether to send a public reset packet, a copy of the previously sent | 36 // Decides whether to send a public reset packet, a copy of the previously sent |
35 // connection close packet, or nothing to the client which sent a packet | 37 // connection close packet, or nothing to the client which sent a packet |
36 // with the guid in time wait state. After the guid expires its time wait | 38 // with the guid in time wait state. After the guid expires its time wait |
37 // period, a new connection/session will be created if a packet is received | 39 // period, a new connection/session will be created if a packet is received |
38 // for this guid. | 40 // for this guid. |
39 class QuicTimeWaitListManager : public QuicBlockedWriterInterface { | 41 class QuicTimeWaitListManager : public QuicBlockedWriterInterface { |
40 public: | 42 public: |
41 // writer - the entity that writes to the socket. (Owned by the dispatcher) | 43 // writer - the entity that writes to the socket. (Owned by the dispatcher) |
| 44 // visitor - the entity that manages blocked writers. (The dispatcher) |
42 // epoll_server - used to run clean up alarms. (Owned by the dispatcher) | 45 // epoll_server - used to run clean up alarms. (Owned by the dispatcher) |
43 QuicTimeWaitListManager(QuicPacketWriter* writer, | 46 QuicTimeWaitListManager(QuicPacketWriter* writer, |
| 47 QuicServerSessionVisitor* visitor, |
44 EpollServer* epoll_server, | 48 EpollServer* epoll_server, |
45 const QuicVersionVector& supported_versions); | 49 const QuicVersionVector& supported_versions); |
46 virtual ~QuicTimeWaitListManager(); | 50 virtual ~QuicTimeWaitListManager(); |
47 | 51 |
48 // Adds the given guid to time wait state for kTimeWaitPeriod. Henceforth, | 52 // Adds the given guid to time wait state for kTimeWaitPeriod. Henceforth, |
49 // any packet bearing this guid should not be processed while the guid remains | 53 // any packet bearing this guid should not be processed while the guid remains |
50 // in this list. If a non-NULL |close_packet| is provided, it is sent again | 54 // in this list. If a non-NULL |close_packet| is provided, it is sent again |
51 // when packets are received for added guids. If NULL, a public reset packet | 55 // when packets are received for added guids. If NULL, a public reset packet |
52 // is sent with the specified |version|. DCHECKs that guid is not already on | 56 // is sent with the specified |version|. DCHECKs that guid is not already on |
53 // the list. | 57 // the list. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 134 |
131 // Maintains a list of GuidAddTime elements which it owns, in the | 135 // Maintains a list of GuidAddTime elements which it owns, in the |
132 // order they should be deleted. | 136 // order they should be deleted. |
133 std::deque<GuidAddTime*> time_ordered_guid_list_; | 137 std::deque<GuidAddTime*> time_ordered_guid_list_; |
134 | 138 |
135 // Pending public reset packets that need to be sent out to the client | 139 // Pending public reset packets that need to be sent out to the client |
136 // when we are given a chance to write by the dispatcher. | 140 // when we are given a chance to write by the dispatcher. |
137 std::deque<QueuedPacket*> pending_packets_queue_; | 141 std::deque<QueuedPacket*> pending_packets_queue_; |
138 | 142 |
139 // Used to schedule alarms to delete old guids which have been in the list for | 143 // Used to schedule alarms to delete old guids which have been in the list for |
140 // too long. Owned by the dispatcher. | 144 // too long. |
141 EpollServer* epoll_server_; | 145 EpollServer* epoll_server_; |
142 | 146 |
143 // Time period for which guids should remain in time wait state. | 147 // Time period for which guids should remain in time wait state. |
144 const QuicTime::Delta kTimeWaitPeriod_; | 148 const QuicTime::Delta kTimeWaitPeriod_; |
145 | 149 |
146 // Alarm registered with the epoll server to clean up guids that have out | 150 // Alarm registered with the epoll server to clean up guids that have out |
147 // lived their duration in time wait state. | 151 // lived their duration in time wait state. |
148 scoped_ptr<GuidCleanUpAlarm> guid_clean_up_alarm_; | 152 scoped_ptr<GuidCleanUpAlarm> guid_clean_up_alarm_; |
149 | 153 |
150 // Clock to efficiently measure approximate time from the epoll server. | 154 // Clock to efficiently measure approximate time from the epoll server. |
151 QuicEpollClock clock_; | 155 QuicEpollClock clock_; |
152 | 156 |
153 // Interface that writes given buffer to the socket. Owned by the dispatcher. | 157 // Interface that writes given buffer to the socket. |
154 QuicPacketWriter* writer_; | 158 QuicPacketWriter* writer_; |
155 | 159 |
| 160 // Interface that manages blocked writers. |
| 161 QuicServerSessionVisitor* visitor_; |
| 162 |
156 DISALLOW_COPY_AND_ASSIGN(QuicTimeWaitListManager); | 163 DISALLOW_COPY_AND_ASSIGN(QuicTimeWaitListManager); |
157 }; | 164 }; |
158 | 165 |
159 } // namespace tools | 166 } // namespace tools |
160 } // namespace net | 167 } // namespace net |
161 | 168 |
162 #endif // NET_TOOLS_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_ | 169 #endif // NET_TOOLS_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_ |
OLD | NEW |