[PATCH] D68702: [clangd] Make sure ReplyCallbacks are destroyed before RequestCancelersMutex
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 9 07:02:11 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9a3a87d18975: [clangd] Make sure ReplyCallbacks are destroyed before RequestCancelersMutex (authored by kadircet).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D68702/new/
https://reviews.llvm.org/D68702
Files:
clang-tools-extra/clangd/ClangdLSPServer.cpp
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===================================================================
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -371,16 +371,6 @@
llvm::StringMap<std::function<void(llvm::json::Value)>> Notifications;
llvm::StringMap<std::function<void(llvm::json::Value, ReplyOnce)>> Calls;
- // The maximum number of callbacks held in clangd.
- //
- // We bound the maximum size to the pending map to prevent memory leakage
- // for cases where LSP clients don't reply for the request.
- static constexpr int MaxReplayCallbacks = 100;
- mutable std::mutex CallMutex;
- int NextCallID = 0; /* GUARDED_BY(CallMutex) */
- std::deque<std::pair</*RequestID*/ int,
- /*ReplyHandler*/ Callback<llvm::json::Value>>>
- ReplyCallbacks; /* GUARDED_BY(CallMutex) */
// Method calls may be cancelled by ID, so keep track of their state.
// This needs a mutex: handlers may finish on a different thread, and that's
@@ -432,6 +422,19 @@
}));
}
+ // The maximum number of callbacks held in clangd.
+ //
+ // We bound the maximum size to the pending map to prevent memory leakage
+ // for cases where LSP clients don't reply for the request.
+ // This has to go after RequestCancellers and RequestCancellersMutex since it
+ // can contain a callback that has a cancelable context.
+ static constexpr int MaxReplayCallbacks = 100;
+ mutable std::mutex CallMutex;
+ int NextCallID = 0; /* GUARDED_BY(CallMutex) */
+ std::deque<std::pair</*RequestID*/ int,
+ /*ReplyHandler*/ Callback<llvm::json::Value>>>
+ ReplyCallbacks; /* GUARDED_BY(CallMutex) */
+
ClangdLSPServer &Server;
};
constexpr int ClangdLSPServer::MessageHandler::MaxReplayCallbacks;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68702.224046.patch
Type: text/x-patch
Size: 1826 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191009/10d94941/attachment.bin>
More information about the cfe-commits
mailing list