mirror of
https://github.com/wassname/ray.git
synced 2026-09-09 11:32:43 +08:00
Fix memory leak in rpc ServerCall and ClientCall (#5046)
This commit is contained in:
@@ -30,6 +30,8 @@ class ClientCall {
|
||||
/// The callback to be called by `ClientCallManager` when the reply of this request is
|
||||
/// received.
|
||||
virtual void OnReplyReceived() = 0;
|
||||
|
||||
virtual ~ClientCall() = default;
|
||||
};
|
||||
|
||||
class ClientCallManager;
|
||||
@@ -142,7 +144,7 @@ class ClientCallManager {
|
||||
bool ok = false;
|
||||
// Keep reading events from the `CompletionQueue` until it's shutdown.
|
||||
while (cq_.Next(&got_tag, &ok)) {
|
||||
ClientCall *call = reinterpret_cast<ClientCall *>(got_tag);
|
||||
auto *call = reinterpret_cast<ClientCall *>(got_tag);
|
||||
if (ok) {
|
||||
// Post the callback to the main event loop.
|
||||
main_service_.post([call]() {
|
||||
|
||||
@@ -43,7 +43,7 @@ void GrpcServer::PollEventsFromCompletionQueue() {
|
||||
bool ok;
|
||||
// Keep reading events from the `CompletionQueue` until it's shutdown.
|
||||
while (cq_->Next(&tag, &ok)) {
|
||||
ServerCall *server_call = static_cast<ServerCall *>(tag);
|
||||
auto *server_call = static_cast<ServerCall *>(tag);
|
||||
// `ok == false` indicates that the server has been shut down.
|
||||
// We should delete the call object in this case.
|
||||
bool delete_call = !ok;
|
||||
|
||||
@@ -58,6 +58,8 @@ class ServerCall {
|
||||
|
||||
/// Get the factory that created this `ServerCall`.
|
||||
virtual const ServerCallFactory &GetFactory() const = 0;
|
||||
|
||||
virtual ~ServerCall() = default;
|
||||
};
|
||||
|
||||
/// The factory that creates a particular kind of `ServerCall` objects.
|
||||
|
||||
Reference in New Issue
Block a user