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