fix race with getStore() (#45)

by calling it once before starting the server

closes: #44
This commit is contained in:
Zoe Zuser 2025-05-28 15:02:52 -04:00 committed by GitHub
parent 7b7cf5cd08
commit 1d21f73a2d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 0 deletions

View File

@ -37,6 +37,12 @@ static ref<Store> getStore()
extern "C" {
// Must be called once before the server is stated to avoid races
void initStore()
{
getStore();
}
void freeString(struct string * const input)
{
free((void *) input->data);

View File

@ -341,6 +341,8 @@ main = do
options@Options{ priority, timeout, verbosity } <- do
Options.execParser Options.parserInfo
Nix.initStore
storeDirectory <- Nix.getStoreDir
secretKeyFile <- Environment.lookupEnv "NIX_SECRET_KEY_FILE"

View File

@ -34,6 +34,8 @@ import qualified Foreign
#include "nix.hh"
foreign import ccall "initStore" initStore :: IO ()
foreign import ccall "freeString" freeString :: Ptr String_ -> IO ()
data String_ = String_ { data_ :: Ptr CChar, size :: CSize }