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 ...@@ -38,12 +38,6 @@ SocketEvent::Dispatch() noexcept
callback(flags); callback(flags);
} }
SocketEvent::~SocketEvent() noexcept
{
if (IsDefined())
Cancel();
}
void void
SocketEvent::Open(SocketDescriptor _fd) noexcept SocketEvent::Open(SocketDescriptor _fd) noexcept
{ {
...@@ -72,11 +66,11 @@ SocketEvent::Close() noexcept ...@@ -72,11 +66,11 @@ SocketEvent::Close() noexcept
bool bool
SocketEvent::Schedule(unsigned flags) noexcept SocketEvent::Schedule(unsigned flags) noexcept
{ {
assert(IsDefined());
if (flags == GetScheduledFlags()) if (flags == GetScheduledFlags())
return true; return true;
assert(IsDefined());
bool success; bool success;
if (scheduled_flags == 0) if (scheduled_flags == 0)
success = loop.AddFD(fd.Get(), flags, *this); success = loop.AddFD(fd.Get(), flags, *this);
......
...@@ -91,7 +91,9 @@ public: ...@@ -91,7 +91,9 @@ public:
callback(_callback), callback(_callback),
fd(_fd) {} fd(_fd) {}
~SocketEvent() noexcept; ~SocketEvent() noexcept {
Cancel();
}
auto &GetEventLoop() const noexcept { auto &GetEventLoop() const noexcept {
return loop; return loop;
......
...@@ -52,8 +52,7 @@ DbusToLibevent(unsigned flags) noexcept ...@@ -52,8 +52,7 @@ DbusToLibevent(unsigned flags) noexcept
void void
WatchManager::Watch::Toggled() noexcept WatchManager::Watch::Toggled() noexcept
{ {
if (event.IsDefined()) event.Cancel();
event.Cancel();
if (dbus_watch_get_enabled(&watch)) { if (dbus_watch_get_enabled(&watch)) {
event.Open(SocketDescriptor(dbus_watch_get_unix_fd(&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