Update linux fs to use synchronized. Review: https://reviews.apache.org/r/35095
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/5b0eeb0b Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/5b0eeb0b Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/5b0eeb0b Branch: refs/heads/master Commit: 5b0eeb0b761343e61de5593fba062ee3229dad1a Parents: eb33a57 Author: Joris Van Remoortere <[email protected]> Authored: Sat Jun 13 07:05:33 2015 -0700 Committer: Benjamin Hindman <[email protected]> Committed: Sun Jun 14 02:43:01 2015 -0700 ---------------------------------------------------------------------- src/linux/fs.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/5b0eeb0b/src/linux/fs.cpp ---------------------------------------------------------------------- diff --git a/src/linux/fs.cpp b/src/linux/fs.cpp index 1c9cf3f..568565f 100644 --- a/src/linux/fs.cpp +++ b/src/linux/fs.cpp @@ -26,12 +26,11 @@ #include <stout/numify.hpp> #include <stout/path.hpp> #include <stout/strings.hpp> +#include <stout/synchronized.hpp> #include <stout/os/read.hpp> #include <stout/os/stat.hpp> -#include "common/lock.hpp" - #include "linux/fs.hpp" using std::string; @@ -188,10 +187,9 @@ Try<MountTable> MountTable::read(const string& path) // Mutex for guarding calls into non-reentrant mount table // functions. We use a static local variable to avoid unused // variable warnings. - static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; + static std::mutex mutex; - { - Lock lock(&mutex); + synchronized (mutex) { struct mntent* mntent = ::getmntent(file); if (mntent == NULL) { // NULL means the end of enties. @@ -219,14 +217,12 @@ Try<FileSystemTable> FileSystemTable::read() { // Mutex for guarding calls into non-reentrant fstab functions. We // use a static local variable to avoid unused variable warnings. - static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; + static std::mutex mutex; FileSystemTable table; // Use locks since fstab functions are not thread-safe. - { - Lock lock(&mutex); - + synchronized (mutex) { // Open file _PATH_FSTAB (/etc/fstab). if (::setfsent() == 0) { return Error("Failed to open file system table");
