You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@heron.apache.org by nw...@apache.org on 2019/04/01 17:55:59 UTC

[incubator-heron] branch master updated: memory leak in tmaster fixed (#3230)

This is an automated email from the ASF dual-hosted git repository.

nwang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-heron.git


The following commit(s) were added to refs/heads/master by this push:
     new 378c8ef  memory leak in tmaster fixed (#3230)
378c8ef is described below

commit 378c8efbb34003c8dcf02ffcd51dc8564408c627
Author: Dmitry Rusakov <dn...@gmail.com>
AuthorDate: Mon Apr 1 10:55:53 2019 -0700

    memory leak in tmaster fixed (#3230)
---
 heron/tmaster/src/cpp/manager/stats-interface.cpp |  1 -
 heron/tmaster/src/cpp/manager/tmaster.cpp         | 10 +++++++---
 heron/tmaster/src/cpp/manager/tmaster.h           |  2 +-
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/heron/tmaster/src/cpp/manager/stats-interface.cpp b/heron/tmaster/src/cpp/manager/stats-interface.cpp
index 4d42913..4b2086d 100644
--- a/heron/tmaster/src/cpp/manager/stats-interface.cpp
+++ b/heron/tmaster/src/cpp/manager/stats-interface.cpp
@@ -160,7 +160,6 @@ void StatsInterface::HandleStmgrsRegistrationSummaryRequest(IncomingHTTPRequest*
   http_response->AddHeader("Content-Length", std::to_string(response_string.size()));
   http_response->AddResponse(response_string);
   http_server_->SendReply(_request, 200, http_response);
-  delete stmgrs_reg_summary_response;
   delete _request;
   LOG(INFO) << "Returned stream managers registration summary response";
 }
diff --git a/heron/tmaster/src/cpp/manager/tmaster.cpp b/heron/tmaster/src/cpp/manager/tmaster.cpp
index 44d9a15..206d8fb 100644
--- a/heron/tmaster/src/cpp/manager/tmaster.cpp
+++ b/heron/tmaster/src/cpp/manager/tmaster.cpp
@@ -847,15 +847,19 @@ bool TMaster::DistributePhysicalPlan() {
   return false;
 }
 
-proto::tmaster::StmgrsRegistrationSummaryResponse* TMaster::GetStmgrsRegSummary() {
-  auto response = new proto::tmaster::StmgrsRegistrationSummaryResponse();
+std::unique_ptr<proto::tmaster::StmgrsRegistrationSummaryResponse> TMaster::GetStmgrsRegSummary() {
+  auto response = std::unique_ptr<proto::tmaster::StmgrsRegistrationSummaryResponse>(
+          new proto::tmaster::StmgrsRegistrationSummaryResponse());
+
   for (auto it = stmgrs_.begin(); it != stmgrs_.end(); ++it) {
     response->add_registered_stmgrs(it->first);
   }
+
   for (auto it = absent_stmgrs_.begin(); it != absent_stmgrs_.end(); ++it) {
     response->add_absent_stmgrs(*it);
   }
-  return response;
+
+  return std::move(response);
 }
 
 proto::system::PhysicalPlan* TMaster::MakePhysicalPlan() {
diff --git a/heron/tmaster/src/cpp/manager/tmaster.h b/heron/tmaster/src/cpp/manager/tmaster.h
index 8c48f36..8869618 100644
--- a/heron/tmaster/src/cpp/manager/tmaster.h
+++ b/heron/tmaster/src/cpp/manager/tmaster.h
@@ -90,7 +90,7 @@ class TMaster {
   void HandleCleanStatefulCheckpointResponse(proto::system::StatusCode);
 
   // Get stream managers registration summary
-  proto::tmaster::StmgrsRegistrationSummaryResponse* GetStmgrsRegSummary();
+  std::unique_ptr<proto::tmaster::StmgrsRegistrationSummaryResponse> GetStmgrsRegSummary();
 
   // Accessors
   const proto::system::PhysicalPlan* getPhysicalPlan() const { return current_pplan_; }