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 #ifndef NET_TOOLS_EPOLL_SERVER_EPOLL_SERVER_H_ | 5 #ifndef NET_TOOLS_EPOLL_SERVER_EPOLL_SERVER_H_ |
6 #define NET_TOOLS_EPOLL_SERVER_EPOLL_SERVER_H_ | 6 #define NET_TOOLS_EPOLL_SERVER_EPOLL_SERVER_H_ |
7 | 7 |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <sys/queue.h> | 9 #include <sys/queue.h> |
10 #include <map> | 10 #include <map> |
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 struct EventRecorder { | 713 struct EventRecorder { |
714 public: | 714 public: |
715 EventRecorder() : num_records_(0), record_threshold_(10000) {} | 715 EventRecorder() : num_records_(0), record_threshold_(10000) {} |
716 | 716 |
717 ~EventRecorder() { | 717 ~EventRecorder() { |
718 Clear(); | 718 Clear(); |
719 } | 719 } |
720 | 720 |
721 // When a number of events equals the record threshold, | 721 // When a number of events equals the record threshold, |
722 // the collected data summary for all FDs will be written | 722 // the collected data summary for all FDs will be written |
723 // to LOG(INFO). Note that this does not include the | 723 // to VLOG(0). Note that this does not include the |
724 // individual events (if you'reinterested in those, you'll | 724 // individual events (if you'reinterested in those, you'll |
725 // have to get at them programmatically). | 725 // have to get at them programmatically). |
726 // After any such flushing to LOG(INFO) all events will | 726 // After any such flushing to VLOG(0) all events will |
727 // be cleared. | 727 // be cleared. |
728 // Note that the definition of an 'event' is a bit 'hazy', | 728 // Note that the definition of an 'event' is a bit 'hazy', |
729 // as it includes the 'Unregistration' event, and perhaps | 729 // as it includes the 'Unregistration' event, and perhaps |
730 // others. | 730 // others. |
731 void set_record_threshold(int64 new_threshold) { | 731 void set_record_threshold(int64 new_threshold) { |
732 record_threshold_ = new_threshold; | 732 record_threshold_ = new_threshold; |
733 } | 733 } |
734 | 734 |
735 void Clear() { | 735 void Clear() { |
736 for (int i = 0; i < debug_events_.size(); ++i) { | 736 for (int i = 0; i < debug_events_.size(); ++i) { |
737 delete debug_events_[i]; | 737 delete debug_events_[i]; |
738 } | 738 } |
739 debug_events_.clear(); | 739 debug_events_.clear(); |
740 unregistered_fds_.clear(); | 740 unregistered_fds_.clear(); |
741 event_counts_.clear(); | 741 event_counts_.clear(); |
742 } | 742 } |
743 | 743 |
744 void MaybeRecordAndClear() { | 744 void MaybeRecordAndClear() { |
745 ++num_records_; | 745 ++num_records_; |
746 if ((num_records_ > record_threshold_) && | 746 if ((num_records_ > record_threshold_) && |
747 (record_threshold_ > 0)) { | 747 (record_threshold_ > 0)) { |
748 LOG(INFO) << "\n" << *this; | 748 VLOG(0) << "\n" << *this; |
749 num_records_ = 0; | 749 num_records_ = 0; |
750 Clear(); | 750 Clear(); |
751 } | 751 } |
752 } | 752 } |
753 | 753 |
754 void RecordFDMaskEvent(int fd, int mask, const char* function) { | 754 void RecordFDMaskEvent(int fd, int mask, const char* function) { |
755 FDMaskOutput* fdmo = new FDMaskOutput(fd, mask, function); | 755 FDMaskOutput* fdmo = new FDMaskOutput(fd, mask, function); |
756 debug_events_.push_back(fdmo); | 756 debug_events_.push_back(fdmo); |
757 MaybeRecordAndClear(); | 757 MaybeRecordAndClear(); |
758 } | 758 } |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 | 1044 |
1045 private: | 1045 private: |
1046 EpollServer::AlarmRegToken token_; | 1046 EpollServer::AlarmRegToken token_; |
1047 EpollServer* eps_; | 1047 EpollServer* eps_; |
1048 bool registered_; | 1048 bool registered_; |
1049 }; | 1049 }; |
1050 | 1050 |
1051 } // namespace net | 1051 } // namespace net |
1052 | 1052 |
1053 #endif // NET_TOOLS_EPOLL_SERVER_EPOLL_SERVER_H_ | 1053 #endif // NET_TOOLS_EPOLL_SERVER_EPOLL_SERVER_H_ |
OLD | NEW |