From 176911102ce2c0be06bbfed9099f364d71c3c679 Mon Sep 17 00:00:00 2001 From: Ben Burdette Date: Mon, 13 Sep 2021 11:57:25 -0600 Subject: printEnvPosChain --- src/libutil/error.hh | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/libutil') diff --git a/src/libutil/error.hh b/src/libutil/error.hh index ff58d3e00..b6670c8b2 100644 --- a/src/libutil/error.hh +++ b/src/libutil/error.hh @@ -100,6 +100,12 @@ struct ErrPos { } }; +std::optional getCodeLines(const ErrPos & errPos); +void printCodeLines(std::ostream & out, + const string & prefix, + const ErrPos & errPos, + const LinesOfCode & loc); + struct Trace { std::optional pos; hintformat hint; -- cgit v1.2.3 From b4a59a5eec5bdb94ee2bbc8365f024d5787abd60 Mon Sep 17 00:00:00 2001 From: Ben Burdette Date: Wed, 22 Dec 2021 15:38:49 -0700 Subject: DebugStackTracker class in one place --- src/libutil/error.cc | 2 ++ src/libutil/logging.hh | 1 + 2 files changed, 3 insertions(+) (limited to 'src/libutil') diff --git a/src/libutil/error.cc b/src/libutil/error.cc index 203d79087..c2b9d2707 100644 --- a/src/libutil/error.cc +++ b/src/libutil/error.cc @@ -221,6 +221,8 @@ static std::string indent(std::string_view indentFirst, std::string_view indentR std::ostream & showErrorInfo(std::ostream & out, const ErrorInfo & einfo, bool showTrace) { + std::cout << "showErrorInfo showTrace: " << showTrace << std::endl; + std::string prefix; switch (einfo.level) { case Verbosity::lvlError: { diff --git a/src/libutil/logging.hh b/src/libutil/logging.hh index 96ad69790..f10a9af38 100644 --- a/src/libutil/logging.hh +++ b/src/libutil/logging.hh @@ -38,6 +38,7 @@ typedef uint64_t ActivityId; struct LoggerSettings : Config { Setting showTrace{ + // this, false, "show-trace", this, false, "show-trace", R"( Where Nix should print out a stack trace in case of Nix -- cgit v1.2.3 From bc20e54e0044e08c68a7af1f1e12d001baba8a74 Mon Sep 17 00:00:00 2001 From: Ben Burdette Date: Wed, 22 Dec 2021 19:40:08 -0700 Subject: stack traces basically working --- src/libutil/error.hh | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/libutil') diff --git a/src/libutil/error.hh b/src/libutil/error.hh index b6670c8b2..06301f709 100644 --- a/src/libutil/error.hh +++ b/src/libutil/error.hh @@ -106,6 +106,9 @@ void printCodeLines(std::ostream & out, const ErrPos & errPos, const LinesOfCode & loc); +void printAtPos(const ErrPos & pos, std::ostream & out); + + struct Trace { std::optional pos; hintformat hint; -- cgit v1.2.3 From 4610e02d04c9f41ac355d2ca6a27d3a631ffefc6 Mon Sep 17 00:00:00 2001 From: Ben Burdette Date: Mon, 27 Dec 2021 18:12:46 -0700 Subject: remove debug code --- src/libutil/error.cc | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/libutil') diff --git a/src/libutil/error.cc b/src/libutil/error.cc index c2b9d2707..203d79087 100644 --- a/src/libutil/error.cc +++ b/src/libutil/error.cc @@ -221,8 +221,6 @@ static std::string indent(std::string_view indentFirst, std::string_view indentR std::ostream & showErrorInfo(std::ostream & out, const ErrorInfo & einfo, bool showTrace) { - std::cout << "showErrorInfo showTrace: " << showTrace << std::endl; - std::string prefix; switch (einfo.level) { case Verbosity::lvlError: { -- cgit v1.2.3 From 5954cbf3e9dca0e3b84e4bf2def74abb3d6f80cd Mon Sep 17 00:00:00 2001 From: Ben Burdette Date: Mon, 27 Dec 2021 18:29:55 -0700 Subject: more cleanup --- src/libutil/logging.hh | 1 - 1 file changed, 1 deletion(-) (limited to 'src/libutil') diff --git a/src/libutil/logging.hh b/src/libutil/logging.hh index f10a9af38..96ad69790 100644 --- a/src/libutil/logging.hh +++ b/src/libutil/logging.hh @@ -38,7 +38,6 @@ typedef uint64_t ActivityId; struct LoggerSettings : Config { Setting showTrace{ - // this, false, "show-trace", this, false, "show-trace", R"( Where Nix should print out a stack trace in case of Nix -- cgit v1.2.3 From c94180386182c8cd9e2a4a8053afb5938940c1d2 Mon Sep 17 00:00:00 2001 From: Ben Burdette Date: Fri, 29 Apr 2022 11:27:38 -0600 Subject: spacing --- src/libutil/error.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libutil') diff --git a/src/libutil/error.hh b/src/libutil/error.hh index 6eb80fb9e..a53e9802e 100644 --- a/src/libutil/error.hh +++ b/src/libutil/error.hh @@ -99,6 +99,7 @@ struct ErrPos { }; std::optional getCodeLines(const ErrPos & errPos); + void printCodeLines(std::ostream & out, const std::string & prefix, const ErrPos & errPos, @@ -106,7 +107,6 @@ void printCodeLines(std::ostream & out, void printAtPos(const ErrPos & pos, std::ostream & out); - struct Trace { std::optional pos; hintformat hint; -- cgit v1.2.3 From 667074b5867ffe40e3f1c59bd8e4ebf259f86aaa Mon Sep 17 00:00:00 2001 From: Ben Burdette Date: Mon, 16 May 2022 09:20:51 -0600 Subject: first whack at passing evalState as an arg to debuggerHook. --- src/libutil/ref.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libutil') diff --git a/src/libutil/ref.hh b/src/libutil/ref.hh index f9578afc7..bf26321db 100644 --- a/src/libutil/ref.hh +++ b/src/libutil/ref.hh @@ -7,7 +7,7 @@ namespace nix { /* A simple non-nullable reference-counted pointer. Actually a wrapper - around std::shared_ptr that prevents non-null constructions. */ + around std::shared_ptr that prevents null constructions. */ template class ref { -- cgit v1.2.3 From 5b8c1deb18e0e6fc7a83fb8101cf5fc8dba38843 Mon Sep 17 00:00:00 2001 From: Tony Olagbaiye Date: Fri, 16 Oct 2020 00:35:24 +0100 Subject: fetchTree: Allow fetching plain files Add a new `file` fetcher type, which will fetch a plain file over http(s), or from the local file. Because plain `http(s)://` or `file://` urls can already correspond to `tarball` inputs (if the path ends-up with a know archive extension), the URL parsing logic is a bit convuluted in that: - {http,https,file}:// urls will be interpreted as either a tarball or a file input, depending on the extensions of the path part (so `https://foo.com/bar` will be a `file` input and `https://foo.com/bar.tar.gz` as a `tarball` input) - `file+{something}://` urls will be interpreted as `file` urls (with the `file+` part removed) - `tarball+{something}://` urls will be interpreted as `tarball` urls (with the `tarball+` part removed) Fix #3785 Co-Authored-By: Tony Olagbaiye --- src/libutil/url.cc | 18 ++++++++++++++++++ src/libutil/url.hh | 15 +++++++++++++++ 2 files changed, 33 insertions(+) (limited to 'src/libutil') diff --git a/src/libutil/url.cc b/src/libutil/url.cc index f6232d255..5b7abeb49 100644 --- a/src/libutil/url.cc +++ b/src/libutil/url.cc @@ -1,6 +1,7 @@ #include "url.hh" #include "url-parts.hh" #include "util.hh" +#include "split.hh" namespace nix { @@ -136,4 +137,21 @@ bool ParsedURL::operator ==(const ParsedURL & other) const && fragment == other.fragment; } +/** + * Parse a URL scheme of the form '(applicationScheme\+)?transportScheme' + * into a tuple '(applicationScheme, transportScheme)' + * + * > parseUrlScheme("http") == ParsedUrlScheme{ {}, "http"} + * > parseUrlScheme("tarball+http") == ParsedUrlScheme{ {"tarball"}, "http"} + */ +ParsedUrlScheme parseUrlScheme(std::string_view scheme) +{ + auto application = splitPrefixTo(scheme, '+'); + auto transport = scheme; + return ParsedUrlScheme { + .application = application, + .transport = transport, + }; +} + } diff --git a/src/libutil/url.hh b/src/libutil/url.hh index 6e77142e3..2a9fb34c1 100644 --- a/src/libutil/url.hh +++ b/src/libutil/url.hh @@ -27,4 +27,19 @@ std::map decodeQuery(const std::string & query); ParsedURL parseURL(const std::string & url); +/* + * Although that’s not really standardized anywhere, an number of tools + * use a scheme of the form 'x+y' in urls, where y is the “transport layer” + * scheme, and x is the “application layer” scheme. + * + * For example git uses `git+https` to designate remotes using a Git + * protocol over http. + */ +struct ParsedUrlScheme { + std::optional application; + std::string_view transport; +}; + +ParsedUrlScheme parseUrlScheme(std::string_view scheme); + } -- cgit v1.2.3 From c156155239dafd68104a843916d8d737e6e61bed Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Thu, 26 May 2022 10:53:06 +0200 Subject: createUnixDomainSocket: listen(unix, 5 -> 100) This solves the error error: cannot connect to socket at '/nix/var/nix/daemon-socket/socket': Connection refused on build farm systems that are loaded but operating normally. I've seen this happen on an M1 mac running a loaded hercules-ci-agent. Hercules CI uses multiple worker processes, which may connect to the Nix daemon around the same time. It's not unthinkable that the Nix daemon listening process isn't scheduled until after 6 workers try to connect, especially on a system under load with many workers. Is the increase safe? The number is the number of connections that the kernel will buffer while the listening process hasn't `accept`-ed them yet. It did not - and will not - restrict the total number of daemon forks that a client can create. History The number 5 has remained unchanged since the introduction in nix-worker with 0130ef88ea in 2006. --- src/libutil/util.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libutil') diff --git a/src/libutil/util.cc b/src/libutil/util.cc index d4d78329d..1c19938a8 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -1818,7 +1818,7 @@ AutoCloseFD createUnixDomainSocket(const Path & path, mode_t mode) if (chmod(path.c_str(), mode) == -1) throw SysError("changing permissions on '%1%'", path); - if (listen(fdSocket.get(), 5) == -1) + if (listen(fdSocket.get(), 100) == -1) throw SysError("cannot listen on socket '%1%'", path); return fdSocket; -- cgit v1.2.3 From b36d5172cb2cd99f8ae5262b3e3536cceac76b50 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Thu, 26 May 2022 18:36:10 +0100 Subject: src/libutil/json.cc: add missing include for gcc-13 Without the change llvm build fails on this week's gcc-13 snapshot as: src/libutil/json.cc: In function 'void nix::toJSON(std::ostream&, const char*, const char*)': src/libutil/json.cc:33:22: error: 'uint16_t' was not declared in this scope 33 | put(hex[(uint16_t(*i) >> 12) & 0xf]); | ^~~~~~~~ src/libutil/json.cc:5:1: note: 'uint16_t' is defined in header ''; did you forget to '#include '? 4 | #include +++ |+#include 5 | --- src/libutil/json.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'src/libutil') diff --git a/src/libutil/json.cc b/src/libutil/json.cc index 3a981376f..b0a5d7e75 100644 --- a/src/libutil/json.cc +++ b/src/libutil/json.cc @@ -1,6 +1,7 @@ #include "json.hh" #include +#include #include namespace nix { -- cgit v1.2.3