forked from lix-project/lix
LocalStore: Get rid of recursive_mutex
This commit is contained in:
parent
797a52e31d
commit
e8c379555f
5 changed files with 22 additions and 15 deletions
|
@ -3245,7 +3245,7 @@ void DerivationGoal::registerOutputs()
|
||||||
if (!oldInfo.ultimate) {
|
if (!oldInfo.ultimate) {
|
||||||
oldInfo.ultimate = true;
|
oldInfo.ultimate = true;
|
||||||
worker.store.signPathInfo(oldInfo);
|
worker.store.signPathInfo(oldInfo);
|
||||||
worker.store.registerValidPaths({ std::move(oldInfo) });
|
worker.store.registerValidPaths({{oldInfo.path, oldInfo}});
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
@ -3275,7 +3275,7 @@ void DerivationGoal::registerOutputs()
|
||||||
isn't statically known so that we can safely unlock the path before
|
isn't statically known so that we can safely unlock the path before
|
||||||
the next iteration */
|
the next iteration */
|
||||||
if (newInfo.ca)
|
if (newInfo.ca)
|
||||||
worker.store.registerValidPaths({newInfo});
|
worker.store.registerValidPaths({{newInfo.path, newInfo}});
|
||||||
|
|
||||||
infos.emplace(outputName, std::move(newInfo));
|
infos.emplace(outputName, std::move(newInfo));
|
||||||
}
|
}
|
||||||
|
@ -3350,7 +3350,7 @@ void DerivationGoal::registerOutputs()
|
||||||
{
|
{
|
||||||
ValidPathInfos infos2;
|
ValidPathInfos infos2;
|
||||||
for (auto & [outputName, newInfo] : infos) {
|
for (auto & [outputName, newInfo] : infos) {
|
||||||
infos2.push_back(newInfo);
|
infos2.insert_or_assign(newInfo.path, newInfo);
|
||||||
}
|
}
|
||||||
worker.store.registerValidPaths(infos2);
|
worker.store.registerValidPaths(infos2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "nar-info.hh"
|
#include "nar-info.hh"
|
||||||
#include "references.hh"
|
#include "references.hh"
|
||||||
#include "callback.hh"
|
#include "callback.hh"
|
||||||
|
#include "topo-sort.hh"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -962,9 +963,7 @@ void LocalStore::querySubstitutablePathInfos(const StorePathCAMap & paths, Subst
|
||||||
|
|
||||||
void LocalStore::registerValidPath(const ValidPathInfo & info)
|
void LocalStore::registerValidPath(const ValidPathInfo & info)
|
||||||
{
|
{
|
||||||
ValidPathInfos infos;
|
registerValidPaths({{info.path, info}});
|
||||||
infos.push_back(info);
|
|
||||||
registerValidPaths(infos);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -982,7 +981,7 @@ void LocalStore::registerValidPaths(const ValidPathInfos & infos)
|
||||||
SQLiteTxn txn(state->db);
|
SQLiteTxn txn(state->db);
|
||||||
StorePathSet paths;
|
StorePathSet paths;
|
||||||
|
|
||||||
for (auto & i : infos) {
|
for (auto & [_, i] : infos) {
|
||||||
assert(i.narHash.type == htSHA256);
|
assert(i.narHash.type == htSHA256);
|
||||||
if (isValidPath_(*state, i.path))
|
if (isValidPath_(*state, i.path))
|
||||||
updatePathInfo(*state, i);
|
updatePathInfo(*state, i);
|
||||||
|
@ -991,7 +990,7 @@ void LocalStore::registerValidPaths(const ValidPathInfos & infos)
|
||||||
paths.insert(i.path);
|
paths.insert(i.path);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto & i : infos) {
|
for (auto & [_, i] : infos) {
|
||||||
auto referrer = queryValidPathId(*state, i.path);
|
auto referrer = queryValidPathId(*state, i.path);
|
||||||
for (auto & j : i.references)
|
for (auto & j : i.references)
|
||||||
state->stmtAddReference.use()(referrer)(queryValidPathId(*state, j)).exec();
|
state->stmtAddReference.use()(referrer)(queryValidPathId(*state, j)).exec();
|
||||||
|
@ -1000,7 +999,7 @@ void LocalStore::registerValidPaths(const ValidPathInfos & infos)
|
||||||
/* Check that the derivation outputs are correct. We can't do
|
/* Check that the derivation outputs are correct. We can't do
|
||||||
this in addValidPath() above, because the references might
|
this in addValidPath() above, because the references might
|
||||||
not be valid yet. */
|
not be valid yet. */
|
||||||
for (auto & i : infos)
|
for (auto & [_, i] : infos)
|
||||||
if (i.path.isDerivation()) {
|
if (i.path.isDerivation()) {
|
||||||
// FIXME: inefficient; we already loaded the derivation in addValidPath().
|
// FIXME: inefficient; we already loaded the derivation in addValidPath().
|
||||||
checkDerivationOutputs(i.path,
|
checkDerivationOutputs(i.path,
|
||||||
|
@ -1014,7 +1013,17 @@ void LocalStore::registerValidPaths(const ValidPathInfos & infos)
|
||||||
error if a cycle is detected and roll back the
|
error if a cycle is detected and roll back the
|
||||||
transaction. Cycles can only occur when a derivation
|
transaction. Cycles can only occur when a derivation
|
||||||
has multiple outputs. */
|
has multiple outputs. */
|
||||||
topoSortPaths(paths);
|
topoSort(paths,
|
||||||
|
{[&](const StorePath & path) {
|
||||||
|
auto i = infos.find(path);
|
||||||
|
return i == infos.end() ? StorePathSet() : i->second.references;
|
||||||
|
}},
|
||||||
|
{[&](const StorePath & path, const StorePath & parent) {
|
||||||
|
return BuildError(
|
||||||
|
"cycle detected in the references of '%s' from '%s'",
|
||||||
|
printStorePath(path),
|
||||||
|
printStorePath(parent));
|
||||||
|
}});
|
||||||
|
|
||||||
txn.commit();
|
txn.commit();
|
||||||
});
|
});
|
||||||
|
|
|
@ -90,9 +90,7 @@ private:
|
||||||
std::unique_ptr<PublicKeys> publicKeys;
|
std::unique_ptr<PublicKeys> publicKeys;
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME: get rid of recursive_mutex, it hides recursive SQLite
|
Sync<State> _state;
|
||||||
// queries.
|
|
||||||
Sync<State, std::recursive_mutex> _state;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
@ -107,6 +107,6 @@ struct ValidPathInfo
|
||||||
virtual ~ValidPathInfo() { }
|
virtual ~ValidPathInfo() { }
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef list<ValidPathInfo> ValidPathInfos;
|
typedef std::map<StorePath, ValidPathInfo> ValidPathInfos;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -516,7 +516,7 @@ static void registerValidity(bool reregister, bool hashGiven, bool canonicalise)
|
||||||
info->narHash = hash.first;
|
info->narHash = hash.first;
|
||||||
info->narSize = hash.second;
|
info->narSize = hash.second;
|
||||||
}
|
}
|
||||||
infos.push_back(std::move(*info));
|
infos.insert_or_assign(info->path, *info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue