summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2019-12-18 17:50:21 +0100
committerMax Kellermann <max@musicpd.org>2019-12-18 17:50:21 +0100
commita84bf5a92ede3fe38e9b3fc2882d7080d59c13b1 (patch)
tree73b1e23dcf3ea42ee0852cce5a3bc0272ef484b6 /src
parent732bdc800d33e9d5fc78af4463da844309e7a312 (diff)
event/MultiSocketMonitor: AddSocket() returns bool
Diffstat (limited to 'src')
-rw-r--r--src/event/MultiSocketMonitor.hxx18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/event/MultiSocketMonitor.hxx b/src/event/MultiSocketMonitor.hxx
index eff82bbdf..c4bad8ac0 100644
--- a/src/event/MultiSocketMonitor.hxx
+++ b/src/event/MultiSocketMonitor.hxx
@@ -50,12 +50,10 @@ class MultiSocketMonitor : IdleMonitor
unsigned revents;
public:
- SingleFD(MultiSocketMonitor &_multi, SocketDescriptor _fd,
- unsigned events) noexcept
+ SingleFD(MultiSocketMonitor &_multi,
+ SocketDescriptor _fd) noexcept
:SocketMonitor(_fd, _multi.GetEventLoop()),
- multi(_multi), revents(0) {
- Schedule(events);
- }
+ multi(_multi), revents(0) {}
SocketDescriptor GetSocket() const noexcept {
return SocketMonitor::GetSocket();
@@ -147,8 +145,14 @@ public:
*
* May only be called from PrepareSockets().
*/
- void AddSocket(SocketDescriptor fd, unsigned events) noexcept {
- fds.emplace_front(*this, fd, events);
+ bool AddSocket(SocketDescriptor fd, unsigned events) noexcept {
+ fds.emplace_front(*this, fd);
+ bool success = fds.front().Schedule(events);
+ if (!success) {
+ fds.pop_front();
+ }
+
+ return success;
}
/**