You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2016/10/04 00:51:17 UTC

[1/3] mesos git commit: CMake: Added build script for mesos-log tool.

Repository: mesos
Updated Branches:
  refs/heads/master 3af5f5512 -> 5f6dac4c4


CMake: Added build script for mesos-log tool.

This tool is used to interact with the Mesos replicated log library.

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


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

Branch: refs/heads/master
Commit: 5f6dac4c460240b511697a57164178d9317c798e
Parents: 8bf6107
Author: Srinivas Brahmaroutu <sr...@us.ibm.com>
Authored: Mon Oct 3 14:21:20 2016 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Mon Oct 3 17:50:39 2016 -0700

----------------------------------------------------------------------
 src/CMakeLists.txt     |  1 +
 src/log/CMakeLists.txt | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/5f6dac4c/src/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 35eb63f..ba49d81 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -517,6 +517,7 @@ add_subdirectory(cli/)
 add_subdirectory(docker/)
 add_subdirectory(launcher/)
 add_subdirectory(local/)
+add_subdirectory(log/)
 add_subdirectory(master/)
 add_subdirectory(slave/)
 add_subdirectory(slave/containerizer/mesos/)

http://git-wip-us.apache.org/repos/asf/mesos/blob/5f6dac4c/src/log/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/log/CMakeLists.txt b/src/log/CMakeLists.txt
new file mode 100644
index 0000000..b2b930c
--- /dev/null
+++ b/src/log/CMakeLists.txt
@@ -0,0 +1,42 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# TODO(josephw): Enable this on Windows after sorting out the dependencies.
+if (NOT WIN32)
+
+set(MESOS_LOG_TARGET mesos-log
+  CACHE STRING "Utility used to interact with the replicated log.")
+
+# THE MESOS-LOG SOURCE.
+###########################
+set(MESOS_LOG_SRC
+  ${MESOS_LOG_SRC}
+  main.cpp
+  )
+
+# THE MESOS LOG.
+###########################################
+add_executable(${MESOS_LOG_TARGET} ${MESOS_LOG_SRC})
+
+# ADD LINKER FLAGS (generates, e.g., -lglog on Linux).
+######################################################
+target_link_libraries(${MESOS_LOG_TARGET} ${MESOS_TARGET})
+
+# ADD BINARY DEPENDENCIES (tells CMake what to compile/build first).
+####################################################################
+add_dependencies(${MESOS_LOG_TARGET} ${MESOS_TARGET})
+
+endif (NOT WIND32)


[2/3] mesos git commit: Removed `memory_test_helper_main.cpp`.

Posted by jo...@apache.org.
Removed `memory_test_helper_main.cpp`.

All content of this file was was superceded by `test_helper_main.cpp`.
See: https://reviews.apache.org/r/51215/

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


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

Branch: refs/heads/master
Commit: 8bf61073562f4e3d81494762a88fd0d82a704ee3
Parents: 9feb797
Author: Joseph Wu <jo...@mesosphere.io>
Authored: Mon Oct 3 16:35:45 2016 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Mon Oct 3 17:50:39 2016 -0700

----------------------------------------------------------------------
 .../containerizer/memory_test_helper_main.cpp   | 30 --------------------
 1 file changed, 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/8bf61073/src/tests/containerizer/memory_test_helper_main.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/memory_test_helper_main.cpp b/src/tests/containerizer/memory_test_helper_main.cpp
deleted file mode 100644
index 9eeba9c..0000000
--- a/src/tests/containerizer/memory_test_helper_main.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include <stout/subcommand.hpp>
-
-#include "tests/containerizer/memory_test_helper.hpp"
-
-using mesos::internal::tests::MemoryTestHelperMain;
-
-int main(int argc, char** argv)
-{
-  return Subcommand::dispatch(
-      None(),
-      argc,
-      argv,
-      new MemoryTestHelperMain());
-}


[3/3] mesos git commit: Fixed memory leak in master during framework teardown.

Posted by jo...@apache.org.
Fixed memory leak in master during framework teardown.

The `process::http::Pipe` class leaks its underlying `shared_ptr`
due to how the master (accidentally) causes the `shared_ptr` to hold
a self-reference.

When the master receives a `SUBSCRIBE` call from an V1 HTTP API
framework, the master creates a `process::http::Pipe` to manage the
reading and writing in separate locations in the code.  For
synchronization, the read/write ends of the HTTP connection share
some state (via `shared_ptr`).

The master introduces a self-reference via this line in
`Master::addFramework`:
```
  http.closed()
    .onAny(defer(self(), &Self::exited, framework->id(), http));
```

`http.closed()` returns a future managed by the read-end of the `Pipe`.
`http` holds a copy of the write-end of the `Pipe`, which in turn has
a copy of the `shared_ptr`.  Because `http` is passed into the future's
continuation, a copy of `http` will live inside the read-end's future
until the either (a) the continuation is executed or (b) the future
is destructed.

Due to how we manage the future, neither (a) nor (b) are performed:
(a) When the read-end of the `Pipe` is closed, we only complete the
    future if the write-end of the `Pipe` is still open.  During
    framework teardown, the write-end is closed first.
(b) The future in question lives inside a `Promise`, which lives
    inside the `shared_ptr`.  Because the self-reference exists, the
    `shared_ptr` is never destructed; which means the `Promise` and
    future are never destructed either.

---

This patch fixes the leak by making sure the continuation is always
executed (a) or discarded.  It does so by discarding the related
future when the write-end of the `Pipe` is already closed.

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


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

Branch: refs/heads/master
Commit: 9feb797a700af0b2c0db34ba04988dc1ca7df9c3
Parents: 3af5f55
Author: Joseph Wu <jo...@mesosphere.io>
Authored: Mon Oct 3 16:35:35 2016 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Mon Oct 3 17:50:39 2016 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/include/process/http.hpp |  5 ++---
 3rdparty/libprocess/src/http.cpp             |  5 +++++
 3rdparty/libprocess/src/tests/http_tests.cpp | 13 ++++++-------
 3 files changed, 13 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/9feb797a/3rdparty/libprocess/include/process/http.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/http.hpp b/3rdparty/libprocess/include/process/http.hpp
index 404196b..9722c62 100644
--- a/3rdparty/libprocess/include/process/http.hpp
+++ b/3rdparty/libprocess/include/process/http.hpp
@@ -307,9 +307,8 @@ struct Request
 //
 // Unlike unix pipes, if the read-end of the pipe is closed before
 // the write-end is closed, rather than receiving SIGPIPE or EPIPE
-// during a write, the writer is notified via a future. Like unix
-// pipes, we are not notified if the read-end is closed after the
-// write-end is closed, even if data is remaining in the pipe!
+// during a write, the writer is notified via a future. This future
+// is discarded if the write-end is closed first.
 //
 // No buffering means that each non-empty write to the pipe will
 // correspond to to an equivalent read from the pipe, and the

http://git-wip-us.apache.org/repos/asf/mesos/blob/9feb797a/3rdparty/libprocess/src/http.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/http.cpp b/3rdparty/libprocess/src/http.cpp
index 298bd46..b5ddac9 100644
--- a/3rdparty/libprocess/src/http.cpp
+++ b/3rdparty/libprocess/src/http.cpp
@@ -452,6 +452,11 @@ bool Pipe::Reader::close()
 
     if (notify) {
       data->readerClosure.set(Nothing());
+    } else {
+      // This future is only satisifed when the reader is closed before
+      // the write-end of the pipe. In other cases, discard the promise
+      // in order to clear any associated callbacks.
+      data->readerClosure.discard();
     }
   }
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/9feb797a/3rdparty/libprocess/src/tests/http_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/http_tests.cpp b/3rdparty/libprocess/src/tests/http_tests.cpp
index 2538f56..8d6c8c4 100644
--- a/3rdparty/libprocess/src/tests/http_tests.cpp
+++ b/3rdparty/libprocess/src/tests/http_tests.cpp
@@ -347,10 +347,10 @@ TEST(HTTPTest, PipeEOF)
   // The write end cannot be closed twice.
   EXPECT_FALSE(writer.close());
 
-  // Close the read end, this should not notify the writer
-  // since the write end was already closed.
+  // Close the read end.
+  // This should discard the associated future held by the write end.
   EXPECT_TRUE(reader.close());
-  EXPECT_TRUE(writer.readerClosed().isPending());
+  EXPECT_TRUE(writer.readerClosed().isDiscarded());
 }
 
 
@@ -378,14 +378,13 @@ TEST(HTTPTest, PipeFailure)
   EXPECT_FALSE(writer.close());
   EXPECT_FALSE(writer.fail("not again"));
 
-  // The writer shouldn't be notified of the reader closing,
-  // since the writer had already failed.
+  // Close the read end.
+  // This should discard the associated future held by the write end.
   EXPECT_TRUE(reader.close());
-  EXPECT_TRUE(writer.readerClosed().isPending());
+  EXPECT_TRUE(writer.readerClosed().isDiscarded());
 }
 
 
-
 TEST(HTTPTest, PipeReaderCloses)
 {
   http::Pipe pipe;