| 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> |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 // Specifies the directory used during QuicInMemoryCache | 41 // Specifies the directory used during QuicInMemoryCache |
| 42 // construction to seed the cache. Cache directory can be | 42 // construction to seed the cache. Cache directory can be |
| 43 // generated using `wget -p --save-headers <url>` | 43 // generated using `wget -p --save-headers <url>` |
| 44 std::string FLAGS_quic_in_memory_cache_dir = ""; | 44 std::string FLAGS_quic_in_memory_cache_dir = ""; |
| 45 | 45 |
| 46 const int kEpollFlags = EPOLLIN | EPOLLOUT | EPOLLET; | 46 const int kEpollFlags = EPOLLIN | EPOLLOUT | EPOLLET; |
| 47 const char kSourceAddressTokenSecret[] = "secret"; | 47 const char kSourceAddressTokenSecret[] = "secret"; |
| 48 | 48 |
| 49 } // namespace | 49 } // namespace |
| 50 | 50 |
| 51 const size_t kNumSessionsToCreatePerSocketEvent = 16; |
| 52 |
| 51 QuicServer::QuicServer(std::unique_ptr<ProofSource> proof_source) | 53 QuicServer::QuicServer(std::unique_ptr<ProofSource> proof_source) |
| 52 : QuicServer(std::move(proof_source), | 54 : QuicServer(std::move(proof_source), |
| 53 QuicConfig(), | 55 QuicConfig(), |
| 54 QuicCryptoServerConfig::ConfigOptions(), | 56 QuicCryptoServerConfig::ConfigOptions(), |
| 55 AllSupportedVersions()) {} | 57 AllSupportedVersions()) {} |
| 56 | 58 |
| 57 QuicServer::QuicServer( | 59 QuicServer::QuicServer( |
| 58 std::unique_ptr<ProofSource> proof_source, | 60 std::unique_ptr<ProofSource> proof_source, |
| 59 const QuicConfig& config, | 61 const QuicConfig& config, |
| 60 const QuicCryptoServerConfig::ConfigOptions& crypto_config_options, | 62 const QuicCryptoServerConfig::ConfigOptions& crypto_config_options, |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 close(fd_); | 172 close(fd_); |
| 171 fd_ = -1; | 173 fd_ = -1; |
| 172 } | 174 } |
| 173 | 175 |
| 174 void QuicServer::OnEvent(int fd, EpollEvent* event) { | 176 void QuicServer::OnEvent(int fd, EpollEvent* event) { |
| 175 DCHECK_EQ(fd, fd_); | 177 DCHECK_EQ(fd, fd_); |
| 176 event->out_ready_mask = 0; | 178 event->out_ready_mask = 0; |
| 177 | 179 |
| 178 if (event->in_events & EPOLLIN) { | 180 if (event->in_events & EPOLLIN) { |
| 179 DVLOG(1) << "EPOLLIN"; | 181 DVLOG(1) << "EPOLLIN"; |
| 182 |
| 183 if (FLAGS_quic_limit_num_new_sessions_per_epoll_loop && |
| 184 FLAGS_quic_buffer_packet_till_chlo) { |
| 185 dispatcher_->ProcessBufferedChlos(kNumSessionsToCreatePerSocketEvent); |
| 186 } |
| 187 |
| 180 bool more_to_read = true; | 188 bool more_to_read = true; |
| 181 while (more_to_read) { | 189 while (more_to_read) { |
| 182 more_to_read = packet_reader_->ReadAndDispatchPackets( | 190 more_to_read = packet_reader_->ReadAndDispatchPackets( |
| 183 fd_, port_, false /* potentially_small_mtu */, | 191 fd_, port_, false /* potentially_small_mtu */, |
| 184 QuicEpollClock(&epoll_server_), dispatcher_.get(), | 192 QuicEpollClock(&epoll_server_), dispatcher_.get(), |
| 185 overflow_supported_ ? &packets_dropped_ : nullptr); | 193 overflow_supported_ ? &packets_dropped_ : nullptr); |
| 186 } | 194 } |
| 195 |
| 196 if (FLAGS_quic_limit_num_new_sessions_per_epoll_loop && |
| 197 FLAGS_quic_buffer_packet_till_chlo && dispatcher_->HasChlosBuffered()) { |
| 198 // Register EPOLLIN event to consume buffered CHLO(s). |
| 199 event->out_ready_mask |= EPOLLIN; |
| 200 } |
| 187 } | 201 } |
| 188 if (event->in_events & EPOLLOUT) { | 202 if (event->in_events & EPOLLOUT) { |
| 189 dispatcher_->OnCanWrite(); | 203 dispatcher_->OnCanWrite(); |
| 190 if (dispatcher_->HasPendingWrites()) { | 204 if (dispatcher_->HasPendingWrites()) { |
| 191 event->out_ready_mask |= EPOLLOUT; | 205 event->out_ready_mask |= EPOLLOUT; |
| 192 } | 206 } |
| 193 } | 207 } |
| 194 if (event->in_events & EPOLLERR) { | 208 if (event->in_events & EPOLLERR) { |
| 195 } | 209 } |
| 196 } | 210 } |
| 197 | 211 |
| 198 } // namespace net | 212 } // namespace net |
| OLD | NEW |