aboutsummaryrefslogtreecommitdiffstats
path: root/src/event/MultiSocketMonitor.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-08-10 11:21:38 +0200
committerMax Kellermann <max@duempel.org>2013-08-10 11:52:31 +0200
commit84ac79bb08696230157912a1d927d35004b12e8c (patch)
tree857369be445009e0368e4123d1aea8b03411b4d1 /src/event/MultiSocketMonitor.cxx
parentbe0c8495cdb60847279ffbb6b6e1c1efed607e98 (diff)
downloadmpd-84ac79bb08696230157912a1d927d35004b12e8c.tar.gz
mpd-84ac79bb08696230157912a1d927d35004b12e8c.tar.xz
mpd-84ac79bb08696230157912a1d927d35004b12e8c.zip
event/MultiSocketMonitor: eliminate virtual method CheckSockets()
Handle timeout internally.
Diffstat (limited to '')
-rw-r--r--src/event/MultiSocketMonitor.cxx16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/event/MultiSocketMonitor.cxx b/src/event/MultiSocketMonitor.cxx
index d8a9ffd6a..3fcc4375c 100644
--- a/src/event/MultiSocketMonitor.cxx
+++ b/src/event/MultiSocketMonitor.cxx
@@ -42,7 +42,8 @@ static GSourceFuncs multi_socket_monitor_source_funcs = {
MultiSocketMonitor::MultiSocketMonitor(EventLoop &_loop)
:loop(_loop),
source((Source *)g_source_new(&multi_socket_monitor_source_funcs,
- sizeof(*source))) {
+ sizeof(*source))),
+ absolute_timeout_us(G_MAXINT64) {
source->monitor = this;
g_source_attach(&source->base, loop.GetContext());
@@ -56,9 +57,20 @@ MultiSocketMonitor::~MultiSocketMonitor()
}
bool
+MultiSocketMonitor::Prepare(gint *timeout_r)
+{
+ int timeout_ms = *timeout_r = PrepareSockets();
+ absolute_timeout_us = timeout_ms < 0
+ ? G_MAXINT64
+ : GetTime() + gint64(timeout_ms) * 1000;
+
+ return false;
+}
+
+bool
MultiSocketMonitor::Check() const
{
- if (CheckSockets())
+ if (GetTime() >= absolute_timeout_us)
return true;
for (const auto &i : fds)