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 #include "net/tools/quic/quic_dispatcher.h" | 5 #include "net/tools/quic/quic_dispatcher.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 | 8 |
9 #include "base/debug/stack_trace.h" | 9 #include "base/debug/stack_trace.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "net/quic/quic_blocked_writer_interface.h" | 12 #include "net/quic/quic_blocked_writer_interface.h" |
13 #include "net/quic/quic_flags.h" | 13 #include "net/quic/quic_flags.h" |
14 #include "net/quic/quic_utils.h" | 14 #include "net/quic/quic_utils.h" |
15 #include "net/tools/epoll_server/epoll_server.h" | 15 #include "net/tools/epoll_server/epoll_server.h" |
16 #include "net/tools/quic/quic_default_packet_writer.h" | 16 #include "net/tools/quic/quic_default_packet_writer.h" |
17 #include "net/tools/quic/quic_epoll_connection_helper.h" | 17 #include "net/tools/quic/quic_epoll_connection_helper.h" |
18 #include "net/tools/quic/quic_per_connection_packet_writer.h" | 18 #include "net/tools/quic/quic_per_connection_packet_writer.h" |
19 #include "net/tools/quic/quic_socket_utils.h" | 19 #include "net/tools/quic/quic_socket_utils.h" |
20 #include "net/tools/quic/quic_time_wait_list_manager.h" | 20 #include "net/tools/quic/quic_time_wait_list_manager.h" |
21 | 21 |
22 namespace net { | 22 namespace net { |
23 | 23 |
24 namespace tools { | 24 namespace tools { |
25 | 25 |
26 using base::StringPiece; | 26 using base::StringPiece; |
27 using std::make_pair; | |
28 | 27 |
29 class DeleteSessionsAlarm : public EpollAlarm { | 28 class DeleteSessionsAlarm : public EpollAlarm { |
30 public: | 29 public: |
31 explicit DeleteSessionsAlarm(QuicDispatcher* dispatcher) | 30 explicit DeleteSessionsAlarm(QuicDispatcher* dispatcher) |
32 : dispatcher_(dispatcher) { | 31 : dispatcher_(dispatcher) { |
33 } | 32 } |
34 | 33 |
35 int64 OnAlarm() override { | 34 int64 OnAlarm() override { |
36 EpollAlarm::OnAlarm(); | 35 EpollAlarm::OnAlarm(); |
37 dispatcher_->DeleteSessions(); | 36 dispatcher_->DeleteSessions(); |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 | 246 |
248 // Use the version in the packet if possible, otherwise assume the latest. | 247 // Use the version in the packet if possible, otherwise assume the latest. |
249 QuicVersion version = header.version_flag ? header.versions.front() : | 248 QuicVersion version = header.version_flag ? header.versions.front() : |
250 supported_versions_.front(); | 249 supported_versions_.front(); |
251 time_wait_list_manager_->AddConnectionIdToTimeWait(connection_id, version, | 250 time_wait_list_manager_->AddConnectionIdToTimeWait(connection_id, version, |
252 nullptr); | 251 nullptr); |
253 DCHECK(time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id)); | 252 DCHECK(time_wait_list_manager_->IsConnectionIdInTimeWait(connection_id)); |
254 return HandlePacketForTimeWait(header); | 253 return HandlePacketForTimeWait(header); |
255 } | 254 } |
256 DVLOG(1) << "Created new session for " << connection_id; | 255 DVLOG(1) << "Created new session for " << connection_id; |
257 session_map_.insert(make_pair(connection_id, session)); | 256 session_map_.insert(std::make_pair(connection_id, session)); |
258 } else { | 257 } else { |
259 session = it->second; | 258 session = it->second; |
260 } | 259 } |
261 | 260 |
262 session->connection()->ProcessUdpPacket( | 261 session->connection()->ProcessUdpPacket( |
263 current_server_address_, current_client_address_, *current_packet_); | 262 current_server_address_, current_client_address_, *current_packet_); |
264 | 263 |
265 // Do not parse the packet further. The session will process it completely. | 264 // Do not parse the packet further. The session will process it completely. |
266 return false; | 265 return false; |
267 } | 266 } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 | 344 |
346 void QuicDispatcher::OnWriteBlocked( | 345 void QuicDispatcher::OnWriteBlocked( |
347 QuicBlockedWriterInterface* blocked_writer) { | 346 QuicBlockedWriterInterface* blocked_writer) { |
348 if (!writer_->IsWriteBlocked()) { | 347 if (!writer_->IsWriteBlocked()) { |
349 LOG(DFATAL) << | 348 LOG(DFATAL) << |
350 "QuicDispatcher::OnWriteBlocked called when the writer is not blocked."; | 349 "QuicDispatcher::OnWriteBlocked called when the writer is not blocked."; |
351 // Return without adding the connection to the blocked list, to avoid | 350 // Return without adding the connection to the blocked list, to avoid |
352 // infinite loops in OnCanWrite. | 351 // infinite loops in OnCanWrite. |
353 return; | 352 return; |
354 } | 353 } |
355 write_blocked_list_.insert(make_pair(blocked_writer, true)); | 354 write_blocked_list_.insert(std::make_pair(blocked_writer, true)); |
356 } | 355 } |
357 | 356 |
358 void QuicDispatcher::OnConnectionAddedToTimeWaitList( | 357 void QuicDispatcher::OnConnectionAddedToTimeWaitList( |
359 QuicConnectionId connection_id) { | 358 QuicConnectionId connection_id) { |
360 DVLOG(1) << "Connection " << connection_id << " added to time wait list."; | 359 DVLOG(1) << "Connection " << connection_id << " added to time wait list."; |
361 } | 360 } |
362 | 361 |
363 void QuicDispatcher::OnConnectionRemovedFromTimeWaitList( | 362 void QuicDispatcher::OnConnectionRemovedFromTimeWaitList( |
364 QuicConnectionId connection_id) { | 363 QuicConnectionId connection_id) { |
365 DVLOG(1) << "Connection " << connection_id << " removed from time wait list."; | 364 DVLOG(1) << "Connection " << connection_id << " removed from time wait list."; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 framer_.set_version(time_wait_list_manager_->GetQuicVersionFromConnectionId( | 411 framer_.set_version(time_wait_list_manager_->GetQuicVersionFromConnectionId( |
413 header.connection_id)); | 412 header.connection_id)); |
414 | 413 |
415 // Continue parsing the packet to extract the sequence number. Then | 414 // Continue parsing the packet to extract the sequence number. Then |
416 // send it to the time wait manager in OnUnathenticatedHeader. | 415 // send it to the time wait manager in OnUnathenticatedHeader. |
417 return true; | 416 return true; |
418 } | 417 } |
419 | 418 |
420 } // namespace tools | 419 } // namespace tools |
421 } // namespace net | 420 } // namespace net |
OLD | NEW |