mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
The prohibition to move libsystemd objects between threads was added in64a7ef8bc0('man: be more explicit about thread safety of sd_journal'). At the time, this was valid, because we were using the mempool for allocation and it apparently didn't handle access from different threads. Sadlly, the commit links to a bugzilla entry referenced in the commit is not publicly visible anymore, so the details are murky. But we stopped using the mempool ina5d8835c78('mempool: only enable mempool use when linked to libsystemd-shared.so'), with subsequent followup inb01f31954f('Turn mempool_enabled() into a weak symbol'). The restriction added in the man page is not necessary since then. The text in the man page was arguably incorrect in calling the code "thread-agnostic". If the code does not support being touched from threads at all and has global state to tied to the main thread, it is not "agnostic", but just doesn't support threads. (I'm looking into https://github.com/systemd/python-systemd/issues/143, and with the current scheme, the python-systemd module and all python code using libsystemd would be very hard to use. With the change to free-threaded python in python3.13, i.e. the replacement of single Global Interpreter Lock by locking on individual objects, this limitation would become even more constraining.)
24 lines
1.2 KiB
XML
24 lines
1.2 KiB
XML
<?xml version="1.0"?>
|
|
<!DOCTYPE refsect1 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-or-later -->
|
|
|
|
<refsect1>
|
|
<title/>
|
|
|
|
<para id="strict">All functions listed here are thread-agnostic and only a single thread may operate on a
|
|
given object at any given time. Different threads may access the same object at different times. Multiple
|
|
independent objects may be used from different threads in parallel.</para>
|
|
|
|
<para id="safe">All functions listed here are thread-safe and may be called in parallel from multiple threads.</para>
|
|
|
|
<para id='getenv'>The code described here uses
|
|
<citerefentry project='man-pages'><refentrytitle>getenv</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
|
which is declared to be not multi-thread-safe. This means that the code calling the functions described
|
|
here must not call
|
|
<citerefentry project='man-pages'><refentrytitle>setenv</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
|
from a parallel thread. It is recommended to only do calls to <function>setenv()</function>
|
|
from an early phase of the program when no other threads have been started.</para>
|
|
|
|
</refsect1>
|