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 #ifndef __APPLE__ | 8 #ifndef __APPLE__ |
9 // This is a GNU header that is not present in /usr/include on MacOS | 9 // This is a GNU header that is not present in /usr/include on MacOS |
10 #include <features.h> | 10 #include <features.h> |
11 #endif | 11 #endif |
12 #include <netinet/in.h> | 12 #include <netinet/in.h> |
13 #include <string.h> | 13 #include <string.h> |
14 #include <sys/socket.h> | 14 #include <sys/socket.h> |
15 | 15 |
16 #include "net/base/ip_endpoint.h" | 16 #include "net/base/ip_endpoint.h" |
17 #include "net/quic/crypto/crypto_handshake.h" | 17 #include "net/quic/crypto/crypto_handshake.h" |
18 #include "net/quic/crypto/quic_random.h" | 18 #include "net/quic/crypto/quic_random.h" |
19 #include "net/quic/quic_clock.h" | 19 #include "net/quic/quic_clock.h" |
20 #include "net/quic/quic_crypto_stream.h" | 20 #include "net/quic/quic_crypto_stream.h" |
21 #include "net/quic/quic_data_reader.h" | 21 #include "net/quic/quic_data_reader.h" |
22 #include "net/quic/quic_protocol.h" | 22 #include "net/quic/quic_protocol.h" |
23 #include "net/tools/quic/quic_dispatcher.h" | 23 #include "net/tools/quic/quic_dispatcher.h" |
24 #include "net/tools/quic/quic_epoll_clock.h" | 24 #include "net/tools/quic/quic_epoll_clock.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 // TODO(rtenneti): Add support for MMSG_MORE. | 30 // TODO(rtenneti): Add support for MMSG_MORE. |
30 #define MMSG_MORE 0 | 31 #define MMSG_MORE 0 |
31 // If true, QuicListener uses the QuicPacketReader to read packets instead of | 32 // If true, QuicListener uses the QuicPacketReader to read packets instead of |
32 // QuicServer. | 33 // QuicServer. |
33 // TODO(rtenneti): Enable this flag after MMSG_MORE is set to 1. | 34 // TODO(rtenneti): Enable this flag after MMSG_MORE is set to 1. |
34 #define FLAGS_quic_use_optimized_packet_reader false | 35 #define FLAGS_quic_use_optimized_packet_reader false |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 | 180 |
180 return true; | 181 return true; |
181 } | 182 } |
182 | 183 |
183 QuicDispatcher* QuicServer::CreateQuicDispatcher() { | 184 QuicDispatcher* QuicServer::CreateQuicDispatcher() { |
184 return new QuicDispatcher( | 185 return new QuicDispatcher( |
185 config_, | 186 config_, |
186 crypto_config_, | 187 crypto_config_, |
187 supported_versions_, | 188 supported_versions_, |
188 new QuicDispatcher::DefaultPacketWriterFactory(), | 189 new QuicDispatcher::DefaultPacketWriterFactory(), |
189 &epoll_server_); | 190 new QuicEpollConnectionHelper(&epoll_server_)); |
190 } | 191 } |
191 | 192 |
192 void QuicServer::WaitForEvents() { | 193 void QuicServer::WaitForEvents() { |
193 epoll_server_.WaitForEventsAndExecuteCallbacks(); | 194 epoll_server_.WaitForEventsAndExecuteCallbacks(); |
194 } | 195 } |
195 | 196 |
196 void QuicServer::Shutdown() { | 197 void QuicServer::Shutdown() { |
197 // Before we shut down the epoll server, give all active sessions a chance to | 198 // Before we shut down the epoll server, give all active sessions a chance to |
198 // notify clients that they're closing. | 199 // notify clients that they're closing. |
199 dispatcher_->Shutdown(); | 200 dispatcher_->Shutdown(); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 QuicEncryptedPacket packet(buf, bytes_read, false); | 274 QuicEncryptedPacket packet(buf, bytes_read, false); |
274 | 275 |
275 IPEndPoint server_address(server_ip, port); | 276 IPEndPoint server_address(server_ip, port); |
276 processor->ProcessPacket(server_address, client_address, packet); | 277 processor->ProcessPacket(server_address, client_address, packet); |
277 | 278 |
278 return true; | 279 return true; |
279 } | 280 } |
280 | 281 |
281 } // namespace tools | 282 } // namespace tools |
282 } // namespace net | 283 } // namespace net |
OLD | NEW |