| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/epoll_server/epoll_server.h" | 5 #include "net/tools/epoll_server/epoll_server.h" |
| 6 | 6 |
| 7 #include <unistd.h> // For read, pipe, close and write. | 7 #include <unistd.h> // For read, pipe, close and write. |
| 8 #include <stdlib.h> // for abort | 8 #include <stdlib.h> // for abort |
| 9 #include <errno.h> // for errno and strerror_r | 9 #include <errno.h> // for errno and strerror_r |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 // ready_list_ will have all the new ready fds. | 53 // ready_list_ will have all the new ready fds. |
| 54 | 54 |
| 55 // The size we use for buffers passed to strerror_r | 55 // The size we use for buffers passed to strerror_r |
| 56 static const int kErrorBufferSize = 256; | 56 static const int kErrorBufferSize = 256; |
| 57 | 57 |
| 58 namespace net { | 58 namespace net { |
| 59 | 59 |
| 60 // Clears the pipe and returns. Used for waking the epoll server up. | 60 // Clears the pipe and returns. Used for waking the epoll server up. |
| 61 class ReadPipeCallback : public EpollCallbackInterface { | 61 class ReadPipeCallback : public EpollCallbackInterface { |
| 62 public: | 62 public: |
| 63 virtual void OnEvent(int fd, EpollEvent* event) OVERRIDE { | 63 virtual void OnEvent(int fd, EpollEvent* event) override { |
| 64 DCHECK(event->in_events == EPOLLIN); | 64 DCHECK(event->in_events == EPOLLIN); |
| 65 int data; | 65 int data; |
| 66 int data_read = 1; | 66 int data_read = 1; |
| 67 // Read until the pipe is empty. | 67 // Read until the pipe is empty. |
| 68 while (data_read > 0) { | 68 while (data_read > 0) { |
| 69 data_read = read(fd, &data, sizeof(data)); | 69 data_read = read(fd, &data, sizeof(data)); |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 virtual void OnShutdown(EpollServer *eps, int fd) OVERRIDE {} | 72 virtual void OnShutdown(EpollServer *eps, int fd) override {} |
| 73 virtual void OnRegistration(EpollServer*, int, int) OVERRIDE {} | 73 virtual void OnRegistration(EpollServer*, int, int) override {} |
| 74 virtual void OnModification(int, int) OVERRIDE {} // COV_NF_LINE | 74 virtual void OnModification(int, int) override {} // COV_NF_LINE |
| 75 virtual void OnUnregistration(int, bool) OVERRIDE {} // COV_NF_LINE | 75 virtual void OnUnregistration(int, bool) override {} // COV_NF_LINE |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 //////////////////////////////////////////////////////////////////////////////// | 78 //////////////////////////////////////////////////////////////////////////////// |
| 79 //////////////////////////////////////////////////////////////////////////////// | 79 //////////////////////////////////////////////////////////////////////////////// |
| 80 | 80 |
| 81 EpollServer::EpollServer() | 81 EpollServer::EpollServer() |
| 82 : epoll_fd_(epoll_create(1024)), | 82 : epoll_fd_(epoll_create(1024)), |
| 83 timeout_in_us_(0), | 83 timeout_in_us_(0), |
| 84 recorded_now_in_us_(0), | 84 recorded_now_in_us_(0), |
| 85 ready_list_size_(0), | 85 ready_list_size_(0), |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 | 811 |
| 812 // If the alarm was registered, unregister it. | 812 // If the alarm was registered, unregister it. |
| 813 void EpollAlarm::UnregisterIfRegistered() { | 813 void EpollAlarm::UnregisterIfRegistered() { |
| 814 if (!registered_) { | 814 if (!registered_) { |
| 815 return; | 815 return; |
| 816 } | 816 } |
| 817 eps_->UnregisterAlarm(token_); | 817 eps_->UnregisterAlarm(token_); |
| 818 } | 818 } |
| 819 | 819 |
| 820 } // namespace net | 820 } // namespace net |
| OLD | NEW |