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/01/13 02:28:28 UTC
[1/4] mesos git commit: Windows: Fixed the locale guard in
jsonify.hpp.
Repository: mesos
Updated Branches:
refs/heads/master 8cd5acd3c -> 104532d86
Windows: Fixed the locale guard in jsonify.hpp.
Changing locales in Windows is mainly accomplished via `setlocale`,
which takes a bit mask (with constants named slightly differently
than in the POSIX headers) and a `char*`.
This also adds a comment to the locale guard.
Review: https://reviews.apache.org/r/55435/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/d82dc253
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/d82dc253
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/d82dc253
Branch: refs/heads/master
Commit: d82dc253bd730f4cde44b1eb1f3b2c22fb3dedfa
Parents: 8cd5acd
Author: Joseph Wu <jo...@mesosphere.io>
Authored: Thu Jan 12 17:09:55 2017 -0800
Committer: Joseph Wu <jo...@apache.org>
Committed: Thu Jan 12 17:11:08 2017 -0800
----------------------------------------------------------------------
3rdparty/stout/include/stout/jsonify.hpp | 37 +++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/d82dc253/3rdparty/stout/include/stout/jsonify.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/jsonify.hpp b/3rdparty/stout/include/stout/jsonify.hpp
index 3c48046..cdcd839 100644
--- a/3rdparty/stout/include/stout/jsonify.hpp
+++ b/3rdparty/stout/include/stout/jsonify.hpp
@@ -13,7 +13,9 @@
#ifndef __STOUT_JSONIFY__
#define __STOUT_JSONIFY__
+#ifndef __WINDOWS__
#include <xlocale.h>
+#endif // __WINDOWS__
#include <clocale>
#include <cstddef>
@@ -55,8 +57,42 @@ namespace JSON {
namespace internal {
+/**
+ * This object changes the current thread's locale to the default "C"
+ * locale for number printing purposes. This prevents, for example,
+ * commas from appearing in printed numbers instead of decimal points.
+ *
+ * NOTE: This object should only be used to guard synchronous code.
+ * If multiple blocks of code need to enforce the default locale,
+ * each block should utilize this object.
+ */
+// TODO(josephw): Consider pulling this helper into a separate header.
class ClassicLocale
{
+#ifdef __WINDOWS__
+public:
+ ClassicLocale()
+ {
+ // We will only change the locale for this thread
+ // and save the previous state of the thread's locale.
+ original_per_thread_ = _configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
+
+ // NOTE: We must make a copy of the return value as it points
+ // to global or shared memory. Future calls to `setlocale` will
+ // invalidate the memory location.
+ original_locale_ = setlocale(LC_NUMERIC, "C");
+ }
+
+ ~ClassicLocale()
+ {
+ setlocale(LC_NUMERIC, original_locale_.c_str());
+ _configthreadlocale(original_per_thread_);
+ }
+
+private:
+ int original_per_thread_;
+ std::string original_locale_;
+#else
public:
ClassicLocale()
{
@@ -74,6 +110,7 @@ public:
private:
locale_t original_locale_;
locale_t c_locale_;
+#endif // __WINDOWS__
};
} // namespace internal {
[2/4] mesos git commit: Windows: Fixed typo in
`stout/os/windows/write.hpp`.
Posted by jo...@apache.org.
Windows: Fixed typo in `stout/os/windows/write.hpp`.
NOTE: This typo is benign. This method is supposed to help
disambiguate calls to `write`, which pass in a Windows `HANDLE`
type, instead of ints, as we do for file descriptors on UNIX.
Review: https://reviews.apache.org/r/55161/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/869665ae
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/869665ae
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/869665ae
Branch: refs/heads/master
Commit: 869665ae0429a6dbceee11b5d1797914accbcf90
Parents: d82dc25
Author: Alex Clemmer <cl...@gmail.com>
Authored: Thu Jan 12 16:57:42 2017 -0800
Committer: Joseph Wu <jo...@apache.org>
Committed: Thu Jan 12 17:11:14 2017 -0800
----------------------------------------------------------------------
3rdparty/stout/include/stout/os/windows/write.hpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/869665ae/3rdparty/stout/include/stout/os/windows/write.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/os/windows/write.hpp b/3rdparty/stout/include/stout/os/windows/write.hpp
index 2348870..e0f2f0d 100644
--- a/3rdparty/stout/include/stout/os/windows/write.hpp
+++ b/3rdparty/stout/include/stout/os/windows/write.hpp
@@ -40,7 +40,7 @@ inline ssize_t write(int fd, const void* data, size_t size)
}
-inline ssize_t read(HANDLE handle, const void* data, size_t size)
+inline ssize_t write(HANDLE handle, const void* data, size_t size)
{
return ::os::write(
_open_osfhandle(reinterpret_cast<intptr_t>(handle), O_RDWR),
[3/4] mesos git commit: Windows: Normalize `#endif` comments of `//
!__WINDOWS__`.
Posted by jo...@apache.org.
Windows: Normalize `#endif` comments of `// !__WINDOWS__`.
We had a few `#ifndef` blocks for Windows which were closed out by
`#endif // !__WINDOWS__`, which has an extra negation symbol.
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/a92b8ad8
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/a92b8ad8
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/a92b8ad8
Branch: refs/heads/master
Commit: a92b8ad8b48fb2d6771bee522e2705110591329d
Parents: 869665a
Author: Joseph Wu <jo...@apache.org>
Authored: Thu Jan 12 17:13:39 2017 -0800
Committer: Joseph Wu <jo...@apache.org>
Committed: Thu Jan 12 17:13:39 2017 -0800
----------------------------------------------------------------------
src/slave/containerizer/mesos/containerizer.cpp | 4 ++--
src/slave/flags.cpp | 2 +-
src/tests/cluster.cpp | 6 +++---
src/tests/command_executor_tests.cpp | 2 +-
src/tests/environment.cpp | 4 ++--
src/tests/slave_tests.cpp | 10 +++++-----
src/tests/test_helper_main.cpp | 6 +++---
7 files changed, 17 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/a92b8ad8/src/slave/containerizer/mesos/containerizer.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/containerizer.cpp b/src/slave/containerizer/mesos/containerizer.cpp
index 4d2b434..8bf8a77 100644
--- a/src/slave/containerizer/mesos/containerizer.cpp
+++ b/src/slave/containerizer/mesos/containerizer.cpp
@@ -160,7 +160,7 @@ Try<MesosContainerizer*> MesosContainerizer::create(
flags_.isolation = "posix/cpu,posix/mem";
#else
flags_.isolation = "windows/cpu";
-#endif // !__WINDOWS__
+#endif // __WINDOWS__
} else if (flags.isolation == "cgroups") {
LOG(WARNING) << "The 'cgroups' isolation flag is deprecated, "
<< "please update your flags to"
@@ -181,7 +181,7 @@ Try<MesosContainerizer*> MesosContainerizer::create(
flags_.isolation += ",filesystem/posix";
#else
flags_.isolation += ",filesystem/windows";
-#endif // !__WINDOWS__
+#endif // __WINDOWS__
}
if (strings::contains(flags_.isolation, "posix/disk")) {
http://git-wip-us.apache.org/repos/asf/mesos/blob/a92b8ad8/src/slave/flags.cpp
----------------------------------------------------------------------
diff --git a/src/slave/flags.cpp b/src/slave/flags.cpp
index 1eccea9..d976fb8 100644
--- a/src/slave/flags.cpp
+++ b/src/slave/flags.cpp
@@ -108,7 +108,7 @@ mesos::internal::slave::Flags::Flags()
"posix/cpu,posix/mem"
#else
"windows/cpu"
-#endif // !__WINDOWS__
+#endif // __WINDOWS__
);
add(&Flags::launcher,
http://git-wip-us.apache.org/repos/asf/mesos/blob/a92b8ad8/src/tests/cluster.cpp
----------------------------------------------------------------------
diff --git a/src/tests/cluster.cpp b/src/tests/cluster.cpp
index 2447643..04b7083 100644
--- a/src/tests/cluster.cpp
+++ b/src/tests/cluster.cpp
@@ -24,7 +24,7 @@
#ifndef __WINDOWS__
#include <mesos/log/log.hpp>
-#endif // !__WINDOWS__
+#endif // __WINDOWS__
#include <mesos/allocator/allocator.hpp>
@@ -233,7 +233,7 @@ Try<process::Owned<Master>> Master::start(
}
#else
return Error("Windows does not support replicated log");
-#endif // !__WINDOWS__
+#endif // __WINDOWS__
}
// Create the registry's storage backend.
@@ -244,7 +244,7 @@ Try<process::Owned<Master>> Master::start(
master->storage.reset(new mesos::state::LogStorage(master->log.get()));
#else
return Error("Windows does not support replicated log");
-#endif // !__WINDOWS__
+#endif // __WINDOWS__
} else {
return Error(
http://git-wip-us.apache.org/repos/asf/mesos/blob/a92b8ad8/src/tests/command_executor_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/command_executor_tests.cpp b/src/tests/command_executor_tests.cpp
index f4e7044..4d5c21e 100644
--- a/src/tests/command_executor_tests.cpp
+++ b/src/tests/command_executor_tests.cpp
@@ -333,7 +333,7 @@ TEST_P(CommandExecutorTest, NoTransitionFromKillingToRunning)
driver.stop();
driver.join();
}
-#endif // !__WINDOWS__
+#endif // __WINDOWS__
class HTTPCommandExecutorTest
http://git-wip-us.apache.org/repos/asf/mesos/blob/a92b8ad8/src/tests/environment.cpp
----------------------------------------------------------------------
diff --git a/src/tests/environment.cpp b/src/tests/environment.cpp
index df92679..a9e217e 100644
--- a/src/tests/environment.cpp
+++ b/src/tests/environment.cpp
@@ -826,7 +826,7 @@ void Environment::SetUp()
if (!GTEST_IS_THREADSAFE) {
EXIT(EXIT_FAILURE) << "Testing environment is not thread safe, bailing!";
}
-#endif // !__WINDOWS__
+#endif // __WINDOWS__
}
@@ -914,7 +914,7 @@ Try<string> Environment::TemporaryDirectoryEventListener::mkdtemp()
// avoid the infamous Windows path length errors, which would
// normally cause many of our tests to fail.
path::join(tmpdir, "XXXXXX");
-#endif // !__WINDOWS__
+#endif // __WINDOWS__
Try<string> mkdtemp = os::mkdtemp(path);
if (mkdtemp.isSome()) {
http://git-wip-us.apache.org/repos/asf/mesos/blob/a92b8ad8/src/tests/slave_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/slave_tests.cpp b/src/tests/slave_tests.cpp
index 152c53f..7740479 100644
--- a/src/tests/slave_tests.cpp
+++ b/src/tests/slave_tests.cpp
@@ -16,7 +16,7 @@
#ifndef __WINDOWS__
#include <unistd.h>
-#endif // !__WINDOWS__
+#endif // __WINDOWS__
#include <algorithm>
#include <map>
@@ -526,7 +526,7 @@ TEST_F(SlaveTest, ExecutorTimeoutCausedBySlowFetch)
driver.stop();
driver.join();
}
-#endif // !__WINDOWS__
+#endif // __WINDOWS__
// This test verifies that when an executor terminates before
@@ -1196,7 +1196,7 @@ TEST_F(SlaveTest, DISABLED_ROOT_RunTaskWithCommandInfoWithUser)
driver.stop();
driver.join();
}
-#endif // !__WINDOWS__
+#endif // __WINDOWS__
// This test ensures that a status update acknowledgement from a
@@ -3052,7 +3052,7 @@ TEST_F(SlaveTest, HealthCheckUnregisterRace)
driver.stop();
driver.join();
}
-#endif // !__WINDOWS__
+#endif // __WINDOWS__
#ifndef __WINDOWS__
@@ -3166,7 +3166,7 @@ TEST_F(SlaveTest, UnreachableThenUnregisterRace)
driver.stop();
driver.join();
}
-#endif // !__WINDOWS__
+#endif // __WINDOWS__
// This test checks that the master behaves correctly when a slave is
http://git-wip-us.apache.org/repos/asf/mesos/blob/a92b8ad8/src/tests/test_helper_main.cpp
----------------------------------------------------------------------
diff --git a/src/tests/test_helper_main.cpp b/src/tests/test_helper_main.cpp
index ff89f4e..5d99ede 100644
--- a/src/tests/test_helper_main.cpp
+++ b/src/tests/test_helper_main.cpp
@@ -23,7 +23,7 @@
#ifndef __WINDOWS__
#include "tests/containerizer/memory_test_helper.hpp"
-#endif // !__WINDOWS__
+#endif // __WINDOWS__
#ifdef __linux__
#include "tests/containerizer/capabilities_test_helper.hpp"
#include "tests/containerizer/setns_test_helper.hpp"
@@ -34,7 +34,7 @@ using mesos::internal::tests::HealthCheckTestHelper;
#ifndef __WINDOWS__
using mesos::internal::tests::KillPolicyTestHelper;
using mesos::internal::tests::MemoryTestHelper;
-#endif // !__WINDOWS__
+#endif // __WINDOWS__
#ifdef __linux__
using mesos::internal::tests::CapabilitiesTestHelper;
using mesos::internal::tests::SetnsTestHelper;
@@ -55,6 +55,6 @@ int main(int argc, char** argv)
#ifndef __WINDOWS__
new KillPolicyTestHelper(),
new MemoryTestHelper(),
-#endif // !__WINDOWS__
+#endif // __WINDOWS__
new ActiveUserTestHelper());
}
[4/4] mesos git commit: Windows: Stout: Removed dependency on Shell
API.
Posted by jo...@apache.org.
Windows: Stout: Removed dependency on Shell API.
The API `SHGetKnownFolderPath` requires `Shell32.dll`, which is not
available on Nano server (a version of Windows Server 2016).
An equivalent API `GetAllUsersProfileDirectory` is.
This API is also friendlier, as we own the allocation.
The Unicode version `GetAllUsersProfileDirectoryW` is explicitly used
so that we are guaranteed a Unicode path, which we then convert from
UTF-16 to UTF-8, instead of using the ANSI version which depends on a
varying Windows code-page, and is not recommended.
A `vector<wchar_t>` is used over a `wstring` to avoid dealing
with the placement of the null-terminating character.
Review: https://reviews.apache.org/r/54877/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/104532d8
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/104532d8
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/104532d8
Branch: refs/heads/master
Commit: 104532d867214b6d3c6fe96d6ebb144aa8803f7c
Parents: a92b8ad
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Thu Jan 12 17:54:14 2017 -0800
Committer: Joseph Wu <jo...@apache.org>
Committed: Thu Jan 12 17:59:08 2017 -0800
----------------------------------------------------------------------
3rdparty/stout/include/stout/windows.hpp | 5 ----
3rdparty/stout/include/stout/windows/os.hpp | 35 +++++++++++-------------
2 files changed, 16 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/104532d8/3rdparty/stout/include/stout/windows.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/windows.hpp b/3rdparty/stout/include/stout/windows.hpp
index e641c46..d89c709 100644
--- a/3rdparty/stout/include/stout/windows.hpp
+++ b/3rdparty/stout/include/stout/windows.hpp
@@ -50,11 +50,6 @@
#error "Mesos doesn't currently support the `_UNICODE` Windows header constant"
#endif // _UNICODE
-// Similarly, the Windows API uses `PWSTR` to mean `wchar_t*`,
-// but rather than assuming this is true, it should be asserted.
-static_assert(std::is_same<PWSTR, wchar_t*>::value,
- "Expected `PWSTR` to be of type `wchar_t*`.");
-
// An RAII `HANDLE`.
class SharedHandle : public std::shared_ptr<void>
{
http://git-wip-us.apache.org/repos/asf/mesos/blob/104532d8/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 5cd9254..b4a66ba 100644
--- a/3rdparty/stout/include/stout/windows/os.hpp
+++ b/3rdparty/stout/include/stout/windows/os.hpp
@@ -16,8 +16,8 @@
#include <direct.h>
#include <io.h>
#include <Psapi.h>
-#include <shlobj.h>
#include <TlHelp32.h>
+#include <Userenv.h>
#include <sys/utime.h>
@@ -724,27 +724,24 @@ inline Try<Nothing> kill_job(pid_t pid)
inline Try<std::string> var()
{
- wchar_t* var_folder = nullptr;
-
- // Retrieves the directory of `ProgramData` using the default options.
- // NOTE: The location of `ProgramData` is fixed and so does not
- // depend on the current user.
- if (::SHGetKnownFolderPath(
- FOLDERID_ProgramData,
- KF_FLAG_DEFAULT,
- nullptr,
- &var_folder) // `PWSTR` is `typedef wchar_t*`.
- != S_OK) {
- return WindowsError("os::var: Call to `SHGetKnownFolderPath` failed");
+ // Get the `ProgramData` path. First, find the size of the output buffer.
+ // This size includes the null-terminating character.
+ DWORD size = 0;
+ if (::GetAllUsersProfileDirectoryW(nullptr, &size)) {
+ // The expected behavior here is for the function to "fail"
+ // and return `false`, and `size` receives necessary buffer size.
+ return WindowsError(
+ "os::var: `GetAllUsersProfileDirectory` succeeded unexpectedly");
}
- // Convert `wchar_t*` to `wstring`.
- std::wstring wvar_folder(var_folder);
-
- // Free the buffer allocated by `SHGetKnownFolderPath`.
- CoTaskMemFree(static_cast<void*>(var_folder));
+ std::vector<wchar_t> var_folder(size);
+ if (!::GetAllUsersProfileDirectoryW(&var_folder[0], &size)) {
+ return WindowsError(
+ "os::var: `GetAllUsersProfileDirectory` failed");
+ }
- // Convert UTF-16 `wstring` to UTF-8 `string`.
+ // Convert UTF-16 `wchar[]` to UTF-8 `string`.
+ std::wstring wvar_folder(&var_folder[0]);
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>, wchar_t> converter;
return converter.to_bytes(wvar_folder);
}