mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-12-31 11:08:52 -05:00
socket-server: Add support for systemd socket activation.
This adds support to module-native-protocol-unix to take over already listening sockets passed in via socket activation (e.g. from systemd) Most of the code is isolated to socket-server but some cleanup code also had to be tweaked to ensure we do not overzealously close open fds.
This commit is contained in:
parent
fb1ca6f0c1
commit
467b4b9bee
5 changed files with 116 additions and 29 deletions
|
|
@ -52,6 +52,9 @@
|
|||
#ifdef HAVE_NETDB_H
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYSTEMD_DAEMON
|
||||
#include <systemd/sd-daemon.h>
|
||||
#endif
|
||||
|
||||
#include <pulsecore/core-error.h>
|
||||
#include <pulsecore/core-util.h>
|
||||
|
|
@ -255,6 +258,21 @@ int pa_unix_socket_remove_stale(const char *fn) {
|
|||
|
||||
pa_assert(fn);
|
||||
|
||||
#ifdef HAVE_SYSTEMD_DAEMON
|
||||
{
|
||||
int n = sd_listen_fds(0);
|
||||
if (n > 0) {
|
||||
for (int i = 0; i < n; ++i) {
|
||||
if (sd_is_socket_unix(SD_LISTEN_FDS_START + i, SOCK_STREAM, 1, fn, 0) > 0) {
|
||||
/* This is a socket activated socket, therefore do not consider
|
||||
* it stale. */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((r = pa_unix_socket_is_stale(fn)) < 0)
|
||||
return errno != ENOENT ? -1 : 0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue