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 2016/12/03 00:13:15 UTC
[3/5] mesos git commit: Fixed ownership semantics of `DynamicLibrary`.
Fixed ownership semantics of `DynamicLibrary`.
The class `DynamicLibrary` is a RAII wrapper around a handle to a
`dlopen`'ed library. To ensure consistent state any `dlopen`'ed library
will be `dlcose`'ed when the "owning" `DynamicLibrary` gets destructed
(e.g., when the wrapper goes out of scope, or when the library holding
a `static` `DynamicLibrary` gets unloaded).
This patch ensure that `DynamicLibraries` can be neither copy- nor
move-constructed. A copy constructor would lead to two wrappers
managing the same library handle which will lead to inconsistent state
(e.g., a library might be unloaded when a copy gets destructed even
though another copy still exists). While it might be possible to
implement a wrapper allowing move-construction, the current wrapper
does not support this.
Review: https://reviews.apache.org/r/54309/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/b763ee6c
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/b763ee6c
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/b763ee6c
Branch: refs/heads/master
Commit: b763ee6c60f747464bf66030c979644be654014f
Parents: 49ccd13
Author: Benjamin Bannier <be...@mesosphere.io>
Authored: Fri Dec 2 15:47:06 2016 -0800
Committer: Joseph Wu <jo...@apache.org>
Committed: Fri Dec 2 15:47:06 2016 -0800
----------------------------------------------------------------------
3rdparty/stout/include/stout/posix/dynamiclibrary.hpp | 6 ++++++
3rdparty/stout/include/stout/windows/dynamiclibrary.hpp | 6 ++++++
2 files changed, 12 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/b763ee6c/3rdparty/stout/include/stout/posix/dynamiclibrary.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/posix/dynamiclibrary.hpp b/3rdparty/stout/include/stout/posix/dynamiclibrary.hpp
index 2b34322..6a50592 100644
--- a/3rdparty/stout/include/stout/posix/dynamiclibrary.hpp
+++ b/3rdparty/stout/include/stout/posix/dynamiclibrary.hpp
@@ -30,6 +30,12 @@ class DynamicLibrary
public:
DynamicLibrary() : handle_(nullptr) { }
+ // Since this class manages a naked handle it cannot be copy- or
+ // move-constructed.
+ // TODO(bbannier): Allow for move-construction.
+ DynamicLibrary(const DynamicLibrary&) = delete;
+ DynamicLibrary(DynamicLibrary&&) = delete;
+
virtual ~DynamicLibrary()
{
if (handle_ != nullptr) {
http://git-wip-us.apache.org/repos/asf/mesos/blob/b763ee6c/3rdparty/stout/include/stout/windows/dynamiclibrary.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/windows/dynamiclibrary.hpp b/3rdparty/stout/include/stout/windows/dynamiclibrary.hpp
index cfa6c88..28b8e32 100644
--- a/3rdparty/stout/include/stout/windows/dynamiclibrary.hpp
+++ b/3rdparty/stout/include/stout/windows/dynamiclibrary.hpp
@@ -30,6 +30,12 @@ class DynamicLibrary
public:
DynamicLibrary() : handle_(nullptr) { }
+ // Since this class manages a naked handle it cannot be copy- or
+ // move-constructed.
+ // TODO(bbannier): Allow for move-construction.
+ DynamicLibrary(const DynamicLibrary&) = delete;
+ DynamicLibrary(DynamicLibrary&&) = delete;
+
virtual ~DynamicLibrary()
{
if (handle_ != nullptr) {