diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/build-remote/build-remote.cc | 19 | ||||
-rw-r--r-- | src/libcmd/meson.build | 1 | ||||
-rw-r--r-- | src/libexpr/meson.build | 1 | ||||
-rw-r--r-- | src/libfetchers/meson.build | 1 | ||||
-rw-r--r-- | src/libmain/meson.build | 1 | ||||
-rw-r--r-- | src/libstore/local-store.cc | 7 | ||||
-rw-r--r-- | src/libstore/meson.build | 1 | ||||
-rw-r--r-- | src/libutil/args.cc | 2 | ||||
-rw-r--r-- | src/libutil/args.hh | 7 | ||||
-rw-r--r-- | src/libutil/args/root.hh | 4 | ||||
-rw-r--r-- | src/libutil/meson.build | 1 | ||||
-rw-r--r-- | src/nix/meson.build | 1 | ||||
-rw-r--r-- | src/pch/precompiled-headers.hh | 60 |
13 files changed, 101 insertions, 5 deletions
diff --git a/src/build-remote/build-remote.cc b/src/build-remote/build-remote.cc index f7a159829..fb90403a0 100644 --- a/src/build-remote/build-remote.cc +++ b/src/build-remote/build-remote.cc @@ -3,6 +3,7 @@ #include <algorithm> #include <set> #include <memory> +#include <string_view> #include <tuple> #include <iomanip> #if __APPLE__ @@ -20,9 +21,9 @@ #include "local-store.hh" #include "legacy.hh" #include "experimental-features.hh" +#include "hash.hh" using namespace nix; -using std::cin; static void handleAlarm(int sig) { } @@ -35,9 +36,19 @@ std::string escapeUri(std::string uri) static std::string currentLoad; +static std::string makeLockFilename(const std::string & storeUri) { + // We include 48 bytes of escaped URI to give an idea of what the lock + // is on, then 16 bytes of hash to disambiguate. + // This avoids issues with the escaped URI being very long and causing + // path too long errors, while also avoiding any possibility of collision + // caused by simple truncation. + auto hash = hashString(HashType::htSHA256, storeUri).to_string(Base::Base32, false); + return escapeUri(storeUri).substr(0, 48) + "-" + hash.substr(0, 16); +} + static AutoCloseFD openSlotLock(const Machine & m, uint64_t slot) { - return openLockFile(fmt("%s/%s-%d", currentLoad, escapeUri(m.storeUri), slot), true); + return openLockFile(fmt("%s/%s-%d", currentLoad, makeLockFilename(m.storeUri), slot), true); } static bool allSupportedLocally(Store & store, const std::set<std::string>& requiredFeatures) { @@ -263,7 +274,9 @@ connected: auto inputs = readStrings<PathSet>(source); auto wantedOutputs = readStrings<StringSet>(source); - AutoCloseFD uploadLock = openLockFile(currentLoad + "/" + escapeUri(storeUri) + ".upload-lock", true); + auto lockFileName = currentLoad + "/" + makeLockFilename(storeUri) + ".upload-lock"; + + AutoCloseFD uploadLock = openLockFile(lockFileName, true); { Activity act(*logger, lvlTalkative, actUnknown, fmt("waiting for the upload lock to '%s'", storeUri)); diff --git a/src/libcmd/meson.build b/src/libcmd/meson.build index 4da1b496b..4dc0714c8 100644 --- a/src/libcmd/meson.build +++ b/src/libcmd/meson.build @@ -54,6 +54,7 @@ libcmd = library( nlohmann_json, lix_doc ], + cpp_pch : ['../pch/precompiled-headers.hh'], install : true, # FIXME(Qyriad): is this right? install_rpath : libdir, diff --git a/src/libexpr/meson.build b/src/libexpr/meson.build index fda6fde2c..9a18c7ab3 100644 --- a/src/libexpr/meson.build +++ b/src/libexpr/meson.build @@ -145,6 +145,7 @@ libexpr = library( include_directories : [ '../libmain', ], + cpp_pch : ['../pch/precompiled-headers.hh'], install : true, # FIXME(Qyriad): is this right? install_rpath : libdir, diff --git a/src/libfetchers/meson.build b/src/libfetchers/meson.build index dbb85b84c..365bcd4a7 100644 --- a/src/libfetchers/meson.build +++ b/src/libfetchers/meson.build @@ -30,6 +30,7 @@ libfetchers = library( liblixutil, nlohmann_json, ], + cpp_pch : ['../pch/precompiled-headers.hh'], install : true, # FIXME(Qyriad): is this right? install_rpath : libdir, diff --git a/src/libmain/meson.build b/src/libmain/meson.build index b17247a9d..075aa83b2 100644 --- a/src/libmain/meson.build +++ b/src/libmain/meson.build @@ -20,6 +20,7 @@ libmain = library( liblixutil, liblixstore, ], + cpp_pch : ['../pch/precompiled-headers.hh'], install : true, # FIXME(Qyriad): is this right? install_rpath : libdir, diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index 7bcbe3298..d92fafa1b 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -550,7 +550,12 @@ void LocalStore::openDB(State & state, bool create) if (mode == "wal" ) { /* persist the WAL files when the DB connection is closed. * This allows for read-only connections without any write permissions - * on the state directory to succeed on a closed database. */ + * on the state directory to succeed on a closed database. Setting the + * journal_size_limit to 2^40 bytes results in the WAL files getting + * truncated to 0 on exit and limits the on disk size of the WAL files + * to 2^40 bytes following a checkpoint */ + if (sqlite3_exec(db, "pragma main.journal_size_limit = 1099511627776;", 0, 0, 0) != SQLITE_OK) + SQLiteError::throw_(db, "setting journal_size_limit"); int enable = 1; if (sqlite3_file_control(db, NULL, SQLITE_FCNTL_PERSIST_WAL, &enable) != SQLITE_OK) SQLiteError::throw_(db, "setting persistent WAL mode"); diff --git a/src/libstore/meson.build b/src/libstore/meson.build index f776e9621..65ecacc20 100644 --- a/src/libstore/meson.build +++ b/src/libstore/meson.build @@ -220,6 +220,7 @@ libstore = library( nlohmann_json, ], cpp_args : cpp_args, + cpp_pch : ['../pch/precompiled-headers.hh'], install : true, # FIXME(Qyriad): is this right? install_rpath : libdir, diff --git a/src/libutil/args.cc b/src/libutil/args.cc index 655b3e82f..1342e7c6a 100644 --- a/src/libutil/args.cc +++ b/src/libutil/args.cc @@ -64,7 +64,7 @@ RootArgs & Args::getRoot() while (p->parent) p = p->parent; - auto * res = dynamic_cast<RootArgs *>(p); + auto res = p->asRootArgs(); assert(res); return *res; } diff --git a/src/libutil/args.hh b/src/libutil/args.hh index 35a5238c0..71f8f88fa 100644 --- a/src/libutil/args.hh +++ b/src/libutil/args.hh @@ -244,6 +244,13 @@ protected: */ virtual void initialFlagsProcessed() {} + /** + * Returns this Args as a RootArgs if it is one, or \ref std::nullopt otherwise. + */ + virtual std::optional<std::reference_wrapper<RootArgs>> asRootArgs() { + return std::nullopt; + } + public: void addFlag(Flag && flag); diff --git a/src/libutil/args/root.hh b/src/libutil/args/root.hh index f8124eaff..499ee6df4 100644 --- a/src/libutil/args/root.hh +++ b/src/libutil/args/root.hh @@ -65,6 +65,10 @@ protected: */ std::set<ExperimentalFeature> flagExperimentalFeatures; + virtual std::optional<std::reference_wrapper<RootArgs>> asRootArgs() override { + return *this; + } + private: std::optional<std::string> needsCompletion(std::string_view s); diff --git a/src/libutil/meson.build b/src/libutil/meson.build index 96450fbe2..cfdd0e52c 100644 --- a/src/libutil/meson.build +++ b/src/libutil/meson.build @@ -129,6 +129,7 @@ libutil = library( openssl, nlohmann_json, ], + cpp_pch : ['../pch/precompiled-headers.hh'], implicit_include_directories : true, install : true, ) diff --git a/src/nix/meson.build b/src/nix/meson.build index e41399b5d..45303641f 100644 --- a/src/nix/meson.build +++ b/src/nix/meson.build @@ -89,6 +89,7 @@ nix = executable( boehm, nlohmann_json, ], + cpp_pch : ['../pch/precompiled-headers.hh'], install : true, # FIXME(Qyriad): is this right? install_rpath : libdir, diff --git a/src/pch/precompiled-headers.hh b/src/pch/precompiled-headers.hh new file mode 100644 index 000000000..f52f1cab8 --- /dev/null +++ b/src/pch/precompiled-headers.hh @@ -0,0 +1,60 @@ +#include <algorithm> +#include <array> +#include <atomic> +#include <cassert> +#include <cctype> +#include <chrono> +#include <climits> +#include <cmath> +#include <condition_variable> +#include <cstddef> +#include <cstdint> +#include <cstdio> +#include <cstdlib> +#include <cstring> +#include <exception> +#include <functional> +#include <future> +#include <iostream> +#include <limits> +#include <list> +#include <locale> +#include <map> +#include <memory> +#include <mutex> +#include <numeric> +#include <optional> +#include <queue> +#include <random> +#include <regex> +#include <set> +#include <sstream> +#include <stack> +#include <stdexcept> +#include <string> +#include <thread> +#include <unordered_map> +#include <unordered_set> +#include <vector> + +#include <boost/format.hpp> + +#include <dirent.h> +#include <errno.h> +#include <fcntl.h> +#include <grp.h> +#include <netdb.h> +#include <pwd.h> +#include <signal.h> +#include <sys/resource.h> +#include <sys/select.h> +#include <sys/socket.h> +#include <sys/stat.h> +#include <sys/time.h> +#include <sys/types.h> +#include <sys/utsname.h> +#include <sys/wait.h> +#include <termios.h> +#include <unistd.h> + +#include <nlohmann/json.hpp> |