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

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

Issue 2629723003: Revert of Add quic_logging (Closed)
Patch Set: Created 3 years, 11 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_packet_reader.cc ('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 #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> 14 #include <memory>
15 15
16 #include "net/base/ip_endpoint.h" 16 #include "net/base/ip_endpoint.h"
17 #include "net/base/sockaddr_storage.h" 17 #include "net/base/sockaddr_storage.h"
18 #include "net/quic/core/crypto/crypto_handshake.h" 18 #include "net/quic/core/crypto/crypto_handshake.h"
19 #include "net/quic/core/crypto/quic_random.h" 19 #include "net/quic/core/crypto/quic_random.h"
20 #include "net/quic/core/quic_crypto_stream.h" 20 #include "net/quic/core/quic_crypto_stream.h"
21 #include "net/quic/core/quic_data_reader.h" 21 #include "net/quic/core/quic_data_reader.h"
22 #include "net/quic/core/quic_packets.h" 22 #include "net/quic/core/quic_packets.h"
23 #include "net/quic/platform/api/quic_logging.h"
24 #include "net/tools/quic/platform/impl/quic_epoll_clock.h" 23 #include "net/tools/quic/platform/impl/quic_epoll_clock.h"
25 #include "net/tools/quic/platform/impl/quic_socket_utils.h" 24 #include "net/tools/quic/platform/impl/quic_socket_utils.h"
26 #include "net/tools/quic/quic_dispatcher.h" 25 #include "net/tools/quic/quic_dispatcher.h"
27 #include "net/tools/quic/quic_epoll_alarm_factory.h" 26 #include "net/tools/quic/quic_epoll_alarm_factory.h"
28 #include "net/tools/quic/quic_epoll_connection_helper.h" 27 #include "net/tools/quic/quic_epoll_connection_helper.h"
29 #include "net/tools/quic/quic_http_response_cache.h" 28 #include "net/tools/quic/quic_http_response_cache.h"
30 #include "net/tools/quic/quic_packet_reader.h" 29 #include "net/tools/quic/quic_packet_reader.h"
31 #include "net/tools/quic/quic_simple_crypto_server_stream_helper.h" 30 #include "net/tools/quic/quic_simple_crypto_server_stream_helper.h"
32 #include "net/tools/quic/quic_simple_dispatcher.h" 31 #include "net/tools/quic/quic_simple_dispatcher.h"
33 32
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 bool QuicServer::CreateUDPSocketAndListen(const QuicSocketAddress& address) { 110 bool QuicServer::CreateUDPSocketAndListen(const QuicSocketAddress& address) {
112 fd_ = QuicSocketUtils::CreateUDPSocket(address, &overflow_supported_); 111 fd_ = QuicSocketUtils::CreateUDPSocket(address, &overflow_supported_);
113 if (fd_ < 0) { 112 if (fd_ < 0) {
114 LOG(ERROR) << "CreateSocket() failed: " << strerror(errno); 113 LOG(ERROR) << "CreateSocket() failed: " << strerror(errno);
115 return false; 114 return false;
116 } 115 }
117 116
118 sockaddr_storage addr = address.generic_address(); 117 sockaddr_storage addr = address.generic_address();
119 int rc = bind(fd_, reinterpret_cast<sockaddr*>(&addr), sizeof(addr)); 118 int rc = bind(fd_, reinterpret_cast<sockaddr*>(&addr), sizeof(addr));
120 if (rc < 0) { 119 if (rc < 0) {
121 QUIC_LOG(ERROR) << "Bind failed: " << strerror(errno); 120 LOG(ERROR) << "Bind failed: " << strerror(errno);
122 return false; 121 return false;
123 } 122 }
124 QUIC_LOG(INFO) << "Listening on " << address.ToString(); 123 LOG(INFO) << "Listening on " << address.ToString();
125 port_ = address.port(); 124 port_ = address.port();
126 if (port_ == 0) { 125 if (port_ == 0) {
127 QuicSocketAddress address; 126 QuicSocketAddress address;
128 if (address.FromSocket(fd_) != 0) { 127 if (address.FromSocket(fd_) != 0) {
129 QUIC_LOG(ERROR) << "Unable to get self address. Error: " 128 LOG(ERROR) << "Unable to get self address. Error: " << strerror(errno);
130 << strerror(errno);
131 } 129 }
132 port_ = address.port(); 130 port_ = address.port();
133 } 131 }
134 132
135 epoll_server_.RegisterFD(fd_, this, kEpollFlags); 133 epoll_server_.RegisterFD(fd_, this, kEpollFlags);
136 dispatcher_.reset(CreateQuicDispatcher()); 134 dispatcher_.reset(CreateQuicDispatcher());
137 dispatcher_->InitializeWithWriter(CreateWriter(fd_)); 135 dispatcher_->InitializeWithWriter(CreateWriter(fd_));
138 136
139 return true; 137 return true;
140 } 138 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 dispatcher_->OnCanWrite(); 195 dispatcher_->OnCanWrite();
198 if (dispatcher_->HasPendingWrites()) { 196 if (dispatcher_->HasPendingWrites()) {
199 event->out_ready_mask |= EPOLLOUT; 197 event->out_ready_mask |= EPOLLOUT;
200 } 198 }
201 } 199 }
202 if (event->in_events & EPOLLERR) { 200 if (event->in_events & EPOLLERR) {
203 } 201 }
204 } 202 }
205 203
206 } // namespace net 204 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_packet_reader.cc ('k') | net/tools/quic/quic_server_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698