diff options
author | Max Kellermann <max@duempel.org> | 2013-01-30 15:01:34 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-01-30 15:08:09 +0100 |
commit | be3d2188d6a8fc03379d55cec0a9b02980c3df9d (patch) | |
tree | 65071741bed96922baf6dd1e0db24a10754da097 | |
parent | 18e429a87ede285b08aa8d661df7fa6c3f335dc4 (diff) | |
download | mpd-be3d2188d6a8fc03379d55cec0a9b02980c3df9d.tar.gz mpd-be3d2188d6a8fc03379d55cec0a9b02980c3df9d.tar.xz mpd-be3d2188d6a8fc03379d55cec0a9b02980c3df9d.zip |
event/SocketMonitor: wake up the event loop after flag change
-rw-r--r-- | src/event/SocketMonitor.cxx | 6 | ||||
-rw-r--r-- | src/event/SocketMonitor.hxx | 8 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/event/SocketMonitor.cxx b/src/event/SocketMonitor.cxx index bf9fcdc59..6efa69647 100644 --- a/src/event/SocketMonitor.cxx +++ b/src/event/SocketMonitor.cxx @@ -159,3 +159,9 @@ SocketMonitor::Write(const void *data, size_t length) return send(Get(), (const char *)data, length, flags); } + +void +SocketMonitor::CommitEventFlags() +{ + loop.WakeUp(); +} diff --git a/src/event/SocketMonitor.hxx b/src/event/SocketMonitor.hxx index c815e4f53..c60b8efdf 100644 --- a/src/event/SocketMonitor.hxx +++ b/src/event/SocketMonitor.hxx @@ -89,26 +89,32 @@ public: void Schedule(unsigned flags) { poll.events = flags; poll.revents &= flags; + CommitEventFlags(); } void Cancel() { poll.events = 0; + CommitEventFlags(); } void ScheduleRead() { poll.events |= READ|HANGUP|ERROR; + CommitEventFlags(); } void ScheduleWrite() { poll.events |= WRITE; + CommitEventFlags(); } void CancelRead() { poll.events &= ~(READ|HANGUP|ERROR); + CommitEventFlags(); } void CancelWrite() { poll.events &= ~WRITE; + CommitEventFlags(); } ssize_t Read(void *data, size_t length); @@ -128,6 +134,8 @@ public: gpointer user_data); private: + void CommitEventFlags(); + bool Check() const { return (poll.revents & poll.events) != 0; } |