diff --git a/clang-tools-extra/clangd/index/remote/server/Server.cpp b/clang-tools-extra/clangd/index/remote/server/Server.cpp --- a/clang-tools-extra/clangd/index/remote/server/Server.cpp +++ b/clang-tools-extra/clangd/index/remote/server/Server.cpp @@ -80,6 +80,11 @@ "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 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 CurrentRequest; class RemoteIndexServer final : public v1::SymbolIndex::Service { @@ -311,6 +316,8 @@ 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 Server(Builder.BuildAndStart()); log("Server listening on {0}", ServerAddress);