diff options
Diffstat (limited to 'chromium/net/tools/quic/quic_server.cc')
-rw-r--r-- | chromium/net/tools/quic/quic_server.cc | 63 |
1 files changed, 35 insertions, 28 deletions
diff --git a/chromium/net/tools/quic/quic_server.cc b/chromium/net/tools/quic/quic_server.cc index a62cfbbdf15..be3d9fbd128 100644 --- a/chromium/net/tools/quic/quic_server.cc +++ b/chromium/net/tools/quic/quic_server.cc @@ -12,6 +12,7 @@ #include <sys/socket.h> #include "net/base/ip_endpoint.h" +#include "net/quic/congestion_control/tcp_receiver.h" #include "net/quic/crypto/crypto_handshake.h" #include "net/quic/crypto/quic_random.h" #include "net/quic/quic_clock.h" @@ -29,6 +30,7 @@ const int kEpollFlags = EPOLLIN | EPOLLOUT | EPOLLET; static const char kSourceAddressTokenSecret[] = "secret"; +const uint32 kServerInitialFlowControlWindow = 100 * net::kMaxPacketSize; namespace net { namespace tools { @@ -43,9 +45,6 @@ QuicServer::QuicServer() supported_versions_(QuicSupportedVersions()) { // Use hardcoded crypto parameters for now. config_.SetDefaults(); - config_.set_initial_round_trip_time_us(kMaxInitialRoundTripTimeUs, 0); - config_.set_server_initial_congestion_window(kMaxInitialWindow, - kDefaultInitialWindow); Initialize(); } @@ -76,6 +75,9 @@ void QuicServer::Initialize() { crypto_config_.AddDefaultConfig( QuicRandom::GetInstance(), &clock, QuicCryptoServerConfig::ConfigOptions())); + + // Set flow control options in the config. + config_.SetInitialCongestionWindowToSend(kServerInitialFlowControlWindow); } QuicServer::~QuicServer() { @@ -107,6 +109,19 @@ bool QuicServer::Listen(const IPEndPoint& address) { overflow_supported_ = true; } + // These send and receive buffer sizes are sized for a single connection, + // because the default usage of QuicServer is as a test server with one or + // two clients. Adjust higher for use with many clients. + if (!QuicSocketUtils::SetReceiveBufferSize(fd_, + TcpReceiver::kReceiveWindowTCP)) { + return false; + } + + if (!QuicSocketUtils::SetSendBufferSize(fd_, + TcpReceiver::kReceiveWindowTCP)) { + return false; + } + // Enable the socket option that allows the local address to be // returned if the socket is bound to more than on address. int get_local_ip = 1; @@ -133,7 +148,7 @@ bool QuicServer::Listen(const IPEndPoint& address) { return false; } - LOG(INFO) << "Listening on " << address.ToString(); + DVLOG(1) << "Listening on " << address.ToString(); if (port_ == 0) { SockaddrStorage storage; IPEndPoint server_address; @@ -143,17 +158,24 @@ bool QuicServer::Listen(const IPEndPoint& address) { return false; } port_ = server_address.port(); - LOG(INFO) << "Kernel assigned port is " << port_; + DVLOG(1) << "Kernel assigned port is " << port_; } epoll_server_.RegisterFD(fd_, this, kEpollFlags); - dispatcher_.reset(new QuicDispatcher(config_, crypto_config_, - supported_versions_, - fd_, &epoll_server_)); + dispatcher_.reset(CreateQuicDispatcher()); + dispatcher_->Initialize(fd_); return true; } +QuicDispatcher* QuicServer::CreateQuicDispatcher() { + return new QuicDispatcher( + config_, + crypto_config_, + supported_versions_, + &epoll_server_); +} + void QuicServer::WaitForEvents() { epoll_server_.WaitForEventsAndExecuteCallbacks(); } @@ -172,7 +194,7 @@ void QuicServer::OnEvent(int fd, EpollEvent* event) { event->out_ready_mask = 0; if (event->in_events & EPOLLIN) { - LOG(ERROR) << "EPOLLIN"; + DVLOG(1) << "EPOLLIN"; bool read = true; while (read) { read = ReadAndDispatchSinglePacket( @@ -181,8 +203,8 @@ void QuicServer::OnEvent(int fd, EpollEvent* event) { } } if (event->in_events & EPOLLOUT) { - bool can_write_more = dispatcher_->OnCanWrite(); - if (can_write_more) { + dispatcher_->OnCanWrite(); + if (dispatcher_->HasPendingWrites()) { event->out_ready_mask |= EPOLLOUT; } } @@ -191,25 +213,10 @@ void QuicServer::OnEvent(int fd, EpollEvent* event) { } /* static */ -void QuicServer::MaybeDispatchPacket(QuicDispatcher* dispatcher, - const QuicEncryptedPacket& packet, - const IPEndPoint& server_address, - const IPEndPoint& client_address) { - QuicGuid guid; - if (!QuicFramer::ReadGuidFromPacket(packet, &guid)) { - return; - } - - bool has_version_flag = QuicFramer::HasVersionFlag(packet); - - dispatcher->ProcessPacket( - server_address, client_address, guid, has_version_flag, packet); -} - bool QuicServer::ReadAndDispatchSinglePacket(int fd, int port, QuicDispatcher* dispatcher, - int* packets_dropped) { + uint32* packets_dropped) { // Allocate some extra space so we can send an error if the client goes over // the limit. char buf[2 * kMaxPacketSize]; @@ -228,7 +235,7 @@ bool QuicServer::ReadAndDispatchSinglePacket(int fd, QuicEncryptedPacket packet(buf, bytes_read, false); IPEndPoint server_address(server_ip, port); - MaybeDispatchPacket(dispatcher, packet, server_address, client_address); + dispatcher->ProcessPacket(server_address, client_address, packet); return true; } |