]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
man: be more explicit about thread safety of sd_journal
authorLennart Poettering <lennart@poettering.net>
Fri, 3 Aug 2018 14:43:30 +0000 (16:43 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 3 Aug 2018 15:36:11 +0000 (17:36 +0200)
Triggered by https://bugzilla.redhat.com/show_bug.cgi?id=1609349

This adds two generic paragaphs we include via xinclude. One is the
"strict" version, which contains wording saying that we are thread
agnostic and what that means. And the other is the "safe" version, for
the cases we provide fully safety.

Let's then change most man pages to use either of these generic
paragraphs. With one exception: man/sd_journal_get_catalog.xml contains
both kinds of function, we hence use manual wording.

18 files changed:
man/libudev.xml
man/sd-journal.xml
man/sd_journal_enumerate_fields.xml
man/sd_journal_get_catalog.xml
man/sd_journal_get_cursor.xml
man/sd_journal_get_cutoff_realtime_usec.xml
man/sd_journal_get_data.xml
man/sd_journal_get_fd.xml
man/sd_journal_get_realtime_usec.xml
man/sd_journal_get_usage.xml
man/sd_journal_has_runtime_files.xml
man/sd_journal_next.xml
man/sd_journal_open.xml
man/sd_journal_print.xml
man/sd_journal_query_unique.xml
man/sd_journal_seek_head.xml
man/sd_journal_stream_fd.xml
man/threads-aware.xml [new file with mode: 0644]

index 8cb4ba59fc3382a7297d5666030eef0d1be6f4b5..382c1aa25c518a76cd52bf61e201e386a7b45cde 100644 (file)
     <citerefentry><refentrytitle>udev_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
     It is used to track library state and link objects together. No
     global state is used by libudev, everything is always linked to
-    a udev context. Furthermore, multiple different udev contexts can
-    be used in parallel by multiple threads. However, a single context
-    must not be accessed by multiple threads in parallel. The caller
-    is responsible for providing suitable locking if they intend to use
-    it from multiple threads.</para>
+    a udev context.</para>
+
+    <xi:include href="threads-aware.xml" xpointer="strict"/>
 
     <para>To introspect a local device on a system, a udev device
     object can be created via
index 8bfcb90ca0e72a92739f801ff0c2bbcd4edb49ee..3fa6c75b7e9a66934a04761d2864d0f3db73b286 100644 (file)
   <refsect1>
     <title>Thread safety</title>
 
-    <para>Functions that operate on the <structname>sd_journal</structname> object are thread
-    agnostic — given <structname>sd_journal</structname> pointer may only be used from one thread at
-    a time, but multiple threads may use multiple such objects safely. Other functions —
-    those that are used to send entries to the journal, like
-    <citerefentry><refentrytitle>sd_journal_print</refentrytitle><manvolnum>3</manvolnum></citerefentry>
-    and similar, or those that are used to retrieve global information like
-    <citerefentry><refentrytitle>sd_journal_stream_fd</refentrytitle><manvolnum>3</manvolnum></citerefentry>
-    and
+    <para>Functions that operate on <structname>sd_journal</structname> objects are thread agnostic — given
+    <structname>sd_journal</structname> pointer may only be used from one specific thread at all times (and it has to
+    be the very same one during the entire lifetime of the object), but multiple, independent threads may use multiple,
+    independent objects safely. Other functions — those that are used to send entries to the journal, like
+    <citerefentry><refentrytitle>sd_journal_print</refentrytitle><manvolnum>3</manvolnum></citerefentry> and similar,
+    or those that are used to retrieve global information like
+    <citerefentry><refentrytitle>sd_journal_stream_fd</refentrytitle><manvolnum>3</manvolnum></citerefentry> and
     <citerefentry><refentrytitle>sd_journal_get_catalog_for_message_id</refentrytitle><manvolnum>3</manvolnum></citerefentry>
-    — are thread-safe and may be called from multiple threads in parallel.</para>
+    — are fully thread-safe and may be called from multiple threads in parallel.</para>
   </refsect1>
 
   <xi:include href="libsystemd-pkgconfig.xml" />
index 95af2c1ee0a07e212c9c207c9066939061efe4cd..c5704f53adf510784a1372acb949006447a8f87c 100644 (file)
@@ -86,8 +86,7 @@
   <refsect1>
     <title>Notes</title>
 
-    <para>All functions listed here are thread-agnostic and only a single thread may operate
-    on a given <structname>sd_journal</structname> object.</para>
+    <xi:include href="threads-aware.xml" xpointer="strict" />
 
     <xi:include href="libsystemd-pkgconfig.xml" xpointer="pkgconfig-text"/>
   </refsect1>
index ce37e177bd1e639586d0ffdb77a639b8b234aa0b..80edc08c8121a3d34514c63037eb93f6147cb994 100644 (file)
   <refsect1>
     <title>Notes</title>
 
-    <para>Function <function>sd_journal_get_catalog()</function> is thread-agnostic and only a
-    single thread may operate on a given <structname>sd_journal</structname> object. Function
-    <function>sd_journal_get_catalog_for_message_id()</function> is thread-safe.</para>
+    <para>Function <function>sd_journal_get_catalog()</function> is thread-agnostic and only
+    a single specific thread may operate on a given object during its entire lifetime. It's safe to allocate multiple
+    independent objects and use each from a specific thread in parallel. However, it's not safe to allocate such an
+    object in one thread, and operate or free it from any other, even if locking is used to ensure these threads don't
+    operate on it at the very same time.</para>
+
+    <para>Function <function>sd_journal_get_catalog_for_message_id()</function> is are thread-safe and may be called in
+    parallel from multiple threads.</para>
 
     <xi:include href="libsystemd-pkgconfig.xml" xpointer="pkgconfig-text"/>
   </refsect1>
index 6817a3cd54295b0d39492bc00f3f6a057715da87..d5e465b81ac58a436836c83942443bac80876604 100644 (file)
@@ -98,8 +98,7 @@
   <refsect1>
     <title>Notes</title>
 
-    <para>All functions listed here are thread-agnostic and only a single thread may operate
-    on a given <structname>sd_journal</structname> object.</para>
+    <xi:include href="threads-aware.xml" xpointer="strict" />
 
     <xi:include href="libsystemd-pkgconfig.xml" xpointer="pkgconfig-text"/>
   </refsect1>
index dc8e32bf81beee2f11a2d9f54132049aef4339d2..b2a0634f7dd86f99959591739e91bf6643201f58 100644 (file)
@@ -96,8 +96,7 @@
   <refsect1>
     <title>Notes</title>
 
-    <para>All functions listed here are thread-agnostic and only a single thread may operate
-    on a given <structname>sd_journal</structname> object.</para>
+    <xi:include href="threads-aware.xml" xpointer="strict" />
 
     <xi:include href="libsystemd-pkgconfig.xml" xpointer="pkgconfig-text"/>
   </refsect1>
index 99f9500441b1347718535c4e57a1aa961a953b12..464fd16ace16e53a9acd24b3f75719b6f6238f6f 100644 (file)
     success or a negative errno-style error code.</para>
   </refsect1>
 
-  <xi:include href="libsystemd-pkgconfig.xml" />
+  <refsect1>
+    <title>Notes</title>
+
+    <xi:include href="threads-aware.xml" xpointer="strict"/>
+
+    <xi:include href="libsystemd-pkgconfig.xml" xpointer="pkgconfig-text"/>
+  </refsect1>
 
   <refsect1>
     <title>Examples</title>
index 7edbc4bc2513e27bd2c195031a2f5fa71e32e328..2186b685bfc91672e6bc4d2586663a02e1524e94 100644 (file)
@@ -226,14 +226,9 @@ else {
   <refsect1>
     <title>Notes</title>
 
-    <para>The <function>sd_journal_get_fd()</function>,
-    <function>sd_journal_get_events()</function>,
-    <function>sd_journal_reliable_fd()</function>,
-    <function>sd_journal_process()</function> and
-    <function>sd_journal_wait()</function> interfaces are available as
-    a shared library, which can be compiled and linked to with the
-    <constant>libsystemd</constant> <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
-    file.</para>
+    <xi:include href="threads-aware.xml" xpointer="strict"/>
+
+    <xi:include href="libsystemd-pkgconfig.xml" xpointer="pkgconfig-text"/>
   </refsect1>
 
   <refsect1>
index 2030e8372db6193ba7db7837c82f8fe8e0c36f1e..e0f5c4d2e98989a1168af8f43817d01c1ca271d6 100644 (file)
     <function>sd_journal_get_monotonic_usec()</function>.</para>
   </refsect1>
 
-  <xi:include href="libsystemd-pkgconfig.xml" />
+  <refsect1>
+    <title>Notes</title>
+
+    <xi:include href="threads-aware.xml" xpointer="strict"/>
+
+    <xi:include href="libsystemd-pkgconfig.xml" xpointer="pkgconfig-text"/>
+  </refsect1>
 
   <refsect1>
     <title>See Also</title>
index 358a62d0663abff8d2dc02949e432d9c16d65810..39f53dd5eb6dfe213deb0f1f8ecf8c849de2fb0c 100644 (file)
@@ -56,8 +56,7 @@
   <refsect1>
     <title>Notes</title>
 
-    <para>All functions listed here are thread-agnostic and only a single thread may operate
-    on a given <structname>sd_journal</structname> object.</para>
+    <xi:include href="threads-aware.xml" xpointer="strict"/>
 
     <xi:include href="libsystemd-pkgconfig.xml" xpointer="pkgconfig-text"/>
   </refsect1>
index b7bbf224d43d452a2e12f05d8c4c375ccbe400b5..44fdc8d18689d48914f401165000298f83483f70 100644 (file)
@@ -66,8 +66,7 @@
   <refsect1>
     <title>Notes</title>
 
-    <para>All functions listed here are thread-agnostic and only a single thread may operate
-    on a given <structname>sd_journal</structname> object.</para>
+    <xi:include href="threads-aware.xml" xpointer="strict"/>
 
     <xi:include href="libsystemd-pkgconfig.xml" xpointer="pkgconfig-text"/>
   </refsect1>
index c0ca5a8a14cb2235a929dccb04b6a2349ad1ac84..9a27d1426e3574501a8bdc3b5cd46c5ae473f8e7 100644 (file)
   <refsect1>
     <title>Notes</title>
 
-    <para>All functions listed here are thread-agnostic and only a single thread may operate
-    on a given <structname>sd_journal</structname> object.</para>
+    <xi:include href="threads-aware.xml" xpointer="strict"/>
 
     <xi:include href="libsystemd-pkgconfig.xml" xpointer="pkgconfig-text"/>
   </refsect1>
index 9f600b223f1f1b005e29e31fee00a8dd907dfb69..cf787b7ea1c2c84c07bcb9ebce8f51225b8e39aa 100644 (file)
@@ -6,7 +6,8 @@
   SPDX-License-Identifier: LGPL-2.1+
 -->
 
-<refentry id="sd_journal_open">
+<refentry id="sd_journal_open"
+          xmlns:xi="http://www.w3.org/2001/XInclude">
 
   <refentryinfo>
     <title>sd_journal_open</title>
   <refsect1>
     <title>Notes</title>
 
-    <para>All functions listed here are thread-agnostic and only a single thread may operate
-    on a given <structname>sd_journal</structname> object.</para>
+    <xi:include href="threads-aware.xml" xpointer="strict"/>
 
-    <para>The <function>sd_journal_open()</function>,
-    <function>sd_journal_open_directory()</function> and
-    <function>sd_journal_close()</function> interfaces are available
-    as a shared library, which can be compiled and linked to with the
-    <constant>libsystemd</constant> <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
-    file.</para>
+    <xi:include href="libsystemd-pkgconfig.xml" xpointer="pkgconfig-text"/>
   </refsect1>
 
   <refsect1>
index f8ff7ba0932d9001178edc522309c6ea5b2648cd..e18cf88bbcf2076d9a9e52abd912eecdde7f4576 100644 (file)
@@ -177,7 +177,8 @@ sd_journal_send("MESSAGE=Hello World, this is PID %lu!", (unsigned long) getpid(
 
   <refsect1>
     <title>Thread safety</title>
-    <para>All functions listed here are thread-safe and may be called in parallel from multiple threads.</para>
+
+    <xi:include href="threads-aware.xml" xpointer="safe"/>
 
     <para><function>sd_journal_sendv()</function> is "async signal safe" in the meaning of <citerefentry
     project='man-pages'><refentrytitle>signal-safety</refentrytitle><manvolnum>7</manvolnum></citerefentry>.
index c62f333eabb809aed1c1b8985ed888f7b15ee668..9adafa114460c05fe7ab3ca47ac32f2cca9c7178 100644 (file)
   <refsect1>
     <title>Notes</title>
 
-    <para>All functions listed here are thread-agnostic and only a single thread may operate
-    on a given <structname>sd_journal</structname> object.</para>
+    <xi:include href="threads-aware.xml" xpointer="strict"/>
 
     <xi:include href="libsystemd-pkgconfig.xml" xpointer="pkgconfig-text"/>
   </refsect1>
index 86274071f539a3243fdc086b6e400bbac33edb5f..da88d241e873bb839891e024df7217cea75ec50a 100644 (file)
   <refsect1>
     <title>Notes</title>
 
-    <para>All functions listed here are thread-agnostic and only a single thread may operate
-    on a given <structname>sd_journal</structname> object.</para>
+    <xi:include href="threads-aware.xml" xpointer="strict"/>
 
     <xi:include href="libsystemd-pkgconfig.xml" xpointer="pkgconfig-text"/>
   </refsect1>
index de76cabb4d44c71e0ea7b52d6aae0275fb33602e..8e65dc76580f498394058196eee6c849214abc97 100644 (file)
@@ -92,8 +92,7 @@
   <refsect1>
     <title>Notes</title>
 
-    <para>Function <function>sd_journal_stream_fd()</function> is thread-safe and may be called
-    from multiple threads.</para>
+    <xi:include href="threads-aware.xml" xpointer="safe"/>
 
     <xi:include href="libsystemd-pkgconfig.xml" xpointer="pkgconfig-text"/>
   </refsect1>
diff --git a/man/threads-aware.xml b/man/threads-aware.xml
new file mode 100644 (file)
index 0000000..7985f4a
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+
+<!--
+  SPDX-License-Identifier: LGPL-2.1+
+-->
+
+<refsect1>
+
+<para id="strict">All functions listed here are thread-agnostic and only a single specific thread may operate on a
+given object during its entire lifetime. It's safe to allocate multiple independent objects and use each from a
+specific thread in parallel. However, it's not safe to allocate such an object in one thread, and operate or free it
+from any other, even if locking is used to ensure these threads don't operate on it at the very same time.</para>
+
+<para id="safe">All functions listed here are thread-safe and may be called in parallel from multiple threads.</para>
+
+</refsect1>