You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by gi...@apache.org on 2018/10/10 23:53:39 UTC

[mesos] 09/11: Fixed the lib_logrotate inappropriate UNSET_CLOEXEC via ChildHook.

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

gilbert pushed a commit to branch 1.6.x
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit ffe4928447cdc72a0bbdea54dfc3cba20b51e326
Author: Gilbert Song <so...@gmail.com>
AuthorDate: Tue Aug 21 14:35:01 2018 -0700

    Fixed the lib_logrotate inappropriate UNSET_CLOEXEC via ChildHook.
    
    Previously, we call os::unsetCloexec() on write fd for both outfds and
    errfds. Basically, this is not needed because all stdout and stderr
    fds will be closed at childMain() method. As a result, no need to do
    unsetCloexec() either from the parent process side or UNSET_CLOEXEC
    via the ChildHook.
    
    Review: https://reviews.apache.org/r/68458
    (cherry picked from commit b9d19cd4e03f70014063341c64f96b5860db8b0f)
---
 src/slave/container_loggers/lib_logrotate.cpp | 24 ++----------------------
 1 file changed, 2 insertions(+), 22 deletions(-)

diff --git a/src/slave/container_loggers/lib_logrotate.cpp b/src/slave/container_loggers/lib_logrotate.cpp
index bdc8f27..9a344d9 100644
--- a/src/slave/container_loggers/lib_logrotate.cpp
+++ b/src/slave/container_loggers/lib_logrotate.cpp
@@ -162,8 +162,6 @@ public:
     outfds.read = pipefd->at(0);
     outfds.write = pipefd->at(1);
 
-    const std::vector<int_fd> whitelistOutFds{pipefd->at(0), pipefd->at(1)};
-
     // Spawn a process to handle stdout.
     mesos::internal::logger::rotate::Flags outFlags;
     outFlags.max_size = overriddenFlags.max_stdout_size;
@@ -183,12 +181,6 @@ public:
     }
 #endif // __linux__
 
-    // TODO(gilbert): libprocess should take care of this, see MESOS-9164.
-    std::vector<Subprocess::ChildHook> childHooks;
-    foreach (int_fd fd, whitelistOutFds) {
-      childHooks.push_back(Subprocess::ChildHook::UNSET_CLOEXEC(fd));
-    }
-
     Try<Subprocess> outProcess = subprocess(
         path::join(flags.launcher_dir, mesos::internal::logger::rotate::NAME),
         {mesos::internal::logger::rotate::NAME},
@@ -198,9 +190,7 @@ public:
         &outFlags,
         environment,
         None(),
-        parentHooks,
-        childHooks,
-        whitelistOutFds);
+        parentHooks);
 
     if (outProcess.isError()) {
       os::close(outfds.write.get());
@@ -220,8 +210,6 @@ public:
     errfds.read = pipefd->at(0);
     errfds.write = pipefd->at(1);
 
-    const std::vector<int_fd> whitelistErrFds{pipefd->at(0), pipefd->at(1)};
-
     // Spawn a process to handle stderr.
     mesos::internal::logger::rotate::Flags errFlags;
     errFlags.max_size = overriddenFlags.max_stderr_size;
@@ -230,12 +218,6 @@ public:
     errFlags.logrotate_path = flags.logrotate_path;
     errFlags.user = user;
 
-    // TODO(gilbert): libprocess should take care of this, see MESOS-9164.
-    childHooks.clear();
-    foreach (int_fd fd, whitelistErrFds) {
-      childHooks.push_back(Subprocess::ChildHook::UNSET_CLOEXEC(fd));
-    }
-
     Try<Subprocess> errProcess = subprocess(
         path::join(flags.launcher_dir, mesos::internal::logger::rotate::NAME),
         {mesos::internal::logger::rotate::NAME},
@@ -245,9 +227,7 @@ public:
         &errFlags,
         environment,
         None(),
-        parentHooks,
-        childHooks,
-        whitelistErrFds);
+        parentHooks);
 
     if (errProcess.isError()) {
       os::close(outfds.write.get());