summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2019-12-18 17:46:33 +0100
committerMax Kellermann <max@musicpd.org>2019-12-18 17:46:33 +0100
commit732bdc800d33e9d5fc78af4463da844309e7a312 (patch)
tree462e6f59a83b28d2d13acbe7ed23151e4cc14fbb /src
parenta8661b593132e3a0febb191072834bee39f5b14f (diff)
event/SocketMonitor: Schedule() returns bool
Diffstat (limited to 'src')
-rw-r--r--src/event/SocketMonitor.cxx16
-rw-r--r--src/event/SocketMonitor.hxx14
2 files changed, 19 insertions, 11 deletions
diff --git a/src/event/SocketMonitor.cxx b/src/event/SocketMonitor.cxx
index 64cc42820..f335c8fdc 100644
--- a/src/event/SocketMonitor.cxx
+++ b/src/event/SocketMonitor.cxx
@@ -68,20 +68,24 @@ SocketMonitor::Close() noexcept
Steal().Close();
}
-void
+bool
SocketMonitor::Schedule(unsigned flags) noexcept
{
assert(IsDefined());
if (flags == GetScheduledFlags())
- return;
+ return true;
+ bool success;
if (scheduled_flags == 0)
- loop.AddFD(fd.Get(), flags, *this);
+ success = loop.AddFD(fd.Get(), flags, *this);
else if (flags == 0)
- loop.RemoveFD(fd.Get(), *this);
+ success = loop.RemoveFD(fd.Get(), *this);
else
- loop.ModifyFD(fd.Get(), flags, *this);
+ success = loop.ModifyFD(fd.Get(), flags, *this);
+
+ if (success)
+ scheduled_flags = flags;
- scheduled_flags = flags;
+ return success;
}
diff --git a/src/event/SocketMonitor.hxx b/src/event/SocketMonitor.hxx
index df80ced04..1d8814cc5 100644
--- a/src/event/SocketMonitor.hxx
+++ b/src/event/SocketMonitor.hxx
@@ -98,18 +98,22 @@ public:
return scheduled_flags;
}
- void Schedule(unsigned flags) noexcept;
+ /**
+ * @return true on success, false on error (with errno set if
+ * USE_EPOLL is defined)
+ */
+ bool Schedule(unsigned flags) noexcept;
void Cancel() noexcept {
Schedule(0);
}
- void ScheduleRead() noexcept {
- Schedule(GetScheduledFlags() | READ | HANGUP | ERROR);
+ bool ScheduleRead() noexcept {
+ return Schedule(GetScheduledFlags() | READ | HANGUP | ERROR);
}
- void ScheduleWrite() noexcept {
- Schedule(GetScheduledFlags() | WRITE);
+ bool ScheduleWrite() noexcept {
+ return Schedule(GetScheduledFlags() | WRITE);
}
void CancelRead() noexcept {