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 2017/07/11 01:39:31 UTC
[45/50] mesos git commit: Windows: Made job object APIs use Unicode.
Windows: Made job object APIs use Unicode.
Changed the Job Object name to be a `wstring` for easier use.
Review: https://reviews.apache.org/r/60340/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/dc81df5c
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/dc81df5c
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/dc81df5c
Branch: refs/heads/master
Commit: dc81df5c2e53acecb3dcc215f8d9499e8095a327
Parents: 5df5750
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Mon Jul 10 15:36:08 2017 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Mon Jul 10 17:15:39 2017 -0700
----------------------------------------------------------------------
.../stout/include/stout/os/windows/killtree.hpp | 2 +-
3rdparty/stout/include/stout/windows/os.hpp | 28 +++++++++++---------
2 files changed, 16 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/dc81df5c/3rdparty/stout/include/stout/os/windows/killtree.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/os/windows/killtree.hpp b/3rdparty/stout/include/stout/os/windows/killtree.hpp
index 267a9a0..ce8bdcd 100644
--- a/3rdparty/stout/include/stout/os/windows/killtree.hpp
+++ b/3rdparty/stout/include/stout/os/windows/killtree.hpp
@@ -34,7 +34,7 @@ inline Try<std::list<ProcessTree>> killtree(
bool groups = false,
bool sessions = false)
{
- Try<std::string> name = os::name_job(pid);
+ Try<std::wstring> name = os::name_job(pid);
if (name.isError()) {
return Error("Failed to determine job object name: " + name.error());
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/dc81df5c/3rdparty/stout/include/stout/windows/os.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/windows/os.hpp b/3rdparty/stout/include/stout/windows/os.hpp
index 1a5abda..e0909d1 100644
--- a/3rdparty/stout/include/stout/windows/os.hpp
+++ b/3rdparty/stout/include/stout/windows/os.hpp
@@ -627,17 +627,17 @@ inline int random()
}
-// `name_job` maps a `pid` to a `string` name for a job object.
+// `name_job` maps a `pid` to a `wstring` name for a job object.
// Only named job objects are accessible via `OpenJobObject`.
// Thus all our job objects must be named. This is essentially a shim
// to map the Linux concept of a process tree's root `pid` to a
// named job object so that the process group can be treated similarly.
-inline Try<std::string> name_job(pid_t pid) {
+inline Try<std::wstring> name_job(pid_t pid) {
Try<std::string> alpha_pid = strings::internal::format("MESOS_JOB_%X", pid);
if (alpha_pid.isError()) {
return Error(alpha_pid.error());
}
- return alpha_pid;
+ return wide_stringify(alpha_pid.get());
}
@@ -649,18 +649,19 @@ inline Try<std::string> name_job(pid_t pid) {
inline Try<SharedHandle> open_job(
const DWORD desired_access,
BOOL inherit_handles,
- const std::string& name)
+ const std::wstring& name)
{
SharedHandle jobHandle(
- ::OpenJobObject(
+ ::OpenJobObjectW(
desired_access,
inherit_handles,
- name.c_str()),
+ name.data()),
::CloseHandle);
if (jobHandle.get() == nullptr) {
return WindowsError(
- "os::open_job: Call to `OpenJobObject` failed for job: " + name);
+ "os::open_job: Call to `OpenJobObject` failed for job: " +
+ stringify(name));
}
return jobHandle;
@@ -673,19 +674,19 @@ inline Try<SharedHandle> open_job(
// handle is closed and all associated processes have exited,
// a running process must be assigned to the created job
// before the returned handle is closed.
-inline Try<SharedHandle> create_job(const std::string& name)
+inline Try<SharedHandle> create_job(const std::wstring& name)
{
SharedHandle jobHandle(
- ::CreateJobObject(
+ ::CreateJobObjectW(
nullptr, // Use a default security descriptor, and
// the created handle cannot be inherited.
- name.c_str()), // The name of the job.
+ name.data()), // The name of the job.
::CloseHandle);
- // TODO(andschwa): Fix the type of `name` when Unicode is turned on.
if (jobHandle.get_handle() == nullptr) {
return WindowsError(
- "os::create_job: Call to `CreateJobObject` failed for job: " + name);
+ "os::create_job: Call to `CreateJobObject` failed for job: " +
+ stringify(name));
}
JOBOBJECT_EXTENDED_LIMIT_INFORMATION jeli = { { 0 }, 0 };
@@ -705,7 +706,8 @@ inline Try<SharedHandle> create_job(const std::string& name)
if (setInformationResult == FALSE) {
return WindowsError(
- "os::create_job: `SetInformationJobObject` failed for job: " + name);
+ "os::create_job: `SetInformationJobObject` failed for job: " +
+ stringify(name));
}
return jobHandle;