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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 } | 103 } |
104 | 104 |
105 // Ensure the packet has a version negotiation bit set before creating a new | 105 // Ensure the packet has a version negotiation bit set before creating a new |
106 // session for it. All initial packets for a new connection are required to | 106 // session for it. All initial packets for a new connection are required to |
107 // have the flag set. Otherwise it may be a stray packet. | 107 // have the flag set. Otherwise it may be a stray packet. |
108 if (has_version_flag) { | 108 if (has_version_flag) { |
109 session = CreateQuicSession(guid, client_address); | 109 session = CreateQuicSession(guid, client_address); |
110 } | 110 } |
111 | 111 |
112 if (session == NULL) { | 112 if (session == NULL) { |
113 DLOG(INFO) << "Failed to create session for " << guid; | 113 DVLOG(0) << "Failed to create session for " << guid; |
114 // Add this guid fo the time-wait state, to safely reject future packets. | 114 // Add this guid fo the time-wait state, to safely reject future packets. |
115 // We don't know the version here, so assume latest. | 115 // We don't know the version here, so assume latest. |
116 // TODO(ianswett): Produce a no-version version negotiation packet. | 116 // TODO(ianswett): Produce a no-version version negotiation packet. |
117 time_wait_list_manager_->AddGuidToTimeWait(guid, | 117 time_wait_list_manager_->AddGuidToTimeWait(guid, |
118 supported_versions_.front(), | 118 supported_versions_.front(), |
119 NULL); | 119 NULL); |
120 time_wait_list_manager_->ProcessPacket(server_address, | 120 time_wait_list_manager_->ProcessPacket(server_address, |
121 client_address, | 121 client_address, |
122 guid, | 122 guid, |
123 packet); | 123 packet); |
124 return; | 124 return; |
125 } | 125 } |
126 DLOG(INFO) << "Created new session for " << guid; | 126 DVLOG(0) << "Created new session for " << guid; |
127 session_map_.insert(make_pair(guid, session)); | 127 session_map_.insert(make_pair(guid, session)); |
128 } else { | 128 } else { |
129 session = it->second; | 129 session = it->second; |
130 } | 130 } |
131 | 131 |
132 session->connection()->ProcessUdpPacket( | 132 session->connection()->ProcessUdpPacket( |
133 server_address, client_address, packet); | 133 server_address, client_address, packet); |
134 } | 134 } |
135 | 135 |
136 void QuicDispatcher::CleanUpSession(SessionMap::iterator it) { | 136 void QuicDispatcher::CleanUpSession(SessionMap::iterator it) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 } | 193 } |
194 | 194 |
195 void QuicDispatcher::OnConnectionClosed(QuicGuid guid, QuicErrorCode error) { | 195 void QuicDispatcher::OnConnectionClosed(QuicGuid guid, QuicErrorCode error) { |
196 SessionMap::iterator it = session_map_.find(guid); | 196 SessionMap::iterator it = session_map_.find(guid); |
197 if (it == session_map_.end()) { | 197 if (it == session_map_.end()) { |
198 LOG(DFATAL) << "GUID " << guid << " does not exist in the session map. " | 198 LOG(DFATAL) << "GUID " << guid << " does not exist in the session map. " |
199 << "Error: " << QuicUtils::ErrorToString(error); | 199 << "Error: " << QuicUtils::ErrorToString(error); |
200 return; | 200 return; |
201 } | 201 } |
202 | 202 |
203 DLOG_IF(INFO, error != QUIC_NO_ERROR) << "Closing connection (" << guid | 203 DVLOG_IF(0, error != QUIC_NO_ERROR) << "Closing connection (" << guid |
204 << ") due to error: " | 204 << ") due to error: " |
205 << QuicUtils::ErrorToString(error); | 205 << QuicUtils::ErrorToString(error); |
206 | 206 |
207 if (closed_session_list_.empty()) { | 207 if (closed_session_list_.empty()) { |
208 epoll_server_->RegisterAlarmApproximateDelta( | 208 epoll_server_->RegisterAlarmApproximateDelta( |
209 0, delete_sessions_alarm_.get()); | 209 0, delete_sessions_alarm_.get()); |
210 } | 210 } |
211 closed_session_list_.push_back(it->second); | 211 closed_session_list_.push_back(it->second); |
212 CleanUpSession(it); | 212 CleanUpSession(it); |
213 } | 213 } |
214 | 214 |
215 QuicSession* QuicDispatcher::CreateQuicSession( | 215 QuicSession* QuicDispatcher::CreateQuicSession( |
216 QuicGuid guid, | 216 QuicGuid guid, |
217 const IPEndPoint& client_address) { | 217 const IPEndPoint& client_address) { |
218 QuicServerSession* session = new QuicServerSession( | 218 QuicServerSession* session = new QuicServerSession( |
219 config_, new QuicConnection(guid, client_address, helper_.get(), this, | 219 config_, new QuicConnection(guid, client_address, helper_.get(), this, |
220 true, supported_versions_), this); | 220 true, supported_versions_), this); |
221 session->InitializeSession(crypto_config_); | 221 session->InitializeSession(crypto_config_); |
222 return session; | 222 return session; |
223 } | 223 } |
224 | 224 |
225 } // namespace tools | 225 } // namespace tools |
226 } // namespace net | 226 } // namespace net |
OLD | NEW |