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 2016/11/12 02:57:24 UTC
[03/11] mesos git commit: Added a flag to optionally skip the
multithreaded check in setns().
Added a flag to optionally skip the multithreaded check in setns().
Review: https://reviews.apache.org/r/53681/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/ed1b4bc6
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/ed1b4bc6
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/ed1b4bc6
Branch: refs/heads/master
Commit: ed1b4bc62486e06a5e76922bcc2f9bd494ab01e8
Parents: 0f3eabc
Author: Kevin Klues <kl...@gmail.com>
Authored: Fri Nov 11 16:14:51 2016 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Nov 11 18:54:07 2016 -0800
----------------------------------------------------------------------
src/linux/ns.hpp | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/ed1b4bc6/src/linux/ns.hpp
----------------------------------------------------------------------
diff --git a/src/linux/ns.hpp b/src/linux/ns.hpp
index 76db0dc..010a1fa 100644
--- a/src/linux/ns.hpp
+++ b/src/linux/ns.hpp
@@ -154,16 +154,21 @@ inline std::set<int> nstypes()
// allow a process with multiple threads to call this function because
// it will lead to some weird situations where different threads of a
// process are in different namespaces.
-inline Try<Nothing> setns(const std::string& path, const std::string& ns)
+inline Try<Nothing> setns(
+ const std::string& path,
+ const std::string& ns,
+ bool checkMultithreaded = true)
{
- // Return error if there're multiple threads in the calling process.
- Try<std::set<pid_t>> threads = proc::threads(::getpid());
- if (threads.isError()) {
- return Error(
- "Failed to get the threads of the current process: " +
- threads.error());
- } else if (threads.get().size() > 1) {
- return Error("Multiple threads exist in the current process");
+ if (checkMultithreaded) {
+ // Return error if there're multiple threads in the calling process.
+ Try<std::set<pid_t>> threads = proc::threads(::getpid());
+ if (threads.isError()) {
+ return Error(
+ "Failed to get the threads of the current process: " +
+ threads.error());
+ } else if (threads.get().size() > 1) {
+ return Error("Multiple threads exist in the current process");
+ }
}
if (ns::namespaces().count(ns) == 0) {