You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2017/01/10 00:06:18 UTC
mesos git commit: Fixed an FD leak in the IO switchboard.
Repository: mesos
Updated Branches:
refs/heads/master b492d4458 -> 87d723017
Fixed an FD leak in the IO switchboard.
Previously, the IO switchboard could leak file descriptors
because it held a reference to its server socket within the
socket's accept loop. This patch explicitly discards the
future containing this reference to eliminate the leak.
Review: https://reviews.apache.org/r/55355/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/87d72301
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/87d72301
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/87d72301
Branch: refs/heads/master
Commit: 87d7230171ec7a3ad2d232fbffc5bfc94f9cd68c
Parents: b492d44
Author: Greg Mann <gr...@mesosphere.io>
Authored: Mon Jan 9 16:06:11 2017 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Mon Jan 9 16:06:11 2017 -0800
----------------------------------------------------------------------
src/slave/containerizer/mesos/io/switchboard.cpp | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/87d72301/src/slave/containerizer/mesos/io/switchboard.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/io/switchboard.cpp b/src/slave/containerizer/mesos/io/switchboard.cpp
index 67c5167..c444568 100644
--- a/src/slave/containerizer/mesos/io/switchboard.cpp
+++ b/src/slave/containerizer/mesos/io/switchboard.cpp
@@ -984,6 +984,7 @@ private:
bool waitForConnection;
Option<Duration> heartbeatInterval;
bool inputConnected;
+ Future<unix::Socket> accept;
Promise<Nothing> promise;
Promise<Nothing> startRedirect;
// The following must be a `std::list`
@@ -1216,6 +1217,10 @@ Future<Nothing> IOSwitchboardServerProcess::unblock()
void IOSwitchboardServerProcess::finalize()
{
+ // Discard the server socket's `accept` future so that we do not
+ // maintain a reference to the socket, which would cause a leak.
+ accept.discard();
+
foreach (HttpConnection& connection, outputConnections) {
connection.close();
@@ -1257,7 +1262,10 @@ void IOSwitchboardServerProcess::heartbeatLoop()
void IOSwitchboardServerProcess::acceptLoop()
{
- socket.accept()
+ // Store the server socket's `accept` future so that we can discard
+ // it during process finalization. Otherwise, we would maintain a
+ // reference to the socket, causing a leak.
+ accept = socket.accept()
.onAny(defer(self(), [this](const Future<unix::Socket>& socket) {
if (!socket.isReady()) {
failure = Failure("Failed trying to accept connection");