Client: migrate from TimeoutMonitor to TimerEvent

This commit is contained in:
Max Kellermann 2017-08-29 16:22:01 +02:00
parent 30a5dd267b
commit fd520eeed2
5 changed files with 12 additions and 10 deletions

View File

@ -25,7 +25,7 @@
#include "command/CommandListBuilder.hxx" #include "command/CommandListBuilder.hxx"
#include "tag/Mask.hxx" #include "tag/Mask.hxx"
#include "event/FullyBufferedSocket.hxx" #include "event/FullyBufferedSocket.hxx"
#include "event/TimeoutMonitor.hxx" #include "event/TimerEvent.hxx"
#include "Compiler.h" #include "Compiler.h"
#include <boost/intrusive/link_mode.hpp> #include <boost/intrusive/link_mode.hpp>
@ -49,8 +49,10 @@ class Database;
class Storage; class Storage;
class Client final class Client final
: FullyBufferedSocket, TimeoutMonitor, : FullyBufferedSocket,
public boost::intrusive::list_base_hook<boost::intrusive::link_mode<boost::intrusive::normal_link>> { public boost::intrusive::list_base_hook<boost::intrusive::link_mode<boost::intrusive::normal_link>> {
TimerEvent timeout_event;
Partition *partition; Partition *partition;
public: public:
@ -228,8 +230,8 @@ private:
void OnSocketError(std::exception_ptr ep) override; void OnSocketError(std::exception_ptr ep) override;
void OnSocketClosed() override; void OnSocketClosed() override;
/* virtual methods from class TimeoutMonitor */ /* callback for TimerEvent */
void OnTimeout() override; void OnTimeout();
}; };
void void

View File

@ -28,7 +28,7 @@ Client::SetExpired()
return; return;
FullyBufferedSocket::Close(); FullyBufferedSocket::Close();
TimeoutMonitor::Schedule(std::chrono::steady_clock::duration::zero()); timeout_event.Schedule(std::chrono::steady_clock::duration::zero());
} }
void void

View File

@ -42,7 +42,7 @@ Client::IdleNotify()
Write("OK\n"); Write("OK\n");
TimeoutMonitor::Schedule(client_timeout); timeout_event.Schedule(client_timeout);
} }
void void
@ -69,7 +69,7 @@ Client::IdleWait(unsigned flags)
return true; return true;
} else { } else {
/* disable timeouts while in "idle" */ /* disable timeouts while in "idle" */
TimeoutMonitor::Cancel(); timeout_event.Cancel();
return false; return false;
} }
} }

View File

@ -45,13 +45,13 @@ Client::Client(EventLoop &_loop, Partition &_partition,
UniqueSocketDescriptor &&_fd, int _uid, int _num) UniqueSocketDescriptor &&_fd, int _uid, int _num)
:FullyBufferedSocket(_fd.Release(), _loop, :FullyBufferedSocket(_fd.Release(), _loop,
16384, client_max_output_buffer_size), 16384, client_max_output_buffer_size),
TimeoutMonitor(_loop), timeout_event(_loop, BIND_THIS_METHOD(OnTimeout)),
partition(&_partition), partition(&_partition),
permission(getDefaultPermissions()), permission(getDefaultPermissions()),
uid(_uid), uid(_uid),
num(_num) num(_num)
{ {
TimeoutMonitor::Schedule(client_timeout); timeout_event.Schedule(client_timeout);
} }
void void

View File

@ -34,7 +34,7 @@ Client::OnSocketInput(void *data, size_t length)
if (newline == nullptr) if (newline == nullptr)
return InputResult::MORE; return InputResult::MORE;
TimeoutMonitor::Schedule(client_timeout); timeout_event.Schedule(client_timeout);
BufferedSocket::ConsumeInput(newline + 1 - p); BufferedSocket::ConsumeInput(newline + 1 - p);