doc: cross link sd_listen_fd() docs a bit

Let's make sure the sd_listen_fd() docs are really found from the
.socket file documentation as well as the FileDescriptorStoreMax=
documentation.

Let's also emphasize that that's where the order in which the fds are
passed are documented.

Fixes: #16647
This commit is contained in:
Lennart Poettering 2020-08-31 23:41:30 +02:00 committed by Zbigniew Jędrzejewski-Szmek
parent 0419dae715
commit df2f58176d
3 changed files with 35 additions and 38 deletions

View file

@ -54,24 +54,19 @@
(i.e. <constant>SD_LISTEN_FDS_START</constant>), the remaining (i.e. <constant>SD_LISTEN_FDS_START</constant>), the remaining
descriptors follow at 4, 5, 6, …, if any.</para> descriptors follow at 4, 5, 6, …, if any.</para>
<para>If a daemon receives more than one file descriptor, they <para>If a daemon receives more than one file descriptor, they will be passed in the same order as
will be passed in the same order as configured in the systemd configured in the systemd socket unit file (see
socket unit file (see <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry> for
<citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry> details) — if there's only one such file (see below). Nonetheless, it is recommended to verify the
for details). Nonetheless, it is recommended to verify the correct correct socket types before using them. To simplify this checking, the functions
socket types before using them. To simplify this checking, the
functions
<citerefentry><refentrytitle>sd_is_fifo</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>sd_is_fifo</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_is_socket</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>sd_is_socket</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_is_socket_inet</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>sd_is_socket_inet</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_is_socket_unix</refentrytitle><manvolnum>3</manvolnum></citerefentry> <citerefentry><refentrytitle>sd_is_socket_unix</refentrytitle><manvolnum>3</manvolnum></citerefentry> are
are provided. In order to maximize flexibility, it is recommended provided. In order to maximize flexibility, it is recommended to make these checks as loose as possible
to make these checks as loose as possible without allowing without allowing incorrect setups. i.e. often, the actual port number a socket is bound to matters little
incorrect setups. i.e. often, the actual port number a socket is for the service to work, hence it should not be verified. On the other hand, whether a socket is a
bound to matters little for the service to work, hence it should datagram or stream socket matters a lot for the most common program logics and should be checked.</para>
not be verified. On the other hand, whether a socket is a datagram
or stream socket matters a lot for the most common program logics
and should be checked.</para>
<para>This function call will set the FD_CLOEXEC flag for all <para>This function call will set the FD_CLOEXEC flag for all
passed file descriptors to avoid further inheritance to children passed file descriptors to avoid further inheritance to children

View file

@ -1028,20 +1028,24 @@
<varlistentry> <varlistentry>
<term><varname>FileDescriptorStoreMax=</varname></term> <term><varname>FileDescriptorStoreMax=</varname></term>
<listitem><para>Configure how many file descriptors may be stored in the service manager for the service using <listitem><para>Configure how many file descriptors may be stored in the service manager for the
service using
<citerefentry><refentrytitle>sd_pid_notify_with_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>'s <citerefentry><refentrytitle>sd_pid_notify_with_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>'s
<literal>FDSTORE=1</literal> messages. This is useful for implementing services that can restart after an <literal>FDSTORE=1</literal> messages. This is useful for implementing services that can restart
explicit request or a crash without losing state. Any open sockets and other file descriptors which should not after an explicit request or a crash without losing state. Any open sockets and other file
be closed during the restart may be stored this way. Application state can either be serialized to a file in descriptors which should not be closed during the restart may be stored this way. Application state
<filename>/run</filename>, or better, stored in a can either be serialized to a file in <filename>/run</filename>, or better, stored in a
<citerefentry><refentrytitle>memfd_create</refentrytitle><manvolnum>2</manvolnum></citerefentry> memory file <citerefentry><refentrytitle>memfd_create</refentrytitle><manvolnum>2</manvolnum></citerefentry>
descriptor. Defaults to 0, i.e. no file descriptors may be stored in the service manager. All file descriptors memory file descriptor. Defaults to 0, i.e. no file descriptors may be stored in the service
passed to the service manager from a specific service are passed back to the service's main process on the next manager. All file descriptors passed to the service manager from a specific service are passed back
service restart. Any file descriptors passed to the service manager are automatically closed when to the service's main process on the next service restart (see
<constant>POLLHUP</constant> or <constant>POLLERR</constant> is seen on them, or when the service is fully <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry> for
stopped and no job is queued or being executed for it. If this option is used, <varname>NotifyAccess=</varname> details about the precise protocol used and the order in which the file descriptors are passed). Any
(see above) should be set to open access to the notification socket provided by systemd. If file descriptors passed to the service manager are automatically closed when
<varname>NotifyAccess=</varname> is not set, it will be implicitly set to <constant>POLLHUP</constant> or <constant>POLLERR</constant> is seen on them, or when the service is
fully stopped and no job is queued or being executed for it. If this option is used,
<varname>NotifyAccess=</varname> (see above) should be set to open access to the notification socket
provided by systemd. If <varname>NotifyAccess=</varname> is not set, it will be implicitly set to
<option>main</option>.</para></listitem> <option>main</option>.</para></listitem>
</varlistentry> </varlistentry>

View file

@ -81,16 +81,14 @@
services, as well as parallelized starting of services. See the services, as well as parallelized starting of services. See the
blog stories linked at the end for an introduction.</para> blog stories linked at the end for an introduction.</para>
<para>Note that the daemon software configured for socket <para>Note that the daemon software configured for socket activation with socket units needs to be able
activation with socket units needs to be able to accept sockets to accept sockets from systemd, either via systemd's native socket passing interface (see
from systemd, either via systemd's native socket passing interface <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry> for
(see details about the precise protocol used and the order in which the file descriptors are passed) or via
<citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry> traditional <citerefentry
for details) or via the traditional project='freebsd'><refentrytitle>inetd</refentrytitle><manvolnum>8</manvolnum></citerefentry>-style
<citerefentry project='freebsd'><refentrytitle>inetd</refentrytitle><manvolnum>8</manvolnum></citerefentry>-style socket passing (i.e. sockets passed in via standard input and output, using
socket passing (i.e. sockets passed in via standard input and <varname>StandardInput=socket</varname> in the service file).</para>
output, using <varname>StandardInput=socket</varname> in the
service file).</para>
<para>All network sockets allocated through <filename>.socket</filename> units are allocated in the host's network <para>All network sockets allocated through <filename>.socket</filename> units are allocated in the host's network
namespace (see <citerefentry namespace (see <citerefentry