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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 if (getsockname(fd_, storage.addr, &storage.addr_len) != 0 || | 140 if (getsockname(fd_, storage.addr, &storage.addr_len) != 0 || |
141 !server_address.FromSockAddr(storage.addr, storage.addr_len)) { | 141 !server_address.FromSockAddr(storage.addr, storage.addr_len)) { |
142 LOG(ERROR) << "Unable to get self address. Error: " << strerror(errno); | 142 LOG(ERROR) << "Unable to get self address. Error: " << strerror(errno); |
143 return false; | 143 return false; |
144 } | 144 } |
145 port_ = server_address.port(); | 145 port_ = server_address.port(); |
146 LOG(INFO) << "Kernel assigned port is " << port_; | 146 LOG(INFO) << "Kernel assigned port is " << port_; |
147 } | 147 } |
148 | 148 |
149 epoll_server_.RegisterFD(fd_, this, kEpollFlags); | 149 epoll_server_.RegisterFD(fd_, this, kEpollFlags); |
150 dispatcher_.reset(new QuicDispatcher(config_, crypto_config_, | 150 dispatcher_.reset(new QuicDispatcher( |
151 supported_versions_, | 151 config_, crypto_config_, supported_versions_, &epoll_server_)); |
152 fd_, &epoll_server_)); | 152 dispatcher_->Initialize(fd_); |
153 | 153 |
154 return true; | 154 return true; |
155 } | 155 } |
156 | 156 |
157 void QuicServer::WaitForEvents() { | 157 void QuicServer::WaitForEvents() { |
158 epoll_server_.WaitForEventsAndExecuteCallbacks(); | 158 epoll_server_.WaitForEventsAndExecuteCallbacks(); |
159 } | 159 } |
160 | 160 |
161 void QuicServer::Shutdown() { | 161 void QuicServer::Shutdown() { |
162 // Before we shut down the epoll server, give all active sessions a chance to | 162 // Before we shut down the epoll server, give all active sessions a chance to |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 QuicEncryptedPacket packet(buf, bytes_read, false); | 213 QuicEncryptedPacket packet(buf, bytes_read, false); |
214 | 214 |
215 IPEndPoint server_address(server_ip, port); | 215 IPEndPoint server_address(server_ip, port); |
216 dispatcher->ProcessPacket(server_address, client_address, packet); | 216 dispatcher->ProcessPacket(server_address, client_address, packet); |
217 | 217 |
218 return true; | 218 return true; |
219 } | 219 } |
220 | 220 |
221 } // namespace tools | 221 } // namespace tools |
222 } // namespace net | 222 } // namespace net |
OLD | NEW |