[clang-tools-extra] 1a5dfb7 - [clangd][remote] Add flag to set idletimeout
Kadir Cetinkaya via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 26 06:05:11 PST 2021
Author: Kadir Cetinkaya
Date: 2021-02-26T15:04:44+01:00
New Revision: 1a5dfb7db23e3c0aec0b4356a60b9d6b7c8f9683
URL: https://github.com/llvm/llvm-project/commit/1a5dfb7db23e3c0aec0b4356a60b9d6b7c8f9683
DIFF: https://github.com/llvm/llvm-project/commit/1a5dfb7db23e3c0aec0b4356a60b9d6b7c8f9683.diff
LOG: [clangd][remote] Add flag to set idletimeout
By default gRPC has no idletimeout and some firewalls might drop idle
connections after a certain period. This results in idle clients
shouting into void until server resets the connection.
Differential Revision: https://reviews.llvm.org/D97536
Added:
Modified:
clang-tools-extra/clangd/index/remote/server/Server.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/index/remote/server/Server.cpp b/clang-tools-extra/clangd/index/remote/server/Server.cpp
index 20b140e00787..3de2c38f7c08 100644
--- a/clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ b/clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -80,6 +80,11 @@ llvm::cl::opt<std::string> ServerAddress(
"server-address", llvm::cl::init("0.0.0.0:50051"),
llvm::cl::desc("Address of the invoked server. Defaults to 0.0.0.0:50051"));
+llvm::cl::opt<size_t> IdleTimeoutSeconds(
+ "idle-timeout", llvm::cl::init(8 * 60),
+ llvm::cl::desc("Maximum time a channel may stay idle until server closes "
+ "the connection, in seconds. Defaults to 480."));
+
static Key<grpc::ServerContext *> CurrentRequest;
class RemoteIndexServer final : public v1::SymbolIndex::Service {
@@ -311,6 +316,8 @@ void runServerAndWait(clangd::SymbolIndex &Index, llvm::StringRef ServerAddress,
grpc::ServerBuilder Builder;
Builder.AddListeningPort(ServerAddress.str(),
grpc::InsecureServerCredentials());
+ Builder.AddChannelArgument(GRPC_ARG_MAX_CONNECTION_IDLE_MS,
+ IdleTimeoutSeconds * 1000);
Builder.RegisterService(&Service);
std::unique_ptr<grpc::Server> Server(Builder.BuildAndStart());
log("Server listening on {0}", ServerAddress);
More information about the cfe-commits
mailing list