mirror of
https://github.com/NixOS/nix.git
synced 2025-11-16 23:42:43 +01:00
Pool<T>: Allow a maximum pool size
This commit is contained in:
parent
e292144d46
commit
d5626bf4c1
4 changed files with 74 additions and 33 deletions
|
|
@ -14,8 +14,8 @@
|
|||
#include <sys/un.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace nix {
|
||||
|
|
@ -39,8 +39,8 @@ template<class T> T readStorePaths(Source & from)
|
|||
template PathSet readStorePaths(Source & from);
|
||||
|
||||
|
||||
RemoteStore::RemoteStore()
|
||||
: connections(make_ref<Pool<Connection>>([this]() { return openConnection(); }))
|
||||
RemoteStore::RemoteStore(size_t maxConnections)
|
||||
: connections(make_ref<Pool<Connection>>(maxConnections, [this]() { return openConnection(); }))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -116,18 +116,6 @@ ref<RemoteStore::Connection> RemoteStore::openConnection(bool reserveSpace)
|
|||
}
|
||||
|
||||
|
||||
RemoteStore::~RemoteStore()
|
||||
{
|
||||
try {
|
||||
//to.flush();
|
||||
//fdSocket.close();
|
||||
// FIXME: close pool
|
||||
} catch (...) {
|
||||
ignoreException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RemoteStore::setOptions(ref<Connection> conn)
|
||||
{
|
||||
conn->to << wopSetOptions
|
||||
|
|
@ -568,6 +556,18 @@ bool RemoteStore::verifyStore(bool checkContents, bool repair)
|
|||
return readInt(conn->from) != 0;
|
||||
}
|
||||
|
||||
|
||||
RemoteStore::Connection::~Connection()
|
||||
{
|
||||
try {
|
||||
to.flush();
|
||||
fd.close();
|
||||
} catch (...) {
|
||||
ignoreException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RemoteStore::Connection::processStderr(Sink * sink, Source * source)
|
||||
{
|
||||
to.flush();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue