| 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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 client_address, | 87 client_address, |
| 88 guid, | 88 guid, |
| 89 packet); | 89 packet); |
| 90 return; | 90 return; |
| 91 } | 91 } |
| 92 session = CreateQuicSession(guid, client_address, fd_, epoll_server_); | 92 session = CreateQuicSession(guid, client_address, fd_, epoll_server_); |
| 93 | 93 |
| 94 if (session == NULL) { | 94 if (session == NULL) { |
| 95 DLOG(INFO) << "Failed to create session for " << guid; | 95 DLOG(INFO) << "Failed to create session for " << guid; |
| 96 // Add this guid fo the time-wait state, to safely nack future packets. | 96 // Add this guid fo the time-wait state, to safely nack future packets. |
| 97 time_wait_list_manager_->AddGuidToTimeWait(guid); | 97 // We don't know the version here, so assume latest. |
| 98 time_wait_list_manager_->AddGuidToTimeWait(guid, QuicVersionMax()); |
| 98 time_wait_list_manager_->ProcessPacket(server_address, | 99 time_wait_list_manager_->ProcessPacket(server_address, |
| 99 client_address, | 100 client_address, |
| 100 guid, | 101 guid, |
| 101 packet); | 102 packet); |
| 102 return; | 103 return; |
| 103 } | 104 } |
| 104 DLOG(INFO) << "Created new session for " << guid; | 105 DLOG(INFO) << "Created new session for " << guid; |
| 105 session_map_.insert(make_pair(guid, session)); | 106 session_map_.insert(make_pair(guid, session)); |
| 106 } else { | 107 } else { |
| 107 session = it->second; | 108 session = it->second; |
| 108 } | 109 } |
| 109 | 110 |
| 110 session->connection()->ProcessUdpPacket( | 111 session->connection()->ProcessUdpPacket( |
| 111 server_address, client_address, packet); | 112 server_address, client_address, packet); |
| 112 } | 113 } |
| 113 | 114 |
| 114 void QuicDispatcher::CleanUpSession(SessionMap::iterator it) { | 115 void QuicDispatcher::CleanUpSession(SessionMap::iterator it) { |
| 115 QuicSession* session = it->second; | 116 QuicSession* session = it->second; |
| 116 write_blocked_list_.RemoveBlockedObject(session->connection()); | 117 write_blocked_list_.RemoveBlockedObject(session->connection()); |
| 117 time_wait_list_manager_->AddGuidToTimeWait(it->first); | 118 time_wait_list_manager_->AddGuidToTimeWait(it->first, |
| 119 session->connection()->version()); |
| 118 session_map_.erase(it); | 120 session_map_.erase(it); |
| 119 } | 121 } |
| 120 | 122 |
| 121 void QuicDispatcher::DeleteSessions() { | 123 void QuicDispatcher::DeleteSessions() { |
| 122 STLDeleteElements(&closed_session_list_); | 124 STLDeleteElements(&closed_session_list_); |
| 123 } | 125 } |
| 124 | 126 |
| 125 bool QuicDispatcher::OnCanWrite() { | 127 bool QuicDispatcher::OnCanWrite() { |
| 126 // We got an EPOLLOUT: the socket should not be blocked. | 128 // We got an EPOLLOUT: the socket should not be blocked. |
| 127 write_blocked_ = false; | 129 write_blocked_ = false; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 } | 183 } |
| 182 | 184 |
| 183 QuicSession* QuicDispatcher::CreateQuicSession( | 185 QuicSession* QuicDispatcher::CreateQuicSession( |
| 184 QuicGuid guid, | 186 QuicGuid guid, |
| 185 const IPEndPoint& client_address, | 187 const IPEndPoint& client_address, |
| 186 int fd, | 188 int fd, |
| 187 EpollServer* epoll_server) { | 189 EpollServer* epoll_server) { |
| 188 QuicConnectionHelperInterface* helper = | 190 QuicConnectionHelperInterface* helper = |
| 189 new QuicEpollConnectionHelper(this, epoll_server); | 191 new QuicEpollConnectionHelper(this, epoll_server); |
| 190 QuicServerSession* session = new QuicServerSession( | 192 QuicServerSession* session = new QuicServerSession( |
| 191 config_, new QuicConnection(guid, client_address, helper, true), this); | 193 config_, new QuicConnection(guid, client_address, helper, true, |
| 194 QuicVersionMax()), this); |
| 192 session->InitializeSession(crypto_config_); | 195 session->InitializeSession(crypto_config_); |
| 193 return session; | 196 return session; |
| 194 } | 197 } |
| 195 | 198 |
| 196 } // namespace tools | 199 } // namespace tools |
| 197 } // namespace net | 200 } // namespace net |
| 198 | 201 |
| 199 | 202 |
| OLD | NEW |