forked from lix-project/lix
Merge pull request #7478 from hercules-ci/make-sure-initNix-called
libstore: Make sure that initNix has been called
This commit is contained in:
commit
fb8fc6fda6
|
@ -12,6 +12,7 @@ namespace nix {
|
||||||
class LibExprTest : public ::testing::Test {
|
class LibExprTest : public ::testing::Test {
|
||||||
public:
|
public:
|
||||||
static void SetUpTestSuite() {
|
static void SetUpTestSuite() {
|
||||||
|
initLibStore();
|
||||||
initGC();
|
initGC();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -235,6 +235,7 @@ void initNix()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
preloadNSS();
|
preloadNSS();
|
||||||
|
initLibStore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -291,4 +291,18 @@ void initPlugins()
|
||||||
settings.pluginFiles.pluginsLoaded = true;
|
settings.pluginFiles.pluginsLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool initLibStoreDone = false;
|
||||||
|
|
||||||
|
void assertLibStoreInitialized() {
|
||||||
|
if (!initLibStoreDone) {
|
||||||
|
printError("The program must call nix::initNix() before calling any libstore library functions.");
|
||||||
|
abort();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void initLibStore() {
|
||||||
|
initLibStoreDone = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -987,4 +987,12 @@ std::vector<Path> getUserConfigFiles();
|
||||||
|
|
||||||
extern const std::string nixVersion;
|
extern const std::string nixVersion;
|
||||||
|
|
||||||
|
/* NB: This is not sufficient. You need to call initNix() */
|
||||||
|
void initLibStore();
|
||||||
|
|
||||||
|
/* It's important to initialize before doing _anything_, which is why we
|
||||||
|
call upon the programmer to handle this correctly. However, we only add
|
||||||
|
this in a key locations, so as not to litter the code. */
|
||||||
|
void assertLibStoreInitialized();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -458,6 +458,7 @@ Store::Store(const Params & params)
|
||||||
: StoreConfig(params)
|
: StoreConfig(params)
|
||||||
, state({(size_t) pathInfoCacheSize})
|
, state({(size_t) pathInfoCacheSize})
|
||||||
{
|
{
|
||||||
|
assertLibStoreInitialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue