valeriyvdovin / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone
923a60
From dd004bcc058dbb7c66b8eb1a728732ccfce746c7 Mon Sep 17 00:00:00 2001
923a60
From: Jan Synacek <jsynacek@redhat.com>
923a60
Date: Tue, 5 Mar 2019 10:45:07 +0100
923a60
Subject: [PATCH] man: be more explicit about thread safety of sd_journal
923a60
923a60
This adds two generic paragaphs we include via xinclude. One is the
923a60
"strict" version, which contains wording saying that we are thread
923a60
agnostic and what that means. And the other is the "safe" version, for
923a60
the cases we provide fully safety.
923a60
923a60
Let's then change most man pages to use either of these generic
923a60
paragraphs. With one exception: man/sd_journal_get_catalog.xml contains
923a60
both kinds of function, we hence use manual wording.
923a60
923a60
(cherry picked from commit 64a7ef8bc06b5dcfcd9f99ea10a43bde75c4370f)
923a60
923a60
Related: #1609349
923a60
---
923a60
 man/sd-journal.xml                          | 14 ++++++++++++++
923a60
 man/sd_journal_get_catalog.xml              |  9 +++++++++
923a60
 man/sd_journal_get_cursor.xml               |  4 +++-
923a60
 man/sd_journal_get_cutoff_realtime_usec.xml |  4 +++-
923a60
 man/sd_journal_get_data.xml                 |  4 +++-
923a60
 man/sd_journal_get_fd.xml                   |  4 +++-
923a60
 man/sd_journal_get_realtime_usec.xml        |  4 +++-
923a60
 man/sd_journal_get_usage.xml                |  4 +++-
923a60
 man/sd_journal_has_runtime_files.xml        |  8 +++++++-
923a60
 man/sd_journal_next.xml                     |  4 +++-
923a60
 man/sd_journal_open.xml                     |  4 +++-
923a60
 man/sd_journal_print.xml                    |  4 +++-
923a60
 man/sd_journal_query_unique.xml             |  4 +++-
923a60
 man/sd_journal_seek_head.xml                |  4 +++-
923a60
 man/sd_journal_stream_fd.xml                |  4 +++-
923a60
 man/threads-aware.xml                       | 17 +++++++++++++++++
923a60
 16 files changed, 83 insertions(+), 13 deletions(-)
923a60
 create mode 100644 man/threads-aware.xml
923a60
923a60
diff --git a/man/sd-journal.xml b/man/sd-journal.xml
923a60
index a1185d372b..11af4cd9b9 100644
923a60
--- a/man/sd-journal.xml
923a60
+++ b/man/sd-journal.xml
923a60
@@ -97,6 +97,20 @@
923a60
     tool.</para>
923a60
   </refsect1>
923a60
 
923a60
+  <refsect1>
923a60
+    <title>Thread safety</title>
923a60
+
923a60
+    <para>Functions that operate on <structname>sd_journal</structname> objects are thread agnostic — given
923a60
+    <structname>sd_journal</structname> pointer may only be used from one specific thread at all times (and it has to
923a60
+    be the very same one during the entire lifetime of the object), but multiple, independent threads may use multiple,
923a60
+    independent objects safely. Other functions — those that are used to send entries to the journal, like
923a60
+    <citerefentry><refentrytitle>sd_journal_print</refentrytitle><manvolnum>3</manvolnum></citerefentry> and similar,
923a60
+    or those that are used to retrieve global information like
923a60
+    <citerefentry><refentrytitle>sd_journal_stream_fd</refentrytitle><manvolnum>3</manvolnum></citerefentry> and
923a60
+    <citerefentry><refentrytitle>sd_journal_get_catalog_for_message_id</refentrytitle><manvolnum>3</manvolnum></citerefentry>
923a60
+    are fully thread-safe and may be called from multiple threads in parallel.</para>
923a60
+  </refsect1>
923a60
+
923a60
   <xi:include href="libsystemd-pkgconfig.xml" />
923a60
 
923a60
   <refsect1>
923a60
diff --git a/man/sd_journal_get_catalog.xml b/man/sd_journal_get_catalog.xml
923a60
index c19eb11b20..86eb659fe5 100644
923a60
--- a/man/sd_journal_get_catalog.xml
923a60
+++ b/man/sd_journal_get_catalog.xml
923a60
@@ -112,6 +112,15 @@
923a60
   <refsect1>
923a60
     <title>Notes</title>
923a60
 
923a60
+    <para>Function <function>sd_journal_get_catalog()</function> is thread-agnostic and only
923a60
+    a single specific thread may operate on a given object during its entire lifetime. It's safe to allocate multiple
923a60
+    independent objects and use each from a specific thread in parallel. However, it's not safe to allocate such an
923a60
+    object in one thread, and operate or free it from any other, even if locking is used to ensure these threads don't
923a60
+    operate on it at the very same time.</para>
923a60
+
923a60
+    <para>Function <function>sd_journal_get_catalog_for_message_id()</function> is are thread-safe and may be called in
923a60
+    parallel from multiple threads.</para>
923a60
+
923a60
     <para>The <function>sd_journal_get_catalog()</function> and
923a60
     <function>sd_journal_get_catalog_for_message_id()</function>
923a60
     interfaces are available as a shared library, which can be
923a60
diff --git a/man/sd_journal_get_cursor.xml b/man/sd_journal_get_cursor.xml
923a60
index a400d8b1b5..0a20c36146 100644
923a60
--- a/man/sd_journal_get_cursor.xml
923a60
+++ b/man/sd_journal_get_cursor.xml
923a60
@@ -21,7 +21,7 @@
923a60
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
923a60
 -->
923a60
 
923a60
-<refentry id="sd_journal_get_cursor">
923a60
+<refentry id="sd_journal_get_cursor" xmlns:xi="http://www.w3.org/2001/XInclude">
923a60
 
923a60
   <refentryinfo>
923a60
     <title>sd_journal_get_cursor</title>
923a60
@@ -122,6 +122,8 @@
923a60
   <refsect1>
923a60
     <title>Notes</title>
923a60
 
923a60
+    <xi:include href="threads-aware.xml" xpointer="strict" />
923a60
+
923a60
     <para>The <function>sd_journal_get_cursor()</function> and
923a60
     <function>sd_journal_test_cursor()</function> interfaces are
923a60
     available as a shared library, which can be compiled and linked to
923a60
diff --git a/man/sd_journal_get_cutoff_realtime_usec.xml b/man/sd_journal_get_cutoff_realtime_usec.xml
923a60
index 23e7cc65e8..782228009d 100644
923a60
--- a/man/sd_journal_get_cutoff_realtime_usec.xml
923a60
+++ b/man/sd_journal_get_cutoff_realtime_usec.xml
923a60
@@ -21,7 +21,7 @@
923a60
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
923a60
 -->
923a60
 
923a60
-<refentry id="sd_journal_get_cutoff_realtime_usec">
923a60
+<refentry id="sd_journal_get_cutoff_realtime_usec" xmlns:xi="http://www.w3.org/2001/XInclude">
923a60
 
923a60
   <refentryinfo>
923a60
     <title>sd_journal_get_cutoff_realtime_usec</title>
923a60
@@ -120,6 +120,8 @@
923a60
   <refsect1>
923a60
     <title>Notes</title>
923a60
 
923a60
+    <xi:include href="threads-aware.xml" xpointer="strict" />
923a60
+
923a60
     <para>The
923a60
     <function>sd_journal_get_cutoff_realtime_usec()</function> and
923a60
     <function>sd_journal_get_cutoff_monotonic_usec()</function>
923a60
diff --git a/man/sd_journal_get_data.xml b/man/sd_journal_get_data.xml
923a60
index 1afbd7371c..dce421795a 100644
923a60
--- a/man/sd_journal_get_data.xml
923a60
+++ b/man/sd_journal_get_data.xml
923a60
@@ -21,7 +21,7 @@
923a60
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
923a60
 -->
923a60
 
923a60
-<refentry id="sd_journal_get_data">
923a60
+<refentry id="sd_journal_get_data" xmlns:xi="http://www.w3.org/2001/XInclude">
923a60
 
923a60
   <refentryinfo>
923a60
     <title>sd_journal_get_data</title>
923a60
@@ -183,6 +183,8 @@
923a60
   <refsect1>
923a60
     <title>Notes</title>
923a60
 
923a60
+    <xi:include href="threads-aware.xml" xpointer="strict"/>
923a60
+
923a60
     <para>The <function>sd_journal_get_data()</function>,
923a60
     <function>sd_journal_enumerate_data()</function>,
923a60
     <function>sd_journal_restart_data()</function>,
923a60
diff --git a/man/sd_journal_get_fd.xml b/man/sd_journal_get_fd.xml
923a60
index 3a38f733ab..a96857d0df 100644
923a60
--- a/man/sd_journal_get_fd.xml
923a60
+++ b/man/sd_journal_get_fd.xml
923a60
@@ -21,7 +21,7 @@
923a60
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
923a60
 -->
923a60
 
923a60
-<refentry id="sd_journal_get_fd">
923a60
+<refentry id="sd_journal_get_fd" xmlns:xi="http://www.w3.org/2001/XInclude">
923a60
 
923a60
   <refentryinfo>
923a60
     <title>sd_journal_get_fd</title>
923a60
@@ -231,6 +231,8 @@ else {
923a60
   <refsect1>
923a60
     <title>Notes</title>
923a60
 
923a60
+    <xi:include href="threads-aware.xml" xpointer="strict"/>
923a60
+
923a60
     <para>The <function>sd_journal_get_fd()</function>,
923a60
     <function>sd_journal_get_events()</function>,
923a60
     <function>sd_journal_reliable_fd()</function>,
923a60
diff --git a/man/sd_journal_get_realtime_usec.xml b/man/sd_journal_get_realtime_usec.xml
923a60
index 607d74666b..b67e4d6c2d 100644
923a60
--- a/man/sd_journal_get_realtime_usec.xml
923a60
+++ b/man/sd_journal_get_realtime_usec.xml
923a60
@@ -21,7 +21,7 @@
923a60
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
923a60
 -->
923a60
 
923a60
-<refentry id="sd_journal_get_realtime_usec">
923a60
+<refentry id="sd_journal_get_realtime_usec" xmlns:xi="http://www.w3.org/2001/XInclude">
923a60
 
923a60
   <refentryinfo>
923a60
     <title>sd_journal_get_realtime_usec</title>
923a60
@@ -115,6 +115,8 @@
923a60
   <refsect1>
923a60
     <title>Notes</title>
923a60
 
923a60
+    <xi:include href="threads-aware.xml" xpointer="strict"/>
923a60
+
923a60
     <para>The <function>sd_journal_get_realtime_usec()</function> and
923a60
     <function>sd_journal_get_monotonic_usec()</function> interfaces
923a60
     are available as a shared library, which can be compiled and
923a60
diff --git a/man/sd_journal_get_usage.xml b/man/sd_journal_get_usage.xml
923a60
index 72c804d834..6281bc850d 100644
923a60
--- a/man/sd_journal_get_usage.xml
923a60
+++ b/man/sd_journal_get_usage.xml
923a60
@@ -21,7 +21,7 @@
923a60
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
923a60
 -->
923a60
 
923a60
-<refentry id="sd_journal_get_usage">
923a60
+<refentry id="sd_journal_get_usage" xmlns:xi="http://www.w3.org/2001/XInclude">
923a60
 
923a60
   <refentryinfo>
923a60
     <title>sd_journal_get_usage</title>
923a60
@@ -80,6 +80,8 @@
923a60
   <refsect1>
923a60
     <title>Notes</title>
923a60
 
923a60
+    <xi:include href="threads-aware.xml" xpointer="strict"/>
923a60
+
923a60
     <para>The <function>sd_journal_get_usage()</function> interface is
923a60
     available as a shared library, which can be compiled and linked to
923a60
     with the
923a60
diff --git a/man/sd_journal_has_runtime_files.xml b/man/sd_journal_has_runtime_files.xml
923a60
index 237e649206..4dff3c67d0 100644
923a60
--- a/man/sd_journal_has_runtime_files.xml
923a60
+++ b/man/sd_journal_has_runtime_files.xml
923a60
@@ -21,7 +21,7 @@
923a60
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
923a60
 -->
923a60
 
923a60
-<refentry id="sd_journal_has_runtime_files">
923a60
+<refentry id="sd_journal_has_runtime_files" xmlns:xi="http://www.w3.org/2001/XInclude">
923a60
 
923a60
   <refentryinfo>
923a60
     <title>sd_journal_has_runtime_files</title>
923a60
@@ -85,6 +85,12 @@
923a60
     </para>
923a60
   </refsect1>
923a60
 
923a60
+  <refsect1>
923a60
+    <title>Notes</title>
923a60
+
923a60
+    <xi:include href="threads-aware.xml" xpointer="strict"/>
923a60
+  </refsect1>
923a60
+
923a60
   <refsect1>
923a60
     <title>See Also</title>
923a60
     <para>
923a60
diff --git a/man/sd_journal_next.xml b/man/sd_journal_next.xml
923a60
index 115fe26661..c8664994ce 100644
923a60
--- a/man/sd_journal_next.xml
923a60
+++ b/man/sd_journal_next.xml
923a60
@@ -21,7 +21,7 @@
923a60
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
923a60
 -->
923a60
 
923a60
-<refentry id="sd_journal_next">
923a60
+<refentry id="sd_journal_next" xmlns:xi="http://www.w3.org/2001/XInclude">
923a60
 
923a60
   <refentryinfo>
923a60
     <title>sd_journal_next</title>
923a60
@@ -146,6 +146,8 @@
923a60
   <refsect1>
923a60
     <title>Notes</title>
923a60
 
923a60
+    <xi:include href="threads-aware.xml" xpointer="strict"/>
923a60
+
923a60
     <para>The <function>sd_journal_next()</function>,
923a60
     <function>sd_journal_previous()</function>,
923a60
     <function>sd_journal_next_skip()</function> and
923a60
diff --git a/man/sd_journal_open.xml b/man/sd_journal_open.xml
923a60
index fb572802a3..c3044670de 100644
923a60
--- a/man/sd_journal_open.xml
923a60
+++ b/man/sd_journal_open.xml
923a60
@@ -21,7 +21,7 @@
923a60
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
923a60
 -->
923a60
 
923a60
-<refentry id="sd_journal_open">
923a60
+<refentry id="sd_journal_open" xmlns:xi="http://www.w3.org/2001/XInclude">
923a60
 
923a60
   <refentryinfo>
923a60
     <title>sd_journal_open</title>
923a60
@@ -196,6 +196,8 @@
923a60
   <refsect1>
923a60
     <title>Notes</title>
923a60
 
923a60
+    <xi:include href="threads-aware.xml" xpointer="strict"/>
923a60
+
923a60
     <para>The <function>sd_journal_open()</function>,
923a60
     <function>sd_journal_open_directory()</function> and
923a60
     <function>sd_journal_close()</function> interfaces are available
923a60
diff --git a/man/sd_journal_print.xml b/man/sd_journal_print.xml
923a60
index 0cd0b45b9a..50ad5de7be 100644
923a60
--- a/man/sd_journal_print.xml
923a60
+++ b/man/sd_journal_print.xml
923a60
@@ -21,7 +21,7 @@
923a60
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
923a60
 -->
923a60
 
923a60
-<refentry id="sd_journal_print">
923a60
+<refentry id="sd_journal_print" xmlns:xi="http://www.w3.org/2001/XInclude">
923a60
 
923a60
   <refentryinfo>
923a60
     <title>sd_journal_print</title>
923a60
@@ -232,6 +232,8 @@ sd_journal_send("MESSAGE=Hello World, this is PID %lu!", (unsigned long) getpid(
923a60
   <refsect1>
923a60
     <title>Notes</title>
923a60
 
923a60
+    <xi:include href="threads-aware.xml" xpointer="safe"/>
923a60
+
923a60
     <para>The <function>sd_journal_print()</function>,
923a60
     <function>sd_journal_printv()</function>,
923a60
     <function>sd_journal_send()</function> and
923a60
diff --git a/man/sd_journal_query_unique.xml b/man/sd_journal_query_unique.xml
923a60
index ac0e5f633f..074dfd6789 100644
923a60
--- a/man/sd_journal_query_unique.xml
923a60
+++ b/man/sd_journal_query_unique.xml
923a60
@@ -21,7 +21,7 @@
923a60
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
923a60
 -->
923a60
 
923a60
-<refentry id="sd_journal_query_unique">
923a60
+<refentry id="sd_journal_query_unique" xmlns:xi="http://www.w3.org/2001/XInclude">
923a60
 
923a60
   <refentryinfo>
923a60
     <title>sd_journal_query_unique</title>
923a60
@@ -145,6 +145,8 @@
923a60
   <refsect1>
923a60
     <title>Notes</title>
923a60
 
923a60
+    <xi:include href="threads-aware.xml" xpointer="strict"/>
923a60
+
923a60
     <para>The <function>sd_journal_query_unique()</function>,
923a60
     <function>sd_journal_enumerate_unique()</function> and
923a60
     <function>sd_journal_restart_unique()</function> interfaces are
923a60
diff --git a/man/sd_journal_seek_head.xml b/man/sd_journal_seek_head.xml
923a60
index d74c2d5bbc..8bbbb22a73 100644
923a60
--- a/man/sd_journal_seek_head.xml
923a60
+++ b/man/sd_journal_seek_head.xml
923a60
@@ -21,7 +21,7 @@
923a60
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
923a60
 -->
923a60
 
923a60
-<refentry id="sd_journal_seek_head">
923a60
+<refentry id="sd_journal_seek_head" xmlns:xi="http://www.w3.org/2001/XInclude">
923a60
 
923a60
   <refentryinfo>
923a60
     <title>sd_journal_seek_head</title>
923a60
@@ -144,6 +144,8 @@
923a60
   <refsect1>
923a60
     <title>Notes</title>
923a60
 
923a60
+    <xi:include href="threads-aware.xml" xpointer="strict"/>
923a60
+
923a60
     <para>The <function>sd_journal_seek_head()</function>,
923a60
     <function>sd_journal_seek_tail()</function>,
923a60
     <function>sd_journal_seek_monotonic_usec()</function>,
923a60
diff --git a/man/sd_journal_stream_fd.xml b/man/sd_journal_stream_fd.xml
923a60
index 2ea7731b48..340760ba36 100644
923a60
--- a/man/sd_journal_stream_fd.xml
923a60
+++ b/man/sd_journal_stream_fd.xml
923a60
@@ -21,7 +21,7 @@
923a60
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
923a60
 -->
923a60
 
923a60
-<refentry id="sd_journal_stream_fd">
923a60
+<refentry id="sd_journal_stream_fd" xmlns:xi="http://www.w3.org/2001/XInclude">
923a60
 
923a60
   <refentryinfo>
923a60
     <title>sd_journal_stream_fd</title>
923a60
@@ -104,6 +104,8 @@
923a60
   <refsect1>
923a60
     <title>Notes</title>
923a60
 
923a60
+    <xi:include href="threads-aware.xml" xpointer="safe"/>
923a60
+
923a60
     <para>The <function>sd_journal_stream_fd()</function> interface is
923a60
     available as a shared library, which can be compiled and linked to
923a60
     with the
923a60
diff --git a/man/threads-aware.xml b/man/threads-aware.xml
923a60
new file mode 100644
923a60
index 0000000000..7985f4acd1
923a60
--- /dev/null
923a60
+++ b/man/threads-aware.xml
923a60
@@ -0,0 +1,17 @@
923a60
+
923a60
+
923a60
+
923a60
+
923a60
+  SPDX-License-Identifier: LGPL-2.1+
923a60
+-->
923a60
+
923a60
+<refsect1>
923a60
+
923a60
+<para id="strict">All functions listed here are thread-agnostic and only a single specific thread may operate on a
923a60
+given object during its entire lifetime. It's safe to allocate multiple independent objects and use each from a
923a60
+specific thread in parallel. However, it's not safe to allocate such an object in one thread, and operate or free it
923a60
+from any other, even if locking is used to ensure these threads don't operate on it at the very same time.</para>
923a60
+
923a60
+<para id="safe">All functions listed here are thread-safe and may be called in parallel from multiple threads.</para>
923a60
+
923a60
+</refsect1>