From e0d25449e3acacc2c85b73fa5018c620539f6598 Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Sat, 1 Aug 2020 20:22:33 -0400 Subject: fix(3p/nix): Don't reuse ClientContext It turns out these aren't supposed to be reused after the first request - reusing it was causing things to blow up. Change-Id: I935f1ee82ed4e7f26528ae105c8fa2501fa81b97 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1559 Reviewed-by: kanepyork Tested-by: BuildkiteCI --- third_party/nix/src/libstore/rpc-store.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'third_party/nix/src/libstore') diff --git a/third_party/nix/src/libstore/rpc-store.cc b/third_party/nix/src/libstore/rpc-store.cc index 080a1e0a5d00..ba7d77fb0839 100644 --- a/third_party/nix/src/libstore/rpc-store.cc +++ b/third_party/nix/src/libstore/rpc-store.cc @@ -30,7 +30,6 @@ using grpc::ClientContext; using nix::proto::WorkerService; static google::protobuf::Empty kEmpty; -static ClientContext ctx; proto::StorePath StorePath(const Path& path) { proto::StorePath store_path; @@ -65,12 +64,14 @@ void const RpcStore::SuccessOrThrow(const grpc::Status& status) const { } bool RpcStore::isValidPathUncached(const Path& path) { + ClientContext ctx; proto::IsValidPathResponse resp; SuccessOrThrow(stub_->IsValidPath(&ctx, StorePath(path), &resp)); return resp.is_valid(); } PathSet RpcStore::queryAllValidPaths() { + ClientContext ctx; proto::StorePaths paths; SuccessOrThrow(stub_->QueryAllValidPaths(&ctx, kEmpty, &paths)); return FillFrom(paths.paths()); @@ -78,6 +79,7 @@ PathSet RpcStore::queryAllValidPaths() { PathSet RpcStore::queryValidPaths(const PathSet& paths, SubstituteFlag maybeSubstitute) { + ClientContext ctx; proto::StorePaths store_paths; for (const auto& path : paths) { store_paths.add_paths(path); @@ -90,6 +92,7 @@ PathSet RpcStore::queryValidPaths(const PathSet& paths, void RpcStore::queryPathInfoUncached( const Path& path, Callback> callback) noexcept { + ClientContext ctx; proto::StorePath store_path; store_path.set_path(path); @@ -127,24 +130,28 @@ void RpcStore::queryPathInfoUncached( } void RpcStore::queryReferrers(const Path& path, PathSet& referrers) { + ClientContext ctx; proto::StorePaths paths; SuccessOrThrow(stub_->QueryReferrers(&ctx, StorePath(path), &paths)); referrers.insert(paths.paths().begin(), paths.paths().end()); } PathSet RpcStore::queryValidDerivers(const Path& path) { + ClientContext ctx; proto::StorePaths paths; SuccessOrThrow(stub_->QueryValidDerivers(&ctx, StorePath(path), &paths)); return FillFrom(paths.paths()); } PathSet RpcStore::queryDerivationOutputs(const Path& path) { + ClientContext ctx; proto::StorePaths paths; SuccessOrThrow(stub_->QueryDerivationOutputs(&ctx, StorePath(path), &paths)); return FillFrom(paths.paths()); } StringSet RpcStore::queryDerivationOutputNames(const Path& path) { + ClientContext ctx; proto::DerivationOutputNames output_names; SuccessOrThrow( stub_->QueryDerivationOutputNames(&ctx, StorePath(path), &output_names)); @@ -152,6 +159,7 @@ StringSet RpcStore::queryDerivationOutputNames(const Path& path) { } Path RpcStore::queryPathFromHashPart(const std::string& hashPart) { + ClientContext ctx; proto::StorePath path; proto::HashPart proto_hash_part; proto_hash_part.set_hash_part(hashPart); @@ -160,6 +168,7 @@ Path RpcStore::queryPathFromHashPart(const std::string& hashPart) { } PathSet RpcStore::querySubstitutablePaths(const PathSet& paths) { + ClientContext ctx; proto::StorePaths result; SuccessOrThrow( stub_->QuerySubstitutablePaths(&ctx, StorePaths(paths), &result)); @@ -168,6 +177,7 @@ PathSet RpcStore::querySubstitutablePaths(const PathSet& paths) { void RpcStore::querySubstitutablePathInfos(const PathSet& paths, SubstitutablePathInfos& infos) { + ClientContext ctx; proto::SubstitutablePathInfos result; SuccessOrThrow( stub_->QuerySubstitutablePathInfos(&ctx, StorePaths(paths), &result)); -- cgit 1.4.1