You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2016/12/05 05:42:35 UTC
[3/9] mesos git commit: Added os::ptsname to stout.
Added os::ptsname to stout.
Review: https://reviews.apache.org/r/54291
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/5ee6f4f3
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/5ee6f4f3
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/5ee6f4f3
Branch: refs/heads/master
Commit: 5ee6f4f3ff2ad2e10cd2b3430f20c883b2f5b384
Parents: 4df544f
Author: Jie Yu <yu...@gmail.com>
Authored: Thu Dec 1 17:13:09 2016 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Sun Dec 4 21:41:51 2016 -0800
----------------------------------------------------------------------
3rdparty/stout/include/stout/posix/os.hpp | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/5ee6f4f3/3rdparty/stout/include/stout/posix/os.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/posix/os.hpp b/3rdparty/stout/include/stout/posix/os.hpp
index c37e64d..72e69a00 100644
--- a/3rdparty/stout/include/stout/posix/os.hpp
+++ b/3rdparty/stout/include/stout/posix/os.hpp
@@ -45,10 +45,13 @@
#include <list>
#include <map>
+#include <mutex>
#include <set>
#include <string>
#include <vector>
+#include <stout/synchronized.hpp>
+
#include <stout/os/close.hpp>
#include <stout/os/environment.hpp>
#include <stout/os/fcntl.hpp>
@@ -469,6 +472,23 @@ inline Try<Nothing> pipe(int pipe_fd[2])
return Nothing();
}
+
+inline Try<std::string> ptsname(int master)
+{
+ // 'ptsname' is not thread safe. Therefore, we use mutex here to
+ // make this method thread safe.
+ // TODO(jieyu): Consider using ptsname_r for linux.
+ static std::mutex* mutex = new std::mutex;
+
+ synchronized (mutex) {
+ const char* slavePath = ::ptsname(master);
+ if (slavePath == nullptr) {
+ return ErrnoError();
+ }
+ return slavePath;
+ }
+}
+
} // namespace os {
#endif // __STOUT_POSIX_OS_HPP__