Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: net/tools/quic/quic_server.cc

Issue 999353005: Land Recent QUIC Changes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wrap Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/tools/quic/quic_server.h ('k') | net/tools/quic/quic_server_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
25 #include "net/tools/quic/quic_epoll_connection_helper.h"
24 #include "net/tools/quic/quic_in_memory_cache.h" 26 #include "net/tools/quic/quic_in_memory_cache.h"
25 #include "net/tools/quic/quic_packet_reader.h" 27 #include "net/tools/quic/quic_packet_reader.h"
26 #include "net/tools/quic/quic_socket_utils.h" 28 #include "net/tools/quic/quic_socket_utils.h"
27 29
28 // TODO(rtenneti): Add support for MMSG_MORE. 30 // TODO(rtenneti): Add support for MMSG_MORE.
29 #define MMSG_MORE 0 31 #define MMSG_MORE 0
30 // If true, QuicListener uses the QuicPacketReader to read packets instead of 32 // If true, QuicListener uses the QuicPacketReader to read packets instead of
31 // QuicServer. 33 // QuicServer.
32 // 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.
33 #define FLAGS_quic_use_optimized_packet_reader false 35 #define FLAGS_quic_use_optimized_packet_reader false
34 36
35 #ifndef SO_RXQ_OVFL 37 #ifndef SO_RXQ_OVFL
36 #define SO_RXQ_OVFL 40 38 #define SO_RXQ_OVFL 40
37 #endif 39 #endif
38 40
39 namespace net { 41 namespace net {
40 namespace tools { 42 namespace tools {
43 namespace {
41 44
42 namespace { 45 // Specifies the directory used during QuicInMemoryCache
46 // construction to seed the cache. Cache directory can be
47 // generated using `wget -p --save-headers <url>`
48 std::string FLAGS_quic_in_memory_cache_dir = "";
43 49
44 const PollBits kEpollFlags = PollBits(NET_POLLIN | NET_POLLOUT | NET_POLLET); 50 const PollBits kEpollFlags = PollBits(NET_POLLIN | NET_POLLOUT | NET_POLLET);
45 const char kSourceAddressTokenSecret[] = "secret"; 51 const char kSourceAddressTokenSecret[] = "secret";
46 52
47 } // namespace 53 } // namespace
48 54
49 QuicServer::QuicServer() 55 QuicServer::QuicServer()
50 : port_(0), 56 : port_(0),
51 fd_(-1), 57 fd_(-1),
52 packets_dropped_(0), 58 packets_dropped_(0),
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 config_.SetInitialStreamFlowControlWindowToSend( 92 config_.SetInitialStreamFlowControlWindowToSend(
87 kInitialStreamFlowControlWindow); 93 kInitialStreamFlowControlWindow);
88 } 94 }
89 if (config_.GetInitialSessionFlowControlWindowToSend() == 95 if (config_.GetInitialSessionFlowControlWindowToSend() ==
90 kMinimumFlowControlSendWindow) { 96 kMinimumFlowControlSendWindow) {
91 config_.SetInitialSessionFlowControlWindowToSend( 97 config_.SetInitialSessionFlowControlWindowToSend(
92 kInitialSessionFlowControlWindow); 98 kInitialSessionFlowControlWindow);
93 } 99 }
94 100
95 epoll_server_.set_timeout_in_us(50 * 1000); 101 epoll_server_.set_timeout_in_us(50 * 1000);
96 // Initialize the in memory cache now. 102
97 QuicInMemoryCache::GetInstance(); 103 if (!FLAGS_quic_in_memory_cache_dir.empty()) {
104 QuicInMemoryCache::GetInstance()->InitializeFromDirectory(
105 FLAGS_quic_in_memory_cache_dir);
106 }
98 107
99 QuicEpollClock clock(&epoll_server_); 108 QuicEpollClock clock(&epoll_server_);
100 109
101 scoped_ptr<CryptoHandshakeMessage> scfg( 110 scoped_ptr<CryptoHandshakeMessage> scfg(
102 crypto_config_.AddDefaultConfig( 111 crypto_config_.AddDefaultConfig(
103 QuicRandom::GetInstance(), &clock, 112 QuicRandom::GetInstance(), &clock,
104 QuicCryptoServerConfig::ConfigOptions())); 113 QuicCryptoServerConfig::ConfigOptions()));
105 } 114 }
106 115
107 QuicServer::~QuicServer() { 116 QuicServer::~QuicServer() {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 187
179 return true; 188 return true;
180 } 189 }
181 190
182 QuicDispatcher* QuicServer::CreateQuicDispatcher() { 191 QuicDispatcher* QuicServer::CreateQuicDispatcher() {
183 return new QuicDispatcher( 192 return new QuicDispatcher(
184 config_, 193 config_,
185 crypto_config_, 194 crypto_config_,
186 supported_versions_, 195 supported_versions_,
187 new QuicDispatcher::DefaultPacketWriterFactory(), 196 new QuicDispatcher::DefaultPacketWriterFactory(),
188 &epoll_server_); 197 new QuicEpollConnectionHelper(&epoll_server_));
189 } 198 }
190 199
191 void QuicServer::WaitForEvents() { 200 void QuicServer::WaitForEvents() {
192 epoll_server_.WaitForEventsAndExecuteCallbacks(); 201 epoll_server_.WaitForEventsAndExecuteCallbacks();
193 } 202 }
194 203
195 void QuicServer::Shutdown() { 204 void QuicServer::Shutdown() {
196 // Before we shut down the epoll server, give all active sessions a chance to 205 // Before we shut down the epoll server, give all active sessions a chance to
197 // notify clients that they're closing. 206 // notify clients that they're closing.
198 dispatcher_->Shutdown(); 207 dispatcher_->Shutdown();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 QuicEncryptedPacket packet(buf, bytes_read, false); 281 QuicEncryptedPacket packet(buf, bytes_read, false);
273 282
274 IPEndPoint server_address(server_ip, port); 283 IPEndPoint server_address(server_ip, port);
275 processor->ProcessPacket(server_address, client_address, packet); 284 processor->ProcessPacket(server_address, client_address, packet);
276 285
277 return true; 286 return true;
278 } 287 }
279 288
280 } // namespace tools 289 } // namespace tools
281 } // namespace net 290 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_server.h ('k') | net/tools/quic/quic_server_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698