lib/nfs/Connection: migrate from TimeoutMonitor to TimerEvent
This commit is contained in:
parent
c24b8460e0
commit
91d4b5cfed
@ -359,8 +359,8 @@ NfsConnection::DestroyContext()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!mount_finished) {
|
if (!mount_finished) {
|
||||||
assert(TimeoutMonitor::IsActive());
|
assert(mount_timeout_event.IsActive());
|
||||||
TimeoutMonitor::Cancel();
|
mount_timeout_event.Cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* cancel pending DeferredMonitor that was scheduled to notify
|
/* cancel pending DeferredMonitor that was scheduled to notify
|
||||||
@ -525,8 +525,8 @@ NfsConnection::MountCallback(int status, gcc_unused nfs_context *nfs,
|
|||||||
|
|
||||||
mount_finished = true;
|
mount_finished = true;
|
||||||
|
|
||||||
assert(TimeoutMonitor::IsActive() || in_destroy);
|
assert(mount_timeout_event.IsActive() || in_destroy);
|
||||||
TimeoutMonitor::Cancel();
|
mount_timeout_event.Cancel();
|
||||||
|
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
auto e = FormatRuntimeError("nfs_mount_async() failed: %s",
|
auto e = FormatRuntimeError("nfs_mount_async() failed: %s",
|
||||||
@ -558,7 +558,7 @@ NfsConnection::MountInternal()
|
|||||||
postponed_mount_error = std::exception_ptr();
|
postponed_mount_error = std::exception_ptr();
|
||||||
mount_finished = false;
|
mount_finished = false;
|
||||||
|
|
||||||
TimeoutMonitor::Schedule(NFS_MOUNT_TIMEOUT);
|
mount_timeout_event.Schedule(NFS_MOUNT_TIMEOUT);
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
in_service = false;
|
in_service = false;
|
||||||
@ -619,7 +619,7 @@ NfsConnection::BroadcastError(std::exception_ptr &&e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
NfsConnection::OnTimeout()
|
NfsConnection::OnMountTimeout()
|
||||||
{
|
{
|
||||||
assert(GetEventLoop().IsInside());
|
assert(GetEventLoop().IsInside());
|
||||||
assert(!mount_finished);
|
assert(!mount_finished);
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "Cancellable.hxx"
|
#include "Cancellable.hxx"
|
||||||
#include "event/SocketMonitor.hxx"
|
#include "event/SocketMonitor.hxx"
|
||||||
#include "event/TimeoutMonitor.hxx"
|
#include "event/TimerEvent.hxx"
|
||||||
#include "event/DeferredMonitor.hxx"
|
#include "event/DeferredMonitor.hxx"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -39,7 +39,7 @@ class NfsLease;
|
|||||||
/**
|
/**
|
||||||
* An asynchronous connection to a NFS server.
|
* An asynchronous connection to a NFS server.
|
||||||
*/
|
*/
|
||||||
class NfsConnection : SocketMonitor, TimeoutMonitor, DeferredMonitor {
|
class NfsConnection : SocketMonitor, DeferredMonitor {
|
||||||
class CancellableCallback : public CancellablePointer<NfsCallback> {
|
class CancellableCallback : public CancellablePointer<NfsCallback> {
|
||||||
NfsConnection &connection;
|
NfsConnection &connection;
|
||||||
|
|
||||||
@ -91,6 +91,8 @@ class NfsConnection : SocketMonitor, TimeoutMonitor, DeferredMonitor {
|
|||||||
void Callback(int err, void *data);
|
void Callback(int err, void *data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
TimerEvent mount_timeout_event;
|
||||||
|
|
||||||
std::string server, export_name;
|
std::string server, export_name;
|
||||||
|
|
||||||
nfs_context *context;
|
nfs_context *context;
|
||||||
@ -136,8 +138,9 @@ public:
|
|||||||
gcc_nonnull_all
|
gcc_nonnull_all
|
||||||
NfsConnection(EventLoop &_loop,
|
NfsConnection(EventLoop &_loop,
|
||||||
const char *_server, const char *_export_name) noexcept
|
const char *_server, const char *_export_name) noexcept
|
||||||
:SocketMonitor(_loop), TimeoutMonitor(_loop),
|
:SocketMonitor(_loop),
|
||||||
DeferredMonitor(_loop),
|
DeferredMonitor(_loop),
|
||||||
|
mount_timeout_event(_loop, BIND_THIS_METHOD(OnMountTimeout)),
|
||||||
server(_server), export_name(_export_name),
|
server(_server), export_name(_export_name),
|
||||||
context(nullptr) {}
|
context(nullptr) {}
|
||||||
|
|
||||||
@ -229,8 +232,8 @@ private:
|
|||||||
/* virtual methods from SocketMonitor */
|
/* virtual methods from SocketMonitor */
|
||||||
virtual bool OnSocketReady(unsigned flags) override;
|
virtual bool OnSocketReady(unsigned flags) override;
|
||||||
|
|
||||||
/* virtual methods from TimeoutMonitor */
|
/* callback for #mount_timeout_event */
|
||||||
void OnTimeout() final;
|
void OnMountTimeout();
|
||||||
|
|
||||||
/* virtual methods from DeferredMonitor */
|
/* virtual methods from DeferredMonitor */
|
||||||
virtual void RunDeferred() override;
|
virtual void RunDeferred() override;
|
||||||
|
Loading…
Reference in New Issue
Block a user