mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-10-26 19:01:56 -04:00
Initialize readdir threadpool after daemonizing
This commit is contained in:
parent
82781b6ff8
commit
0c555e71a0
6 changed files with 76 additions and 22 deletions
|
|
@ -17,10 +17,15 @@
|
|||
*/
|
||||
|
||||
#include "fuse_readdir.hpp"
|
||||
#include "fuse_readdir_factory.hpp"
|
||||
|
||||
#include "config.hpp"
|
||||
#include "fuse_readdir_factory.hpp"
|
||||
|
||||
/*
|
||||
The _initialized stuff is not pretty but easiest way to deal with
|
||||
the fact that mergerfs is doing arg parsing and setting up of things
|
||||
(including thread pools) before the daemonizing
|
||||
*/
|
||||
|
||||
int
|
||||
FUSE::readdir(const fuse_file_info_t *ffi_,
|
||||
|
|
@ -32,9 +37,11 @@ FUSE::readdir(const fuse_file_info_t *ffi_,
|
|||
}
|
||||
|
||||
FUSE::ReadDir::ReadDir(std::string const s_)
|
||||
: _initialized(false)
|
||||
{
|
||||
from_string(s_);
|
||||
assert(_readdir);
|
||||
if(_initialized)
|
||||
assert(_readdir);
|
||||
}
|
||||
|
||||
std::string
|
||||
|
|
@ -45,25 +52,46 @@ FUSE::ReadDir::to_string() const
|
|||
return _type;
|
||||
}
|
||||
|
||||
void
|
||||
FUSE::ReadDir::initialize()
|
||||
{
|
||||
_initialized = true;
|
||||
from_string(_type);
|
||||
}
|
||||
|
||||
int
|
||||
FUSE::ReadDir::from_string(std::string const &str_)
|
||||
{
|
||||
std::shared_ptr<FUSE::ReadDirBase> tmp;
|
||||
if(_initialized)
|
||||
{
|
||||
std::shared_ptr<FUSE::ReadDirBase> tmp;
|
||||
|
||||
tmp = FUSE::ReadDirFactory::make(str_);
|
||||
if(!tmp)
|
||||
return -EINVAL;
|
||||
tmp = FUSE::ReadDirFactory::make(str_);
|
||||
if(!tmp)
|
||||
return -EINVAL;
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lg(_mutex);
|
||||
{
|
||||
std::lock_guard<std::mutex> lg(_mutex);
|
||||
|
||||
_type = str_;
|
||||
_readdir = tmp;
|
||||
}
|
||||
_type = str_;
|
||||
std::swap(_readdir,tmp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::lock_guard<std::mutex> lg(_mutex);
|
||||
|
||||
_type = str_;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Yeah... if not initialized it will crash... ¯\_(ツ)_/¯
|
||||
This will be resolved once initialization of internal objects and
|
||||
handling of input is better seperated.
|
||||
*/
|
||||
int
|
||||
FUSE::ReadDir::operator()(fuse_file_info_t const *ffi_,
|
||||
fuse_dirents_t *buf_)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue