mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-19 08:57:14 -05:00
pulse-server: add socket activation
This commit is contained in:
parent
346e35eed5
commit
4eb3cc37ea
1 changed files with 22 additions and 2 deletions
|
|
@ -188,8 +188,9 @@ struct server {
|
||||||
uint32_t type;
|
uint32_t type;
|
||||||
struct sockaddr_un addr;
|
struct sockaddr_un addr;
|
||||||
|
|
||||||
struct spa_source *source;
|
struct spa_source *source;
|
||||||
struct spa_list clients;
|
struct spa_list clients;
|
||||||
|
unsigned int activated:1;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct impl {
|
struct impl {
|
||||||
|
|
@ -4390,7 +4391,7 @@ static void server_free(struct server *server)
|
||||||
client_free(c);
|
client_free(c);
|
||||||
if (server->source)
|
if (server->source)
|
||||||
pw_loop_destroy_source(impl->loop, server->source);
|
pw_loop_destroy_source(impl->loop, server->source);
|
||||||
if (server->type == SERVER_TYPE_UNIX)
|
if (server->type == SERVER_TYPE_UNIX && !server->activated)
|
||||||
unlink(server->addr.sun_path);
|
unlink(server->addr.sun_path);
|
||||||
free(server);
|
free(server);
|
||||||
}
|
}
|
||||||
|
|
@ -4443,6 +4444,7 @@ static int make_local_socket(struct server *server, char *name)
|
||||||
socklen_t size;
|
socklen_t size;
|
||||||
int name_size, fd, res;
|
int name_size, fd, res;
|
||||||
struct stat socket_stat;
|
struct stat socket_stat;
|
||||||
|
bool activated = false;
|
||||||
|
|
||||||
if ((res = get_runtime_dir(runtime_dir, sizeof(runtime_dir), "pulse")) < 0)
|
if ((res = get_runtime_dir(runtime_dir, sizeof(runtime_dir), "pulse")) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
@ -4459,6 +4461,22 @@ static int make_local_socket(struct server *server, char *name)
|
||||||
}
|
}
|
||||||
size = offsetof(struct sockaddr_un, sun_path) + strlen(server->addr.sun_path);
|
size = offsetof(struct sockaddr_un, sun_path) + strlen(server->addr.sun_path);
|
||||||
|
|
||||||
|
#ifdef HAVE_SYSTEMD
|
||||||
|
{
|
||||||
|
int i, n = sd_listen_fds(0);
|
||||||
|
for (i = 0; i < n; ++i) {
|
||||||
|
if (sd_is_socket_unix(SD_LISTEN_FDS_START + i, SOCK_STREAM,
|
||||||
|
1, server->addr.sun_path, 0) > 0) {
|
||||||
|
fd = SD_LISTEN_FDS_START + i;
|
||||||
|
activated = true;
|
||||||
|
pw_log_info("server %p: Found socket activation socket for '%s'",
|
||||||
|
server, server->addr.sun_path);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if ((fd = socket(PF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0)) < 0) {
|
if ((fd = socket(PF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0)) < 0) {
|
||||||
res = -errno;
|
res = -errno;
|
||||||
pw_log_info(NAME" %p: socket() failed: %m", server);
|
pw_log_info(NAME" %p: socket() failed: %m", server);
|
||||||
|
|
@ -4496,6 +4514,8 @@ static int make_local_socket(struct server *server, char *name)
|
||||||
goto error_close;
|
goto error_close;
|
||||||
}
|
}
|
||||||
pw_log_info(NAME" listening on unix:%s", server->addr.sun_path);
|
pw_log_info(NAME" listening on unix:%s", server->addr.sun_path);
|
||||||
|
done:
|
||||||
|
server->activated = activated;
|
||||||
server->type = SERVER_TYPE_UNIX;
|
server->type = SERVER_TYPE_UNIX;
|
||||||
|
|
||||||
return fd;
|
return fd;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue