mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-11-22 16:06:27 -05:00
config: rework global config, remove rwlock, make branches RCU like
Also added unit tests. Should have done separately but found a number of bugs.
This commit is contained in:
parent
2e4c6c5fd1
commit
538467b86d
327 changed files with 6691 additions and 3036 deletions
|
|
@ -28,7 +28,7 @@ namespace l
|
|||
|
||||
PolicyCache::Value::Value()
|
||||
: time(0),
|
||||
path()
|
||||
paths()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -91,18 +91,17 @@ PolicyCache::clear(void)
|
|||
}
|
||||
|
||||
int
|
||||
PolicyCache::operator()(Policy::Func::Search &func_,
|
||||
PolicyCache::operator()(const Policy::Search &policy_,
|
||||
const Branches &branches_,
|
||||
const char *fusepath_,
|
||||
std::string *branch_)
|
||||
StrVec *paths_)
|
||||
{
|
||||
int rv;
|
||||
Value *v;
|
||||
uint64_t now;
|
||||
string branch;
|
||||
|
||||
if(timeout == 0)
|
||||
return func_(branches_,fusepath_,branch_);
|
||||
return policy_(branches_,fusepath_,paths_);
|
||||
|
||||
now = l::get_time();
|
||||
|
||||
|
|
@ -112,16 +111,19 @@ PolicyCache::operator()(Policy::Func::Search &func_,
|
|||
if((now - v->time) >= timeout)
|
||||
{
|
||||
pthread_mutex_unlock(&_lock);
|
||||
rv = func_(branches_,fusepath_,&branch);
|
||||
|
||||
rv = policy_(branches_,fusepath_,paths_);
|
||||
if(rv == -1)
|
||||
return -1;
|
||||
|
||||
pthread_mutex_lock(&_lock);
|
||||
v->time = now;
|
||||
v->path = branch;
|
||||
v->time = now;
|
||||
v->paths = *paths_;
|
||||
}
|
||||
else
|
||||
{
|
||||
*paths_ = v->paths;
|
||||
}
|
||||
|
||||
*branch_ = v->path;
|
||||
|
||||
pthread_mutex_unlock(&_lock);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue