Commit fd520eee authored by Max Kellermann's avatar Max Kellermann

Client: migrate from TimeoutMonitor to TimerEvent

parent 30a5dd26
......@@ -25,7 +25,7 @@
#include "command/CommandListBuilder.hxx"
#include "tag/Mask.hxx"
#include "event/FullyBufferedSocket.hxx"
#include "event/TimeoutMonitor.hxx"
#include "event/TimerEvent.hxx"
#include "Compiler.h"
#include <boost/intrusive/link_mode.hpp>
......@@ -49,8 +49,10 @@ class Database;
class Storage;
class Client final
: FullyBufferedSocket, TimeoutMonitor,
: FullyBufferedSocket,
public boost::intrusive::list_base_hook<boost::intrusive::link_mode<boost::intrusive::normal_link>> {
TimerEvent timeout_event;
Partition *partition;
public:
......@@ -228,8 +230,8 @@ private:
void OnSocketError(std::exception_ptr ep) override;
void OnSocketClosed() override;
/* virtual methods from class TimeoutMonitor */
void OnTimeout() override;
/* callback for TimerEvent */
void OnTimeout();
};
void
......
......@@ -28,7 +28,7 @@ Client::SetExpired()
return;
FullyBufferedSocket::Close();
TimeoutMonitor::Schedule(std::chrono::steady_clock::duration::zero());
timeout_event.Schedule(std::chrono::steady_clock::duration::zero());
}
void
......
......@@ -42,7 +42,7 @@ Client::IdleNotify()
Write("OK\n");
TimeoutMonitor::Schedule(client_timeout);
timeout_event.Schedule(client_timeout);
}
void
......@@ -69,7 +69,7 @@ Client::IdleWait(unsigned flags)
return true;
} else {
/* disable timeouts while in "idle" */
TimeoutMonitor::Cancel();
timeout_event.Cancel();
return false;
}
}
......@@ -45,13 +45,13 @@ Client::Client(EventLoop &_loop, Partition &_partition,
UniqueSocketDescriptor &&_fd, int _uid, int _num)
:FullyBufferedSocket(_fd.Release(), _loop,
16384, client_max_output_buffer_size),
TimeoutMonitor(_loop),
timeout_event(_loop, BIND_THIS_METHOD(OnTimeout)),
partition(&_partition),
permission(getDefaultPermissions()),
uid(_uid),
num(_num)
{
TimeoutMonitor::Schedule(client_timeout);
timeout_event.Schedule(client_timeout);
}
void
......
......@@ -34,7 +34,7 @@ Client::OnSocketInput(void *data, size_t length)
if (newline == nullptr)
return InputResult::MORE;
TimeoutMonitor::Schedule(client_timeout);
timeout_event.Schedule(client_timeout);
BufferedSocket::ConsumeInput(newline + 1 - p);
......
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