lib/nfs/{FileReader,Glue}: pass EventLoop&
Eliminate dependency on io_thread_get().
This commit is contained in:
parent
4140e9b857
commit
611ce6e756
@ -24,6 +24,7 @@
|
||||
#include "lib/nfs/Glue.hxx"
|
||||
#include "lib/nfs/FileReader.hxx"
|
||||
#include "util/StringCompare.hxx"
|
||||
#include "IOThread.hxx"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@ -49,6 +50,7 @@ public:
|
||||
:AsyncInputStream(_uri, _mutex, _cond,
|
||||
NFS_MAX_BUFFERED,
|
||||
NFS_RESUME_AT),
|
||||
NfsFileReader(io_thread_get()),
|
||||
reconnect_on_resume(false), reconnecting(false) {}
|
||||
|
||||
virtual ~NfsInputStream() {
|
||||
@ -206,7 +208,7 @@ NfsInputStream::OnNfsFileError(std::exception_ptr &&e)
|
||||
static void
|
||||
input_nfs_init(const ConfigBlock &)
|
||||
{
|
||||
nfs_init();
|
||||
nfs_init(io_thread_get());
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "Base.hxx"
|
||||
#include "Connection.hxx"
|
||||
#include "event/Call.hxx"
|
||||
#include "IOThread.hxx"
|
||||
#include "util/StringCompare.hxx"
|
||||
|
||||
#include <utility>
|
||||
@ -33,8 +32,8 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
NfsFileReader::NfsFileReader()
|
||||
:DeferredMonitor(io_thread_get()), state(State::INITIAL)
|
||||
NfsFileReader::NfsFileReader(EventLoop &event_loop)
|
||||
:DeferredMonitor(event_loop), state(State::INITIAL)
|
||||
{
|
||||
}
|
||||
|
||||
@ -86,7 +85,7 @@ NfsFileReader::CancelOrClose()
|
||||
void
|
||||
NfsFileReader::DeferClose()
|
||||
{
|
||||
BlockingCall(io_thread_get(), [this](){ Close(); });
|
||||
BlockingCall(GetEventLoop(), [this](){ Close(); });
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -64,9 +64,11 @@ class NfsFileReader : NfsLease, NfsCallback, DeferredMonitor {
|
||||
nfsfh *fh;
|
||||
|
||||
public:
|
||||
NfsFileReader();
|
||||
NfsFileReader(EventLoop &event_loop);
|
||||
~NfsFileReader();
|
||||
|
||||
using DeferredMonitor::GetEventLoop;
|
||||
|
||||
void Close();
|
||||
void DeferClose();
|
||||
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "config.h"
|
||||
#include "Glue.hxx"
|
||||
#include "Manager.hxx"
|
||||
#include "IOThread.hxx"
|
||||
#include "event/Call.hxx"
|
||||
#include "util/Manual.hxx"
|
||||
|
||||
@ -30,12 +29,12 @@ static Manual<NfsManager> nfs_glue;
|
||||
static unsigned in_use;
|
||||
|
||||
void
|
||||
nfs_init()
|
||||
nfs_init(EventLoop &event_loop)
|
||||
{
|
||||
if (in_use++ > 0)
|
||||
return;
|
||||
|
||||
nfs_glue.Construct(io_thread_get());
|
||||
nfs_glue.Construct(event_loop);
|
||||
}
|
||||
|
||||
void
|
||||
@ -46,14 +45,13 @@ nfs_finish()
|
||||
if (--in_use > 0)
|
||||
return;
|
||||
|
||||
BlockingCall(io_thread_get(), [](){ nfs_glue.Destruct(); });
|
||||
BlockingCall(nfs_glue->GetEventLoop(), [](){ nfs_glue.Destruct(); });
|
||||
}
|
||||
|
||||
NfsConnection &
|
||||
nfs_get_connection(const char *server, const char *export_name)
|
||||
{
|
||||
assert(in_use > 0);
|
||||
assert(io_thread_inside());
|
||||
|
||||
return nfs_glue->GetConnection(server, export_name);
|
||||
}
|
||||
|
@ -23,10 +23,11 @@
|
||||
#include "check.h"
|
||||
#include "Compiler.h"
|
||||
|
||||
class EventLoop;
|
||||
class NfsConnection;
|
||||
|
||||
void
|
||||
nfs_init();
|
||||
nfs_init(EventLoop &event_loop);
|
||||
|
||||
void
|
||||
nfs_finish();
|
||||
|
@ -97,6 +97,8 @@ public:
|
||||
*/
|
||||
~NfsManager();
|
||||
|
||||
using IdleMonitor::GetEventLoop;
|
||||
|
||||
gcc_pure
|
||||
NfsConnection &GetConnection(const char *server,
|
||||
const char *export_name);
|
||||
|
@ -74,7 +74,7 @@ public:
|
||||
server(std::move(_server)),
|
||||
export_name(std::move(_export_name)),
|
||||
state(State::INITIAL) {
|
||||
nfs_init();
|
||||
nfs_init(_loop);
|
||||
}
|
||||
|
||||
~NfsStorage() {
|
||||
|
Loading…
Reference in New Issue
Block a user