[clangd][remote-client] Set HasMore to true for failure

Currently client was setting the HasMore to true iff stream said so.
Hence if we had a broken stream for whatever reason (e.g. hitting deadline for a
huge response), HasMore would be false, which is semantically incorrect (e.g.
will throw rename off).

Differential Revision: https://reviews.llvm.org/D101915
This commit is contained in:
Kadir Cetinkaya 2021-05-05 17:46:46 +02:00
parent daf3cb3b8a
commit 888307ee62
No known key found for this signature in database
GPG Key ID: E39E36B8D2057ED6
1 changed files with 6 additions and 3 deletions

View File

@ -64,7 +64,10 @@ class IndexClient : public clangd::SymbolIndex {
StreamingCall<RequestT, ReplyT> RPCCall,
CallbackT Callback) const {
updateConnectionStatus();
bool FinalResult = false;
// We initialize to true because stream might be broken before we see the
// final message. In such a case there are actually more results on the
// stream, but we couldn't get to them.
bool HasMore = true;
trace::Span Tracer(RequestT::descriptor()->name());
const auto RPCRequest = ProtobufMarshaller->toProtobuf(Request);
SPAN_ATTACH(Tracer, "Request", RPCRequest.DebugString());
@ -82,7 +85,7 @@ class IndexClient : public clangd::SymbolIndex {
unsigned FailedToParse = 0;
while (Reader->Read(&Reply)) {
if (!Reply.has_stream_result()) {
FinalResult = Reply.final_result().has_more();
HasMore = Reply.final_result().has_more();
continue;
}
auto Response = ProtobufMarshaller->fromProtobuf(Reply.stream_result());
@ -105,7 +108,7 @@ class IndexClient : public clangd::SymbolIndex {
SPAN_ATTACH(Tracer, "Successful", Successful);
SPAN_ATTACH(Tracer, "Failed to parse", FailedToParse);
updateConnectionStatus();
return FinalResult;
return HasMore;
}
public: