You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by an...@apache.org on 2016/07/21 20:43:38 UTC
[2/6] mesos git commit: Fixed a file descriptor leak while reading
file.
Fixed a file descriptor leak while reading file.
There were two early returns without closing the file
in code common to the `ReadFile` operation in the v1
Operator API and the `/files/read` endpoint.
Review: https://reviews.apache.org/r/50208/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/8476cf1e
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/8476cf1e
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/8476cf1e
Branch: refs/heads/master
Commit: 8476cf1e58b6fa2160e3bb109e538fb9d94ccc58
Parents: b3d57a8
Author: zhou xing <xi...@cn.ibm.com>
Authored: Thu Jul 21 13:31:14 2016 -0700
Committer: Anand Mazumdar <an...@apache.org>
Committed: Thu Jul 21 13:31:14 2016 -0700
----------------------------------------------------------------------
src/files/files.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/8476cf1e/src/files/files.cpp
----------------------------------------------------------------------
diff --git a/src/files/files.cpp b/src/files/files.cpp
index b88e34e..793d68e 100644
--- a/src/files/files.cpp
+++ b/src/files/files.cpp
@@ -653,6 +653,7 @@ Future<Try<tuple<size_t, string>, FilesError>> FilesProcess::_read(
// Return the size of file if length is 0.
if (length == 0) {
+ os::close(fd.get());
return std::make_tuple(size, "");
}
@@ -687,7 +688,8 @@ Future<Try<tuple<size_t, string>, FilesError>> FilesProcess::_read(
.then([size, data](const size_t dataLength)
-> Try<tuple<size_t, string>, FilesError> {
return std::make_tuple(size, string(data.get(), dataLength));
- });
+ })
+ .onAny([fd]() { os::close(fd.get()); });
}