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/02/15 21:40:39 UTC
[3/7] mesos git commit: Stout: Explicitly delete `SharedHandle`
default constructor.
Stout: Explicitly delete `SharedHandle` default constructor.
This forces callsites to make an explicit decision about the
value of an empty HANDLE, which differs based on the syscall
used to construct the HANDLE.
Review: https://reviews.apache.org/r/56347/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/bd5c868b
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/bd5c868b
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/bd5c868b
Branch: refs/heads/master
Commit: bd5c868b8a8e1c488f7ddfebe20bf71f4478289f
Parents: 3ade036
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Thu Feb 9 14:34:28 2017 -0800
Committer: Joseph Wu <jo...@apache.org>
Committed: Wed Feb 15 13:40:19 2017 -0800
----------------------------------------------------------------------
3rdparty/stout/include/stout/windows.hpp | 8 ++++++++
1 file changed, 8 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/bd5c868b/3rdparty/stout/include/stout/windows.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/windows.hpp b/3rdparty/stout/include/stout/windows.hpp
index 3bc973b..8b8dc61 100644
--- a/3rdparty/stout/include/stout/windows.hpp
+++ b/3rdparty/stout/include/stout/windows.hpp
@@ -57,6 +57,14 @@ class SharedHandle : public std::shared_ptr<void>
"Expected `HANDLE` to be of type `void*`.");
public:
+ // We delete the default constructor so that the callsite is forced to make
+ // an explicit decision about what the empty `HANDLE` value should be, as it
+ // is not the same for all `HANDLE` types. For example, `OpenProcess`
+ // returns a `nullptr` for an invalid handle, but `CreateFile` returns an
+ // `INVALID_HANDLE_VALUE` instead. This inconsistency is inherent in the
+ // Windows API.
+ SharedHandle() = delete;
+
template <typename Deleter>
SharedHandle(HANDLE handle, Deleter deleter)
: std::shared_ptr<void>(handle, deleter) {}