aboutsummaryrefslogtreecommitdiff
path: root/rtc_base
diff options
context:
space:
mode:
Diffstat (limited to 'rtc_base')
-rw-r--r--rtc_base/physical_socket_server.cc22
-rw-r--r--rtc_base/physical_socket_server.h10
2 files changed, 10 insertions, 22 deletions
diff --git a/rtc_base/physical_socket_server.cc b/rtc_base/physical_socket_server.cc
index cf65300b4a..3a95331669 100644
--- a/rtc_base/physical_socket_server.cc
+++ b/rtc_base/physical_socket_server.cc
@@ -1365,12 +1365,6 @@ bool PhysicalSocketServer::WaitSelect(int cmsWait, bool process_io) {
#if defined(WEBRTC_USE_EPOLL)
-// Initial number of events to process with one call to "epoll_wait".
-static const size_t kInitialEpollEvents = 128;
-
-// Maximum number of events to process with one call to "epoll_wait".
-static const size_t kMaxEpollEvents = 8192;
-
void PhysicalSocketServer::AddEpoll(Dispatcher* pdispatcher) {
RTC_DCHECK(epoll_fd_ != INVALID_SOCKET);
int fd = pdispatcher->GetDescriptor();
@@ -1437,20 +1431,13 @@ bool PhysicalSocketServer::WaitEpoll(int cmsWait) {
tvStop = TimeAfter(cmsWait);
}
- if (epoll_events_.empty()) {
- // The initial space to receive events is created only if epoll is used.
- epoll_events_.resize(kInitialEpollEvents);
- }
-
fWait_ = true;
-
while (fWait_) {
// Wait then call handlers as appropriate
// < 0 means error
// 0 means timeout
// > 0 means count of descriptors ready
- int n = epoll_wait(epoll_fd_, &epoll_events_[0],
- static_cast<int>(epoll_events_.size()),
+ int n = epoll_wait(epoll_fd_, epoll_events_.data(), epoll_events_.size(),
static_cast<int>(tvWait));
if (n < 0) {
if (errno != EINTR) {
@@ -1483,13 +1470,6 @@ bool PhysicalSocketServer::WaitEpoll(int cmsWait) {
}
}
- if (static_cast<size_t>(n) == epoll_events_.size() &&
- epoll_events_.size() < kMaxEpollEvents) {
- // We used the complete space to receive events, increase size for future
- // iterations.
- epoll_events_.resize(std::max(epoll_events_.size() * 2, kMaxEpollEvents));
- }
-
if (cmsWait != kForever) {
tvWait = TimeDiff(tvStop, TimeMillis());
if (tvWait < 0) {
diff --git a/rtc_base/physical_socket_server.h b/rtc_base/physical_socket_server.h
index 2f53d4d4fe..e21e53b8ec 100644
--- a/rtc_base/physical_socket_server.h
+++ b/rtc_base/physical_socket_server.h
@@ -16,6 +16,7 @@
#define WEBRTC_USE_EPOLL 1
#endif
+#include <array>
#include <memory>
#include <set>
#include <vector>
@@ -81,6 +82,9 @@ class RTC_EXPORT PhysicalSocketServer : public SocketServer {
void Update(Dispatcher* dispatcher);
private:
+ // The number of events to process with one call to "epoll_wait".
+ static constexpr size_t kNumEpollEvents = 128;
+
typedef std::set<Dispatcher*> DispatcherSet;
void AddRemovePendingDispatchers() RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
@@ -95,8 +99,12 @@ class RTC_EXPORT PhysicalSocketServer : public SocketServer {
bool WaitEpoll(int cms);
bool WaitPoll(int cms, Dispatcher* dispatcher);
+ // This array is accessed in isolation by a thread calling into Wait().
+ // It's useless to use a SequenceChecker to guard it because a socket
+ // server can outlive the thread it's bound to, forcing the Wait call
+ // to have to reset the sequence checker on Wait calls.
+ std::array<epoll_event, kNumEpollEvents> epoll_events_;
const int epoll_fd_ = INVALID_SOCKET;
- std::vector<struct epoll_event> epoll_events_;
#endif // WEBRTC_USE_EPOLL
DispatcherSet dispatchers_ RTC_GUARDED_BY(crit_);
DispatcherSet pending_add_dispatchers_ RTC_GUARDED_BY(crit_);