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