| 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_server.h" | 5 #include "net/tools/quic/quic_server.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <features.h> | 8 #include <features.h> |
| 9 #include <netinet/in.h> | 9 #include <netinet/in.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| 11 #include <sys/epoll.h> | 11 #include <sys/epoll.h> |
| 12 #include <sys/socket.h> | 12 #include <sys/socket.h> |
| 13 | 13 |
| 14 #include "net/base/ip_endpoint.h" | 14 #include "net/base/ip_endpoint.h" |
| 15 #include "net/base/sockaddr_storage.h" | 15 #include "net/base/sockaddr_storage.h" |
| 16 #include "net/quic/crypto/crypto_handshake.h" | 16 #include "net/quic/crypto/crypto_handshake.h" |
| 17 #include "net/quic/crypto/quic_random.h" | 17 #include "net/quic/crypto/quic_random.h" |
| 18 #include "net/quic/quic_clock.h" | 18 #include "net/quic/quic_clock.h" |
| 19 #include "net/quic/quic_crypto_stream.h" | 19 #include "net/quic/quic_crypto_stream.h" |
| 20 #include "net/quic/quic_data_reader.h" | 20 #include "net/quic/quic_data_reader.h" |
| 21 #include "net/quic/quic_protocol.h" | 21 #include "net/quic/quic_protocol.h" |
| 22 #include "net/tools/quic/quic_dispatcher.h" | 22 #include "net/tools/quic/quic_dispatcher.h" |
| 23 #include "net/tools/quic/quic_epoll_alarm_factory.h" |
| 23 #include "net/tools/quic/quic_epoll_clock.h" | 24 #include "net/tools/quic/quic_epoll_clock.h" |
| 24 #include "net/tools/quic/quic_epoll_connection_helper.h" | 25 #include "net/tools/quic/quic_epoll_connection_helper.h" |
| 25 #include "net/tools/quic/quic_in_memory_cache.h" | 26 #include "net/tools/quic/quic_in_memory_cache.h" |
| 26 #include "net/tools/quic/quic_packet_reader.h" | 27 #include "net/tools/quic/quic_packet_reader.h" |
| 27 #include "net/tools/quic/quic_socket_utils.h" | 28 #include "net/tools/quic/quic_socket_utils.h" |
| 28 | 29 |
| 29 #ifndef SO_RXQ_OVFL | 30 #ifndef SO_RXQ_OVFL |
| 30 #define SO_RXQ_OVFL 40 | 31 #define SO_RXQ_OVFL 40 |
| 31 #endif | 32 #endif |
| 32 | 33 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 dispatcher_->InitializeWithWriter(CreateWriter(fd_)); | 136 dispatcher_->InitializeWithWriter(CreateWriter(fd_)); |
| 136 | 137 |
| 137 return true; | 138 return true; |
| 138 } | 139 } |
| 139 | 140 |
| 140 QuicDefaultPacketWriter* QuicServer::CreateWriter(int fd) { | 141 QuicDefaultPacketWriter* QuicServer::CreateWriter(int fd) { |
| 141 return new QuicDefaultPacketWriter(fd); | 142 return new QuicDefaultPacketWriter(fd); |
| 142 } | 143 } |
| 143 | 144 |
| 144 QuicDispatcher* QuicServer::CreateQuicDispatcher() { | 145 QuicDispatcher* QuicServer::CreateQuicDispatcher() { |
| 145 return new QuicDispatcher(config_, &crypto_config_, supported_versions_, | 146 QuicEpollAlarmFactory alarm_factory(&epoll_server_); |
| 146 new QuicEpollConnectionHelper( | 147 return new QuicDispatcher( |
| 147 &epoll_server_, QuicAllocator::BUFFER_POOL)); | 148 config_, &crypto_config_, supported_versions_, |
| 149 std::unique_ptr<QuicEpollConnectionHelper>(new QuicEpollConnectionHelper( |
| 150 &epoll_server_, QuicAllocator::BUFFER_POOL)), |
| 151 std::unique_ptr<QuicEpollAlarmFactory>( |
| 152 new QuicEpollAlarmFactory(&epoll_server_))); |
| 148 } | 153 } |
| 149 | 154 |
| 150 void QuicServer::WaitForEvents() { | 155 void QuicServer::WaitForEvents() { |
| 151 epoll_server_.WaitForEventsAndExecuteCallbacks(); | 156 epoll_server_.WaitForEventsAndExecuteCallbacks(); |
| 152 } | 157 } |
| 153 | 158 |
| 154 void QuicServer::Shutdown() { | 159 void QuicServer::Shutdown() { |
| 155 // Before we shut down the epoll server, give all active sessions a chance to | 160 // Before we shut down the epoll server, give all active sessions a chance to |
| 156 // notify clients that they're closing. | 161 // notify clients that they're closing. |
| 157 dispatcher_->Shutdown(); | 162 dispatcher_->Shutdown(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 177 dispatcher_->OnCanWrite(); | 182 dispatcher_->OnCanWrite(); |
| 178 if (dispatcher_->HasPendingWrites()) { | 183 if (dispatcher_->HasPendingWrites()) { |
| 179 event->out_ready_mask |= EPOLLOUT; | 184 event->out_ready_mask |= EPOLLOUT; |
| 180 } | 185 } |
| 181 } | 186 } |
| 182 if (event->in_events & EPOLLERR) { | 187 if (event->in_events & EPOLLERR) { |
| 183 } | 188 } |
| 184 } | 189 } |
| 185 | 190 |
| 186 } // namespace net | 191 } // namespace net |
| OLD | NEW |