event/SocketEvent: allow Cancel() without socket
This commit is contained in:
parent
653eea5840
commit
7901b04c78
@ -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)));
|
||||
|
Loading…
Reference in New Issue
Block a user