mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From an...@apache.org
Subject [2/2] mesos git commit: Fixed memory leak in request/response decoders.
Date Wed, 02 Nov 2016 06:32:42 GMT
Fixed memory leak in request/response decoders.

The leak can happen in cases where a client disconnects while the
request/response is in progress.

Review: https://reviews.apache.org/r/53361/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/4033b370
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/4033b370
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/4033b370

Branch: refs/heads/0.28.x
Commit: 4033b37087056c63bc9b90969288ad5a9fa7f4ff
Parents: 94cdfd0
Author: Anand Mazumdar <anand@apache.org>
Authored: Tue Nov 1 21:32:55 2016 -0700
Committer: Anand Mazumdar <anand@apache.org>
Committed: Tue Nov 1 23:30:06 2016 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/src/decoder.hpp | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/4033b370/3rdparty/libprocess/src/decoder.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/decoder.hpp b/3rdparty/libprocess/src/decoder.hpp
index a8aa509..034d2b0 100644
--- a/3rdparty/libprocess/src/decoder.hpp
+++ b/3rdparty/libprocess/src/decoder.hpp
@@ -63,6 +63,15 @@ public:
     parser.data = this;
   }
 
+  ~DataDecoder()
+  {
+    delete request;
+
+    foreach (http::Request* request, requests) {
+      delete request;
+    }
+  }
+
   std::deque<http::Request*> decode(const char* data, size_t length)
   {
     size_t parsed = http_parser_execute(&parser, &settings, data, length);
@@ -327,6 +336,15 @@ public:
     parser.data = this;
   }
 
+  ~ResponseDecoder()
+  {
+    delete response;
+
+    foreach (http::Response* response, responses) {
+      delete response;
+    }
+  }
+
   std::deque<http::Response*> decode(const char* data, size_t length)
   {
     size_t parsed = http_parser_execute(&parser, &settings, data, length);
@@ -542,6 +560,19 @@ public:
     parser.data = this;
   }
 
+  ~StreamingResponseDecoder()
+  {
+    delete response;
+
+    if (writer.isSome()) {
+      writer->fail("Decoder is being deleted");
+    }
+
+    foreach (http::Response* response, responses) {
+      delete response;
+    }
+  }
+
   std::deque<http::Response*> decode(const char* data, size_t length)
   {
     size_t parsed = http_parser_execute(&parser, &settings, data, length);


Mime
View raw message