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

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

Issue 47283002: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix compilation error Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « net/tools/quic/quic_server.h ('k') | net/tools/quic/quic_time_wait_list_manager.h » ('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 #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>
(...skipping 21 matching lines...) Expand all
32 32
33 namespace net { 33 namespace net {
34 namespace tools { 34 namespace tools {
35 35
36 QuicServer::QuicServer() 36 QuicServer::QuicServer()
37 : port_(0), 37 : port_(0),
38 fd_(-1), 38 fd_(-1),
39 packets_dropped_(0), 39 packets_dropped_(0),
40 overflow_supported_(false), 40 overflow_supported_(false),
41 use_recvmmsg_(false), 41 use_recvmmsg_(false),
42 crypto_config_(kSourceAddressTokenSecret, QuicRandom::GetInstance()) { 42 crypto_config_(kSourceAddressTokenSecret, QuicRandom::GetInstance()),
43 supported_versions_(QuicSupportedVersions()) {
43 // Use hardcoded crypto parameters for now. 44 // Use hardcoded crypto parameters for now.
44 config_.SetDefaults(); 45 config_.SetDefaults();
45 Initialize(); 46 Initialize();
46 } 47 }
47 48
48 QuicServer::QuicServer(const QuicConfig& config) 49 QuicServer::QuicServer(const QuicConfig& config,
50 const QuicVersionVector& supported_versions)
49 : port_(0), 51 : port_(0),
50 fd_(-1), 52 fd_(-1),
51 packets_dropped_(0), 53 packets_dropped_(0),
52 overflow_supported_(false), 54 overflow_supported_(false),
53 use_recvmmsg_(false), 55 use_recvmmsg_(false),
54 config_(config), 56 config_(config),
55 crypto_config_(kSourceAddressTokenSecret, QuicRandom::GetInstance()) { 57 crypto_config_(kSourceAddressTokenSecret, QuicRandom::GetInstance()),
58 supported_versions_(supported_versions) {
56 Initialize(); 59 Initialize();
57 } 60 }
58 61
59 void QuicServer::Initialize() { 62 void QuicServer::Initialize() {
60 #if MMSG_MORE 63 #if MMSG_MORE
61 use_recvmmsg_ = true; 64 use_recvmmsg_ = true;
62 #endif 65 #endif
63 epoll_server_.set_timeout_in_us(50 * 1000); 66 epoll_server_.set_timeout_in_us(50 * 1000);
64 // Initialize the in memory cache now. 67 // Initialize the in memory cache now.
65 QuicInMemoryCache::GetInstance(); 68 QuicInMemoryCache::GetInstance();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 if (getsockname(fd_, storage.addr, &storage.addr_len) != 0 || 137 if (getsockname(fd_, storage.addr, &storage.addr_len) != 0 ||
135 !server_address.FromSockAddr(storage.addr, storage.addr_len)) { 138 !server_address.FromSockAddr(storage.addr, storage.addr_len)) {
136 LOG(ERROR) << "Unable to get self address. Error: " << strerror(errno); 139 LOG(ERROR) << "Unable to get self address. Error: " << strerror(errno);
137 return false; 140 return false;
138 } 141 }
139 port_ = server_address.port(); 142 port_ = server_address.port();
140 LOG(INFO) << "Kernel assigned port is " << port_; 143 LOG(INFO) << "Kernel assigned port is " << port_;
141 } 144 }
142 145
143 epoll_server_.RegisterFD(fd_, this, kEpollFlags); 146 epoll_server_.RegisterFD(fd_, this, kEpollFlags);
144 dispatcher_.reset(new QuicDispatcher(config_, crypto_config_, fd_, 147 dispatcher_.reset(new QuicDispatcher(config_, crypto_config_,
145 &epoll_server_)); 148 supported_versions_,
149 fd_, &epoll_server_));
146 150
147 return true; 151 return true;
148 } 152 }
149 153
150 void QuicServer::WaitForEvents() { 154 void QuicServer::WaitForEvents() {
151 epoll_server_.WaitForEventsAndExecuteCallbacks(); 155 epoll_server_.WaitForEventsAndExecuteCallbacks();
152 } 156 }
153 157
154 void QuicServer::Shutdown() { 158 void QuicServer::Shutdown() {
155 // Before we shut down the epoll server, give all active sessions a chance to 159 // Before we shut down the epoll server, give all active sessions a chance to
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 QuicEncryptedPacket packet(buf, bytes_read, false); 222 QuicEncryptedPacket packet(buf, bytes_read, false);
219 223
220 IPEndPoint server_address(server_ip, port); 224 IPEndPoint server_address(server_ip, port);
221 MaybeDispatchPacket(dispatcher, packet, server_address, client_address); 225 MaybeDispatchPacket(dispatcher, packet, server_address, client_address);
222 226
223 return true; 227 return true;
224 } 228 }
225 229
226 } // namespace tools 230 } // namespace tools
227 } // namespace net 231 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_server.h ('k') | net/tools/quic/quic_time_wait_list_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698