From 579912e52f371c07583e09095a5b89bfe88e872a Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 1 Oct 2014 20:39:50 +0200 Subject: lib/nfs/Glue: destruct the NfsManager in the I/O thread This allows eliminating the indirection code from the NfsConnection destructor. --- src/lib/nfs/Connection.cxx | 7 +++---- src/lib/nfs/Connection.hxx | 3 +++ src/lib/nfs/Glue.cxx | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/lib/nfs/Connection.cxx b/src/lib/nfs/Connection.cxx index 13f7cd89c..934cf0a49 100644 --- a/src/lib/nfs/Connection.cxx +++ b/src/lib/nfs/Connection.cxx @@ -22,9 +22,9 @@ #include "Lease.hxx" #include "Domain.hxx" #include "Callback.hxx" +#include "event/Loop.hxx" #include "system/fd_util.h" #include "util/Error.hxx" -#include "event/Call.hxx" extern "C" { #include @@ -123,14 +123,13 @@ events_to_libnfs(unsigned i) NfsConnection::~NfsConnection() { + assert(SocketMonitor::GetEventLoop().IsInside()); assert(new_leases.empty()); assert(active_leases.empty()); assert(callbacks.IsEmpty()); if (context != nullptr) - BlockingCall(SocketMonitor::GetEventLoop(), [this](){ - DestroyContext(); - }); + DestroyContext(); } void diff --git a/src/lib/nfs/Connection.hxx b/src/lib/nfs/Connection.hxx index ff3b3658d..791ab15e7 100644 --- a/src/lib/nfs/Connection.hxx +++ b/src/lib/nfs/Connection.hxx @@ -119,6 +119,9 @@ public: } #endif + /** + * Must be run from EventLoop's thread. + */ ~NfsConnection(); gcc_pure diff --git a/src/lib/nfs/Glue.cxx b/src/lib/nfs/Glue.cxx index c89d463ca..6fc849609 100644 --- a/src/lib/nfs/Glue.cxx +++ b/src/lib/nfs/Glue.cxx @@ -21,6 +21,7 @@ #include "Glue.hxx" #include "Manager.hxx" #include "IOThread.hxx" +#include "event/Call.hxx" #include "util/Manual.hxx" static Manual nfs_glue; @@ -43,7 +44,7 @@ nfs_finish() if (--in_use > 0) return; - nfs_glue.Destruct(); + BlockingCall(io_thread_get(), [](){ nfs_glue.Destruct(); }); } NfsConnection & -- cgit v1.2.3