diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
commit | 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch) | |
tree | e5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/boost/libs/log/config/pthread-mutex-robust | |
parent | Initial commit. (diff) | |
download | ceph-upstream.tar.xz ceph-upstream.zip |
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/log/config/pthread-mutex-robust')
-rw-r--r-- | src/boost/libs/log/config/pthread-mutex-robust/Jamfile.jam | 19 | ||||
-rw-r--r-- | src/boost/libs/log/config/pthread-mutex-robust/pthread_mutex_robust.cpp | 37 |
2 files changed, 56 insertions, 0 deletions
diff --git a/src/boost/libs/log/config/pthread-mutex-robust/Jamfile.jam b/src/boost/libs/log/config/pthread-mutex-robust/Jamfile.jam new file mode 100644 index 00000000..6082e66e --- /dev/null +++ b/src/boost/libs/log/config/pthread-mutex-robust/Jamfile.jam @@ -0,0 +1,19 @@ +# +# Copyright Andrey Semashev 2015. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) +# + +import project ; +import log-platform-config ; + +project /boost/log/pthread-mutex-robust + : source-location . + : requirements + <conditional>@log-platform-config.set-platform-defines + + <pch>off + ; + +obj pthread_mutex_robust : pthread_mutex_robust.cpp ; diff --git a/src/boost/libs/log/config/pthread-mutex-robust/pthread_mutex_robust.cpp b/src/boost/libs/log/config/pthread-mutex-robust/pthread_mutex_robust.cpp new file mode 100644 index 00000000..36415aca --- /dev/null +++ b/src/boost/libs/log/config/pthread-mutex-robust/pthread_mutex_robust.cpp @@ -0,0 +1,37 @@ +/* + * Copyright Andrey Semashev 2015. + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + */ + +#include <errno.h> +#include <pthread.h> + +int main(int, char*[]) +{ + pthread_mutexattr_t attr; + pthread_mutexattr_init(&attr); + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL); + pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); + pthread_mutexattr_setrobust(&attr, PTHREAD_MUTEX_ROBUST); + + pthread_mutex_t m; + pthread_mutex_init(&m, &attr); + pthread_mutexattr_destroy(&attr); + + int err = pthread_mutex_lock(&m); + if (err == EOWNERDEAD) + { + err = pthread_mutex_consistent(&m); + } + + if (err != ENOTRECOVERABLE) + { + pthread_mutex_unlock(&m); + } + + pthread_mutex_destroy(&m); + + return 0; +} |