| Index: webrtc/base/physicalsocketserver.h
|
| diff --git a/webrtc/base/physicalsocketserver.h b/webrtc/base/physicalsocketserver.h
|
| index 5f843da20c78879181f7bc09bd1fddcc26691f9c..dec37c256cdf8a4302c4aa3022aa70d610b49146 100644
|
| --- a/webrtc/base/physicalsocketserver.h
|
| +++ b/webrtc/base/physicalsocketserver.h
|
| @@ -11,7 +11,13 @@
|
| #ifndef WEBRTC_BASE_PHYSICALSOCKETSERVER_H__
|
| #define WEBRTC_BASE_PHYSICALSOCKETSERVER_H__
|
|
|
| +#if defined(WEBRTC_POSIX) && defined(WEBRTC_LINUX)
|
| +#include <sys/epoll.h>
|
| +#define WEBRTC_USE_EPOLL 1
|
| +#endif
|
| +
|
| #include <memory>
|
| +#include <set>
|
| #include <vector>
|
|
|
| #include "webrtc/base/nethelpers.h"
|
| @@ -76,6 +82,7 @@ class PhysicalSocketServer : public SocketServer {
|
|
|
| void Add(Dispatcher* dispatcher);
|
| void Remove(Dispatcher* dispatcher);
|
| + void Update(Dispatcher* dispatcher);
|
|
|
| #if defined(WEBRTC_POSIX)
|
| // Sets the function to be executed in response to the specified POSIX signal.
|
| @@ -95,16 +102,30 @@ class PhysicalSocketServer : public SocketServer {
|
| #endif
|
|
|
| private:
|
| - typedef std::vector<Dispatcher*> DispatcherList;
|
| - typedef std::vector<size_t*> IteratorList;
|
| + typedef std::set<Dispatcher*> DispatcherSet;
|
| +
|
| + void AddRemovePendingDispatchers();
|
|
|
| #if defined(WEBRTC_POSIX)
|
| + bool WaitSelect(int cms, bool process_io);
|
| static bool InstallSignal(int signum, void (*handler)(int));
|
|
|
| std::unique_ptr<PosixSignalDispatcher> signal_dispatcher_;
|
| -#endif
|
| - DispatcherList dispatchers_;
|
| - IteratorList iterators_;
|
| +#endif // WEBRTC_POSIX
|
| +#if defined(WEBRTC_USE_EPOLL)
|
| + void AddEpoll(Dispatcher* dispatcher);
|
| + void RemoveEpoll(Dispatcher* dispatcher);
|
| + void UpdateEpoll(Dispatcher* dispatcher);
|
| + bool WaitEpoll(int cms);
|
| + bool WaitPoll(int cms, Dispatcher* dispatcher);
|
| +
|
| + int epoll_fd_ = INVALID_SOCKET;
|
| + std::vector<struct epoll_event> epoll_events_;
|
| +#endif // WEBRTC_USE_EPOLL
|
| + DispatcherSet dispatchers_;
|
| + DispatcherSet pending_add_dispatchers_;
|
| + DispatcherSet pending_remove_dispatchers_;
|
| + bool processing_dispatchers_ = false;
|
| Signaler* signal_wakeup_;
|
| CriticalSection crit_;
|
| bool fWait_;
|
| @@ -172,9 +193,9 @@ class PhysicalSocket : public AsyncSocket, public sigslot::has_slots<> {
|
| void MaybeRemapSendError();
|
|
|
| uint8_t enabled_events() const { return enabled_events_; }
|
| - void SetEnabledEvents(uint8_t events);
|
| - void EnableEvents(uint8_t events);
|
| - void DisableEvents(uint8_t events);
|
| + virtual void SetEnabledEvents(uint8_t events);
|
| + virtual void EnableEvents(uint8_t events);
|
| + virtual void DisableEvents(uint8_t events);
|
|
|
| static int TranslateOption(Option opt, int* slevel, int* sopt);
|
|
|
| @@ -220,13 +241,28 @@ class SocketDispatcher : public Dispatcher, public PhysicalSocket {
|
|
|
| int Close() override;
|
|
|
| -#if defined(WEBRTC_WIN)
|
| +#if defined(WEBRTC_USE_EPOLL)
|
| + protected:
|
| + void StartBatchedEventUpdates();
|
| + void FinishBatchedEventUpdates();
|
| +
|
| + void SetEnabledEvents(uint8_t events) override;
|
| + void EnableEvents(uint8_t events) override;
|
| + void DisableEvents(uint8_t events) override;
|
| +#endif
|
| +
|
| private:
|
| +#if defined(WEBRTC_WIN)
|
| static int next_id_;
|
| int id_;
|
| bool signal_close_;
|
| int signal_err_;
|
| #endif // WEBRTC_WIN
|
| +#if defined(WEBRTC_USE_EPOLL)
|
| + void MaybeUpdateDispatcher(uint8_t old_events);
|
| +
|
| + int saved_enabled_events_ = -1;
|
| +#endif
|
| };
|
|
|
| } // namespace rtc
|
|
|