Commit 7901b04c authored by Max Kellermann's avatar Max Kellermann

event/SocketEvent: allow Cancel() without socket

parent 653eea58
......@@ -38,12 +38,6 @@ SocketEvent::Dispatch() noexcept
callback(flags);
}
SocketEvent::~SocketEvent() noexcept
{
if (IsDefined())
Cancel();
}
void
SocketEvent::Open(SocketDescriptor _fd) noexcept
{
......@@ -72,11 +66,11 @@ SocketEvent::Close() noexcept
bool
SocketEvent::Schedule(unsigned flags) noexcept
{
assert(IsDefined());
if (flags == GetScheduledFlags())
return true;
assert(IsDefined());
bool success;
if (scheduled_flags == 0)
success = loop.AddFD(fd.Get(), flags, *this);
......
......@@ -91,7 +91,9 @@ public:
callback(_callback),
fd(_fd) {}
~SocketEvent() noexcept;
~SocketEvent() noexcept {
Cancel();
}
auto &GetEventLoop() const noexcept {
return loop;
......
......@@ -52,8 +52,7 @@ DbusToLibevent(unsigned flags) noexcept
void
WatchManager::Watch::Toggled() noexcept
{
if (event.IsDefined())
event.Cancel();
event.Cancel();
if (dbus_watch_get_enabled(&watch)) {
event.Open(SocketDescriptor(dbus_watch_get_unix_fd(&watch)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment