| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/quic/quic_dispatcher.h" | 5 #include "net/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" |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 } | 285 } |
| 286 | 286 |
| 287 void QuicDispatcher::DeleteSessions() { | 287 void QuicDispatcher::DeleteSessions() { |
| 288 STLDeleteElements(&closed_session_list_); | 288 STLDeleteElements(&closed_session_list_); |
| 289 } | 289 } |
| 290 | 290 |
| 291 void QuicDispatcher::OnCanWrite() { | 291 void QuicDispatcher::OnCanWrite() { |
| 292 // We finished a write: the socket should not be blocked. | 292 // We finished a write: the socket should not be blocked. |
| 293 writer_->SetWritable(); | 293 writer_->SetWritable(); |
| 294 | 294 |
| 295 // Let all the blocked writers try to write, until we're blocked again or | 295 // Give all the blocked writers one chance to write, until we're blocked again |
| 296 // there's no work left. | 296 // or there's no work left. |
| 297 while (!write_blocked_list_.empty() && !writer_->IsWriteBlocked()) { | 297 while (!write_blocked_list_.empty() && !writer_->IsWriteBlocked()) { |
| 298 QuicBlockedWriterInterface* blocked_writer = | 298 QuicBlockedWriterInterface* blocked_writer = |
| 299 write_blocked_list_.begin()->first; | 299 write_blocked_list_.begin()->first; |
| 300 write_blocked_list_.erase(write_blocked_list_.begin()); | 300 write_blocked_list_.erase(write_blocked_list_.begin()); |
| 301 blocked_writer->OnCanWrite(); | 301 blocked_writer->OnCanWrite(); |
| 302 } | 302 } |
| 303 } | 303 } |
| 304 | 304 |
| 305 bool QuicDispatcher::HasPendingWrites() const { | 305 bool QuicDispatcher::HasPendingWrites() const { |
| 306 return !write_blocked_list_.empty(); | 306 return !write_blocked_list_.empty(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 330 << connection_id | 330 << connection_id |
| 331 << ") due to error: " | 331 << ") due to error: " |
| 332 << QuicUtils::ErrorToString(error); | 332 << QuicUtils::ErrorToString(error); |
| 333 if (closed_session_list_.empty()) { | 333 if (closed_session_list_.empty()) { |
| 334 delete_sessions_alarm_->Set(helper_->GetClock()->ApproximateNow()); | 334 delete_sessions_alarm_->Set(helper_->GetClock()->ApproximateNow()); |
| 335 } | 335 } |
| 336 closed_session_list_.push_back(it->second); | 336 closed_session_list_.push_back(it->second); |
| 337 CleanUpSession(it); | 337 CleanUpSession(it); |
| 338 } | 338 } |
| 339 | 339 |
| 340 void QuicDispatcher::OnWriteBlocked(QuicBlockedWriterInterface* writer) { | 340 void QuicDispatcher::OnWriteBlocked(QuicBlockedWriterInterface* blocked) { |
| 341 DCHECK(writer_->IsWriteBlocked()); | 341 if (!writer_->IsWriteBlocked()) { |
| 342 write_blocked_list_.insert(make_pair(writer, true)); | 342 LOG(DFATAL) << |
| 343 "QuicDispatcher::OnWriteBlocked called when the writer is not blocked."; |
| 344 // Return without adding the session to the blocked list, to avoid infinite |
| 345 // loops in OnCanWrite |
| 346 return; |
| 347 } |
| 348 write_blocked_list_.insert(make_pair(blocked, true)); |
| 343 } | 349 } |
| 344 | 350 |
| 345 QuicSession* QuicDispatcher::CreateQuicSession( | 351 QuicSession* QuicDispatcher::CreateQuicSession( |
| 346 QuicConnectionId connection_id, | 352 QuicConnectionId connection_id, |
| 347 const IPEndPoint& server_address, | 353 const IPEndPoint& server_address, |
| 348 const IPEndPoint& client_address) { | 354 const IPEndPoint& client_address) { |
| 349 QuicPerConnectionPacketWriter* per_connection_packet_writer = | 355 QuicPerConnectionPacketWriter* per_connection_packet_writer = |
| 350 new QuicPerConnectionPacketWriter(writer_.get()); | 356 new QuicPerConnectionPacketWriter(writer_.get()); |
| 351 QuicConnection* connection = | 357 QuicConnection* connection = |
| 352 CreateQuicConnection(connection_id, | 358 CreateQuicConnection(connection_id, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 // be parsed correctly. | 405 // be parsed correctly. |
| 400 framer_.set_version(time_wait_list_manager_->GetQuicVersionFromConnectionId( | 406 framer_.set_version(time_wait_list_manager_->GetQuicVersionFromConnectionId( |
| 401 header.connection_id)); | 407 header.connection_id)); |
| 402 | 408 |
| 403 // Continue parsing the packet to extract the sequence number. Then | 409 // Continue parsing the packet to extract the sequence number. Then |
| 404 // send it to the time wait manager in OnUnathenticatedHeader. | 410 // send it to the time wait manager in OnUnathenticatedHeader. |
| 405 return true; | 411 return true; |
| 406 } | 412 } |
| 407 | 413 |
| 408 } // namespace net | 414 } // namespace net |
| OLD | NEW |