aboutsummaryrefslogtreecommitdiff
path: root/src/libstore
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/build/derivation-goal.cc2
-rw-r--r--src/libstore/build/derivation-goal.hh2
-rw-r--r--src/libstore/build/goal.hh2
-rw-r--r--src/libstore/build/local-derivation-goal.cc2
-rw-r--r--src/libstore/build/local-derivation-goal.hh2
-rw-r--r--src/libstore/content-address.cc4
-rw-r--r--src/libstore/content-address.hh4
-rw-r--r--src/libstore/filetransfer.cc5
-rw-r--r--src/libstore/legacy-ssh-store.cc18
-rw-r--r--src/libstore/local-store.cc8
-rw-r--r--src/libstore/remote-store.cc38
-rw-r--r--src/libstore/remote-store.hh2
-rw-r--r--src/libstore/store-api.hh4
13 files changed, 34 insertions, 59 deletions
diff --git a/src/libstore/build/derivation-goal.cc b/src/libstore/build/derivation-goal.cc
index 5e0795115..f879a580e 100644
--- a/src/libstore/build/derivation-goal.cc
+++ b/src/libstore/build/derivation-goal.cc
@@ -108,7 +108,7 @@ DerivationGoal::DerivationGoal(const StorePath & drvPath, const BasicDerivation
}
-DerivationGoal::~DerivationGoal()
+DerivationGoal::~DerivationGoal() noexcept(false)
{
/* Careful: we should never ever throw an exception from a
destructor. */
diff --git a/src/libstore/build/derivation-goal.hh b/src/libstore/build/derivation-goal.hh
index ddb5ee1e3..28aa6afbe 100644
--- a/src/libstore/build/derivation-goal.hh
+++ b/src/libstore/build/derivation-goal.hh
@@ -215,7 +215,7 @@ struct DerivationGoal : public Goal
DerivationGoal(const StorePath & drvPath, const BasicDerivation & drv,
const OutputsSpec & wantedOutputs, Worker & worker,
BuildMode buildMode = bmNormal);
- virtual ~DerivationGoal();
+ virtual ~DerivationGoal() noexcept(false);
void timedOut(Error && ex) override;
diff --git a/src/libstore/build/goal.hh b/src/libstore/build/goal.hh
index 9af083230..5b755c275 100644
--- a/src/libstore/build/goal.hh
+++ b/src/libstore/build/goal.hh
@@ -127,7 +127,7 @@ public:
: worker(worker)
{ }
- virtual ~Goal()
+ virtual ~Goal() noexcept(false)
{
trace("goal destroyed");
}
diff --git a/src/libstore/build/local-derivation-goal.cc b/src/libstore/build/local-derivation-goal.cc
index ef170d815..0709dcbcb 100644
--- a/src/libstore/build/local-derivation-goal.cc
+++ b/src/libstore/build/local-derivation-goal.cc
@@ -96,7 +96,7 @@ void handleDiffHook(
const Path LocalDerivationGoal::homeDir = "/homeless-shelter";
-LocalDerivationGoal::~LocalDerivationGoal()
+LocalDerivationGoal::~LocalDerivationGoal() noexcept(false)
{
/* Careful: we should never ever throw an exception from a
destructor. */
diff --git a/src/libstore/build/local-derivation-goal.hh b/src/libstore/build/local-derivation-goal.hh
index 05c2c3a56..b7f317fb6 100644
--- a/src/libstore/build/local-derivation-goal.hh
+++ b/src/libstore/build/local-derivation-goal.hh
@@ -179,7 +179,7 @@ struct LocalDerivationGoal : public DerivationGoal
using DerivationGoal::DerivationGoal;
- virtual ~LocalDerivationGoal() override;
+ virtual ~LocalDerivationGoal() noexcept(false) override;
/**
* Whether we need to perform hash rewriting if there are valid output paths.
diff --git a/src/libstore/content-address.cc b/src/libstore/content-address.cc
index 77f23b0b3..811ddbed7 100644
--- a/src/libstore/content-address.cc
+++ b/src/libstore/content-address.cc
@@ -157,7 +157,7 @@ size_t StoreReferences::size() const
return (self ? 1 : 0) + others.size();
}
-ContentAddressWithReferences ContentAddressWithReferences::withoutRefs(const ContentAddress & ca) noexcept
+ContentAddressWithReferences ContentAddressWithReferences::withoutRefs(const ContentAddress & ca)
{
return std::visit(overloaded {
[&](const TextIngestionMethod &) -> ContentAddressWithReferences {
@@ -177,7 +177,7 @@ ContentAddressWithReferences ContentAddressWithReferences::withoutRefs(const Con
}
std::optional<ContentAddressWithReferences> ContentAddressWithReferences::fromPartsOpt(
- ContentAddressMethod method, Hash hash, StoreReferences refs) noexcept
+ ContentAddressMethod method, Hash hash, StoreReferences refs)
{
return std::visit(overloaded {
[&](TextIngestionMethod _) -> std::optional<ContentAddressWithReferences> {
diff --git a/src/libstore/content-address.hh b/src/libstore/content-address.hh
index c4d619bdc..200543704 100644
--- a/src/libstore/content-address.hh
+++ b/src/libstore/content-address.hh
@@ -255,7 +255,7 @@ struct ContentAddressWithReferences
* Create a `ContentAddressWithReferences` from a mere
* `ContentAddress`, by claiming no references.
*/
- static ContentAddressWithReferences withoutRefs(const ContentAddress &) noexcept;
+ static ContentAddressWithReferences withoutRefs(const ContentAddress &);
/**
* Create a `ContentAddressWithReferences` from 3 parts:
@@ -270,7 +270,7 @@ struct ContentAddressWithReferences
* returns for invalid combinations.
*/
static std::optional<ContentAddressWithReferences> fromPartsOpt(
- ContentAddressMethod method, Hash hash, StoreReferences refs) noexcept;
+ ContentAddressMethod method, Hash hash, StoreReferences refs);
ContentAddressMethod getMethod() const;
diff --git a/src/libstore/filetransfer.cc b/src/libstore/filetransfer.cc
index b843a95f9..ef2480863 100644
--- a/src/libstore/filetransfer.cc
+++ b/src/libstore/filetransfer.cc
@@ -142,7 +142,7 @@ struct curlFileTransfer : public FileTransfer
template<class T>
void fail(T && e)
{
- failEx(std::make_exception_ptr(std::move(e)));
+ failEx(std::make_exception_ptr(std::forward<T>(e)));
}
LambdaSink finalSink;
@@ -270,6 +270,9 @@ struct curlFileTransfer : public FileTransfer
return 0;
auto count = std::min(size * nitems, request.data->length() - readOffset);
assert(count);
+ // Lint: this is turning a string into a byte array to hand to
+ // curl, which is fine.
+ // NOLINTNEXTLINE(bugprone-not-null-terminated-result)
memcpy(buffer, request.data->data() + readOffset, count);
readOffset += count;
return count;
diff --git a/src/libstore/legacy-ssh-store.cc b/src/libstore/legacy-ssh-store.cc
index 2d8667a85..e06d4e08d 100644
--- a/src/libstore/legacy-ssh-store.cc
+++ b/src/libstore/legacy-ssh-store.cc
@@ -46,7 +46,6 @@ struct LegacySSHStore : public virtual LegacySSHStoreConfig, public virtual Stor
FdSink to;
FdSource from;
ServeProto::Version remoteVersion;
- bool good = true;
/**
* Coercion to `ServeProto::ReadConn`. This makes it easy to use the
@@ -97,8 +96,7 @@ struct LegacySSHStore : public virtual LegacySSHStoreConfig, public virtual Stor
, host(host)
, connections(make_ref<Pool<Connection>>(
std::max(1, (int) maxConnections),
- [this]() { return openConnection(); },
- [](const ref<Connection> & r) { return r->good; }
+ [this]() { return openConnection(); }
))
, master(
host,
@@ -196,12 +194,7 @@ struct LegacySSHStore : public virtual LegacySSHStoreConfig, public virtual Stor
<< info.ultimate
<< info.sigs
<< renderContentAddress(info.ca);
- try {
- copyNAR(source, conn->to);
- } catch (...) {
- conn->good = false;
- throw;
- }
+ copyNAR(source, conn->to);
conn->to.flush();
} else {
@@ -209,12 +202,7 @@ struct LegacySSHStore : public virtual LegacySSHStoreConfig, public virtual Stor
conn->to
<< ServeProto::Command::ImportPaths
<< 1;
- try {
- copyNAR(source, conn->to);
- } catch (...) {
- conn->good = false;
- throw;
- }
+ copyNAR(source, conn->to);
conn->to
<< exportMagic
<< printStorePath(info.path);
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index db3934d5e..f252b449c 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -1315,10 +1315,12 @@ StorePath LocalStore::addToStoreFromDump(Source & source0, std::string_view name
auto oldSize = dump.size();
constexpr size_t chunkSize = 65536;
auto want = std::min(chunkSize, settings.narBufferSize - oldSize);
- if (auto tmp = realloc(dumpBuffer.get(), oldSize + want)) {
- dumpBuffer.release();
- dumpBuffer.reset((char*) tmp);
+
+ auto *toRealloc = dumpBuffer.release();
+ if (auto realloced = realloc(toRealloc, oldSize + want)) {
+ dumpBuffer.reset((char*) realloced);
} else {
+ free(toRealloc);
throw std::bad_alloc();
}
auto got = 0;
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc
index f0dbe8e21..2ce047acd 100644
--- a/src/libstore/remote-store.cc
+++ b/src/libstore/remote-store.cc
@@ -39,9 +39,7 @@ RemoteStore::RemoteStore(const Params & params)
},
[this](const ref<Connection> & r) {
return
- r->to.good()
- && r->from.good()
- && std::chrono::duration_cast<std::chrono::seconds>(
+ std::chrono::duration_cast<std::chrono::seconds>(
std::chrono::steady_clock::now() - r->startTime).count() < maxConnectionAge;
}
))
@@ -155,7 +153,6 @@ void RemoteStore::setOptions(Connection & conn)
RemoteStore::ConnectionHandle::~ConnectionHandle()
{
if (!daemonException && std::uncaught_exceptions()) {
- handle.markBad();
debug("closing daemon connection because of an exception");
}
}
@@ -181,6 +178,10 @@ void RemoteStore::ConnectionHandle::processStderr(Sink * sink, Source * source,
m.find("Derive([") != std::string::npos)
throw Error("%s, this might be because the daemon is too old to understand dependencies on dynamic derivations. Check to see if the raw derivation is in the form '%s'", std::move(m), "DrvWithVersion(..)");
}
+ // the daemon can still handle more requests, so the connection itself
+ // is still valid. the current *handle* however should be considered a
+ // lost cause and abandoned entirely.
+ handle.release();
throw;
}
}
@@ -940,11 +941,6 @@ std::optional<TrustedFlag> RemoteStore::isTrustedClient()
return conn->remoteTrustsUs;
}
-void RemoteStore::flushBadConnections()
-{
- connections->flushBad();
-}
-
RemoteStore::Connection::~Connection()
{
@@ -1073,27 +1069,15 @@ void RemoteStore::ConnectionHandle::withFramedSink(std::function<void(Sink & sin
Finally joinStderrThread([&]()
{
- if (stderrThread.joinable()) {
- stderrThread.join();
- if (ex) {
- try {
- std::rethrow_exception(ex);
- } catch (...) {
- ignoreException();
- }
- }
+ stderrThread.join();
+ if (ex) {
+ std::rethrow_exception(ex);
}
});
- {
- FramedSink sink((*this)->to, ex);
- fun(sink);
- sink.flush();
- }
-
- stderrThread.join();
- if (ex)
- std::rethrow_exception(ex);
+ FramedSink sink((*this)->to, ex);
+ fun(sink);
+ sink.flush();
}
}
diff --git a/src/libstore/remote-store.hh b/src/libstore/remote-store.hh
index f0985fdc1..0cae81e16 100644
--- a/src/libstore/remote-store.hh
+++ b/src/libstore/remote-store.hh
@@ -161,8 +161,6 @@ public:
std::optional<TrustedFlag> isTrustedClient() override;
- void flushBadConnections();
-
struct Connection;
ref<Connection> openConnectionWrapper();
diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh
index 88c182b94..cb9f8e4a6 100644
--- a/src/libstore/store-api.hh
+++ b/src/libstore/store-api.hh
@@ -108,7 +108,7 @@ struct StoreConfig : public Config
static StringSet getDefaultSystemFeatures();
- virtual ~StoreConfig() { }
+ virtual ~StoreConfig() noexcept(false) { }
/**
* The name of this type of store.
@@ -220,7 +220,7 @@ public:
*/
virtual void init() {};
- virtual ~Store() { }
+ virtual ~Store() noexcept(false) { }
virtual std::string getUri() = 0;