| 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 <memory> |
| 15 |
| 14 #include "net/base/ip_endpoint.h" | 16 #include "net/base/ip_endpoint.h" |
| 15 #include "net/base/sockaddr_storage.h" | 17 #include "net/base/sockaddr_storage.h" |
| 16 #include "net/quic/crypto/crypto_handshake.h" | 18 #include "net/quic/crypto/crypto_handshake.h" |
| 17 #include "net/quic/crypto/quic_random.h" | 19 #include "net/quic/crypto/quic_random.h" |
| 18 #include "net/quic/quic_clock.h" | 20 #include "net/quic/quic_clock.h" |
| 19 #include "net/quic/quic_crypto_stream.h" | 21 #include "net/quic/quic_crypto_stream.h" |
| 20 #include "net/quic/quic_data_reader.h" | 22 #include "net/quic/quic_data_reader.h" |
| 21 #include "net/quic/quic_protocol.h" | 23 #include "net/quic/quic_protocol.h" |
| 22 #include "net/tools/quic/quic_dispatcher.h" | 24 #include "net/tools/quic/quic_dispatcher.h" |
| 23 #include "net/tools/quic/quic_epoll_alarm_factory.h" | 25 #include "net/tools/quic/quic_epoll_alarm_factory.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 89 |
| 88 epoll_server_.set_timeout_in_us(50 * 1000); | 90 epoll_server_.set_timeout_in_us(50 * 1000); |
| 89 | 91 |
| 90 if (!FLAGS_quic_in_memory_cache_dir.empty()) { | 92 if (!FLAGS_quic_in_memory_cache_dir.empty()) { |
| 91 QuicInMemoryCache::GetInstance()->InitializeFromDirectory( | 93 QuicInMemoryCache::GetInstance()->InitializeFromDirectory( |
| 92 FLAGS_quic_in_memory_cache_dir); | 94 FLAGS_quic_in_memory_cache_dir); |
| 93 } | 95 } |
| 94 | 96 |
| 95 QuicEpollClock clock(&epoll_server_); | 97 QuicEpollClock clock(&epoll_server_); |
| 96 | 98 |
| 97 scoped_ptr<CryptoHandshakeMessage> scfg(crypto_config_.AddDefaultConfig( | 99 std::unique_ptr<CryptoHandshakeMessage> scfg(crypto_config_.AddDefaultConfig( |
| 98 QuicRandom::GetInstance(), &clock, crypto_config_options_)); | 100 QuicRandom::GetInstance(), &clock, crypto_config_options_)); |
| 99 } | 101 } |
| 100 | 102 |
| 101 QuicServer::~QuicServer() {} | 103 QuicServer::~QuicServer() {} |
| 102 | 104 |
| 103 bool QuicServer::CreateUDPSocketAndListen(const IPEndPoint& address) { | 105 bool QuicServer::CreateUDPSocketAndListen(const IPEndPoint& address) { |
| 104 fd_ = QuicSocketUtils::CreateUDPSocket(address, &overflow_supported_); | 106 fd_ = QuicSocketUtils::CreateUDPSocket(address, &overflow_supported_); |
| 105 if (fd_ < 0) { | 107 if (fd_ < 0) { |
| 106 LOG(ERROR) << "CreateSocket() failed: " << strerror(errno); | 108 LOG(ERROR) << "CreateSocket() failed: " << strerror(errno); |
| 107 return false; | 109 return false; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 dispatcher_->OnCanWrite(); | 184 dispatcher_->OnCanWrite(); |
| 183 if (dispatcher_->HasPendingWrites()) { | 185 if (dispatcher_->HasPendingWrites()) { |
| 184 event->out_ready_mask |= EPOLLOUT; | 186 event->out_ready_mask |= EPOLLOUT; |
| 185 } | 187 } |
| 186 } | 188 } |
| 187 if (event->in_events & EPOLLERR) { | 189 if (event->in_events & EPOLLERR) { |
| 188 } | 190 } |
| 189 } | 191 } |
| 190 | 192 |
| 191 } // namespace net | 193 } // namespace net |
| OLD | NEW |