forked from OSchip/llvm-project
[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
This commit is contained in:
parent
ad9091c5fa
commit
1a5dfb7db2
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue