mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-14 02:06:16 +02:00
build-remote: only allocate storeUri once
also it's probably not much overhead compared to the networking stuff it, but it's less code at least.
This commit is contained in:
parent
99c20d6624
commit
9b5ce9acc2
1 changed files with 11 additions and 12 deletions
|
@ -101,7 +101,7 @@ static int main_build_remote(int argc, char * * argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<StorePath> drvPath;
|
std::optional<StorePath> drvPath;
|
||||||
StoreReference storeUri;
|
std::string storeUri;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
||||||
|
@ -234,17 +234,16 @@ static int main_build_remote(int argc, char * * argv)
|
||||||
lock = -1;
|
lock = -1;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
storeUri = bestMachine->storeUri.render();
|
||||||
|
|
||||||
Activity act(*logger, lvlTalkative, actUnknown, fmt("connecting to '%s'", bestMachine->storeUri.render()));
|
Activity act(*logger, lvlTalkative, actUnknown, fmt("connecting to '%s'", storeUri));
|
||||||
|
|
||||||
sshStore = bestMachine->openStore();
|
sshStore = bestMachine->openStore();
|
||||||
sshStore->connect();
|
sshStore->connect();
|
||||||
storeUri = bestMachine->storeUri;
|
|
||||||
|
|
||||||
} catch (std::exception & e) {
|
} catch (std::exception & e) {
|
||||||
auto msg = chomp(drainFD(5, false));
|
auto msg = chomp(drainFD(5, false));
|
||||||
printError("cannot build on '%s': %s%s",
|
printError("cannot build on '%s': %s%s",
|
||||||
bestMachine->storeUri.render(), e.what(),
|
storeUri, e.what(),
|
||||||
msg.empty() ? "" : ": " + msg);
|
msg.empty() ? "" : ": " + msg);
|
||||||
bestMachine->enabled = false;
|
bestMachine->enabled = false;
|
||||||
continue;
|
continue;
|
||||||
|
@ -259,7 +258,7 @@ connected:
|
||||||
|
|
||||||
assert(sshStore);
|
assert(sshStore);
|
||||||
|
|
||||||
std::cerr << "# accept\n" << storeUri.render() << "\n";
|
std::cerr << "# accept\n" << storeUri << "\n";
|
||||||
|
|
||||||
auto inputs = readStrings<PathSet>(source);
|
auto inputs = readStrings<PathSet>(source);
|
||||||
auto wantedOutputs = readStrings<StringSet>(source);
|
auto wantedOutputs = readStrings<StringSet>(source);
|
||||||
|
@ -270,17 +269,17 @@ connected:
|
||||||
uploadLock = openLockFile(currentLoad + "/" + escapeUri(fileName) + ".upload-lock", true);
|
uploadLock = openLockFile(currentLoad + "/" + escapeUri(fileName) + ".upload-lock", true);
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
setUpdateLock(storeUri.render());
|
setUpdateLock(storeUri);
|
||||||
} catch (SysError & e) {
|
} catch (SysError & e) {
|
||||||
if (e.errNo != ENAMETOOLONG) throw;
|
if (e.errNo != ENAMETOOLONG) throw;
|
||||||
// Try again hashing the store URL so we have a shorter path
|
// Try again hashing the store URL so we have a shorter path
|
||||||
auto h = hashString(HashAlgorithm::MD5, storeUri.render());
|
auto h = hashString(HashAlgorithm::MD5, storeUri);
|
||||||
setUpdateLock(h.to_string(HashFormat::Base64, false));
|
setUpdateLock(h.to_string(HashFormat::Base64, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Activity act(*logger, lvlTalkative, actUnknown, fmt("waiting for the upload lock to '%s'", storeUri.render()));
|
Activity act(*logger, lvlTalkative, actUnknown, fmt("waiting for the upload lock to '%s'", storeUri));
|
||||||
|
|
||||||
auto old = signal(SIGALRM, handleAlarm);
|
auto old = signal(SIGALRM, handleAlarm);
|
||||||
alarm(15 * 60);
|
alarm(15 * 60);
|
||||||
|
@ -293,7 +292,7 @@ connected:
|
||||||
auto substitute = settings.buildersUseSubstitutes ? Substitute : NoSubstitute;
|
auto substitute = settings.buildersUseSubstitutes ? Substitute : NoSubstitute;
|
||||||
|
|
||||||
{
|
{
|
||||||
Activity act(*logger, lvlTalkative, actUnknown, fmt("copying dependencies to '%s'", storeUri.render()));
|
Activity act(*logger, lvlTalkative, actUnknown, fmt("copying dependencies to '%s'", storeUri));
|
||||||
copyPaths(*store, *sshStore, store->parseStorePathSet(inputs), NoRepair, NoCheckSigs, substitute);
|
copyPaths(*store, *sshStore, store->parseStorePathSet(inputs), NoRepair, NoCheckSigs, substitute);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,7 +330,7 @@ connected:
|
||||||
optResult = sshStore->buildDerivation(*drvPath, (const BasicDerivation &) drv);
|
optResult = sshStore->buildDerivation(*drvPath, (const BasicDerivation &) drv);
|
||||||
auto & result = *optResult;
|
auto & result = *optResult;
|
||||||
if (!result.success())
|
if (!result.success())
|
||||||
throw Error("build of '%s' on '%s' failed: %s", store->printStorePath(*drvPath), storeUri.render(), result.errorMsg);
|
throw Error("build of '%s' on '%s' failed: %s", store->printStorePath(*drvPath), storeUri, result.errorMsg);
|
||||||
} else {
|
} else {
|
||||||
copyClosure(*store, *sshStore, StorePathSet {*drvPath}, NoRepair, NoCheckSigs, substitute);
|
copyClosure(*store, *sshStore, StorePathSet {*drvPath}, NoRepair, NoCheckSigs, substitute);
|
||||||
auto res = sshStore->buildPathsWithResults({
|
auto res = sshStore->buildPathsWithResults({
|
||||||
|
@ -374,7 +373,7 @@ connected:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!missingPaths.empty()) {
|
if (!missingPaths.empty()) {
|
||||||
Activity act(*logger, lvlTalkative, actUnknown, fmt("copying outputs from '%s'", storeUri.render()));
|
Activity act(*logger, lvlTalkative, actUnknown, fmt("copying outputs from '%s'", storeUri));
|
||||||
if (auto localStore = store.dynamic_pointer_cast<LocalStore>())
|
if (auto localStore = store.dynamic_pointer_cast<LocalStore>())
|
||||||
for (auto & path : missingPaths)
|
for (auto & path : missingPaths)
|
||||||
localStore->locksHeld.insert(store->printStorePath(path)); /* FIXME: ugly */
|
localStore->locksHeld.insert(store->printStorePath(path)); /* FIXME: ugly */
|
||||||
|
|
Loading…
Reference in a new issue