event/MultiSocketMonitor: AddSocket() returns bool

This commit is contained in:
Max Kellermann 2019-12-18 17:50:21 +01:00
parent 732bdc800d
commit a84bf5a92e

View File

@ -50,12 +50,10 @@ class MultiSocketMonitor : IdleMonitor
unsigned revents; unsigned revents;
public: public:
SingleFD(MultiSocketMonitor &_multi, SocketDescriptor _fd, SingleFD(MultiSocketMonitor &_multi,
unsigned events) noexcept SocketDescriptor _fd) noexcept
:SocketMonitor(_fd, _multi.GetEventLoop()), :SocketMonitor(_fd, _multi.GetEventLoop()),
multi(_multi), revents(0) { multi(_multi), revents(0) {}
Schedule(events);
}
SocketDescriptor GetSocket() const noexcept { SocketDescriptor GetSocket() const noexcept {
return SocketMonitor::GetSocket(); return SocketMonitor::GetSocket();
@ -147,8 +145,14 @@ public:
* *
* May only be called from PrepareSockets(). * May only be called from PrepareSockets().
*/ */
void AddSocket(SocketDescriptor fd, unsigned events) noexcept { bool AddSocket(SocketDescriptor fd, unsigned events) noexcept {
fds.emplace_front(*this, fd, events); fds.emplace_front(*this, fd);
bool success = fds.front().Schedule(events);
if (!success) {
fds.pop_front();
}
return success;
} }
/** /**