| 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 "net/base/ip_endpoint.h" |   14 #include "net/base/ip_endpoint.h" | 
|   15 #include "net/base/sockaddr_storage.h" |   15 #include "net/base/sockaddr_storage.h" | 
|   16 #include "net/quic/crypto/crypto_handshake.h" |   16 #include "net/quic/crypto/crypto_handshake.h" | 
|   17 #include "net/quic/crypto/quic_random.h" |   17 #include "net/quic/crypto/quic_random.h" | 
|   18 #include "net/quic/quic_clock.h" |   18 #include "net/quic/quic_clock.h" | 
|   19 #include "net/quic/quic_crypto_stream.h" |   19 #include "net/quic/quic_crypto_stream.h" | 
|   20 #include "net/quic/quic_data_reader.h" |   20 #include "net/quic/quic_data_reader.h" | 
|   21 #include "net/quic/quic_protocol.h" |   21 #include "net/quic/quic_protocol.h" | 
|   22 #include "net/tools/quic/quic_dispatcher.h" |   22 #include "net/tools/quic/quic_dispatcher.h" | 
 |   23 #include "net/tools/quic/quic_epoll_alarm_factory.h" | 
|   23 #include "net/tools/quic/quic_epoll_clock.h" |   24 #include "net/tools/quic/quic_epoll_clock.h" | 
|   24 #include "net/tools/quic/quic_epoll_connection_helper.h" |   25 #include "net/tools/quic/quic_epoll_connection_helper.h" | 
|   25 #include "net/tools/quic/quic_in_memory_cache.h" |   26 #include "net/tools/quic/quic_in_memory_cache.h" | 
|   26 #include "net/tools/quic/quic_packet_reader.h" |   27 #include "net/tools/quic/quic_packet_reader.h" | 
|   27 #include "net/tools/quic/quic_socket_utils.h" |   28 #include "net/tools/quic/quic_socket_utils.h" | 
|   28  |   29  | 
|   29 #ifndef SO_RXQ_OVFL |   30 #ifndef SO_RXQ_OVFL | 
|   30 #define SO_RXQ_OVFL 40 |   31 #define SO_RXQ_OVFL 40 | 
|   31 #endif |   32 #endif | 
|   32  |   33  | 
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  135   dispatcher_->InitializeWithWriter(CreateWriter(fd_)); |  136   dispatcher_->InitializeWithWriter(CreateWriter(fd_)); | 
|  136  |  137  | 
|  137   return true; |  138   return true; | 
|  138 } |  139 } | 
|  139  |  140  | 
|  140 QuicDefaultPacketWriter* QuicServer::CreateWriter(int fd) { |  141 QuicDefaultPacketWriter* QuicServer::CreateWriter(int fd) { | 
|  141   return new QuicDefaultPacketWriter(fd); |  142   return new QuicDefaultPacketWriter(fd); | 
|  142 } |  143 } | 
|  143  |  144  | 
|  144 QuicDispatcher* QuicServer::CreateQuicDispatcher() { |  145 QuicDispatcher* QuicServer::CreateQuicDispatcher() { | 
|  145   return new QuicDispatcher(config_, &crypto_config_, supported_versions_, |  146   return new QuicDispatcher( | 
|  146                             new QuicEpollConnectionHelper( |  147       config_, &crypto_config_, supported_versions_, | 
|  147                                 &epoll_server_, QuicAllocator::BUFFER_POOL)); |  148       new QuicEpollConnectionHelper(&epoll_server_, QuicAllocator::BUFFER_POOL), | 
 |  149       new QuicEpollAlarmFactory(&epoll_server_)); | 
|  148 } |  150 } | 
|  149  |  151  | 
|  150 void QuicServer::WaitForEvents() { |  152 void QuicServer::WaitForEvents() { | 
|  151   epoll_server_.WaitForEventsAndExecuteCallbacks(); |  153   epoll_server_.WaitForEventsAndExecuteCallbacks(); | 
|  152 } |  154 } | 
|  153  |  155  | 
|  154 void QuicServer::Shutdown() { |  156 void QuicServer::Shutdown() { | 
|  155   // Before we shut down the epoll server, give all active sessions a chance to |  157   // Before we shut down the epoll server, give all active sessions a chance to | 
|  156   // notify clients that they're closing. |  158   // notify clients that they're closing. | 
|  157   dispatcher_->Shutdown(); |  159   dispatcher_->Shutdown(); | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
|  177     dispatcher_->OnCanWrite(); |  179     dispatcher_->OnCanWrite(); | 
|  178     if (dispatcher_->HasPendingWrites()) { |  180     if (dispatcher_->HasPendingWrites()) { | 
|  179       event->out_ready_mask |= EPOLLOUT; |  181       event->out_ready_mask |= EPOLLOUT; | 
|  180     } |  182     } | 
|  181   } |  183   } | 
|  182   if (event->in_events & EPOLLERR) { |  184   if (event->in_events & EPOLLERR) { | 
|  183   } |  185   } | 
|  184 } |  186 } | 
|  185  |  187  | 
|  186 }  // namespace net |  188 }  // namespace net | 
| OLD | NEW |