mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
pulse-server: improve stale socket detection
Only declare stale when ECONNREFUSED and not socket activated.
This commit is contained in:
parent
6e2ab9973b
commit
593c183166
2 changed files with 30 additions and 11 deletions
|
|
@ -67,10 +67,10 @@ pipewire_module_link_factory = shared_library('pipewire-module-link-factory',
|
|||
dependencies : [mathlib, dl_lib, pipewire_dep],
|
||||
)
|
||||
|
||||
pipewire_module_protocol_native_deps = [mathlib, dl_lib, pipewire_dep]
|
||||
pipewire_module_protocol_deps = [mathlib, dl_lib, pipewire_dep]
|
||||
|
||||
if get_option('systemd')
|
||||
pipewire_module_protocol_native_deps += systemd_dep
|
||||
pipewire_module_protocol_deps += systemd_dep
|
||||
endif
|
||||
|
||||
pipewire_module_protocol_native = shared_library('pipewire-module-protocol-native',
|
||||
|
|
@ -85,7 +85,7 @@ pipewire_module_protocol_native = shared_library('pipewire-module-protocol-nativ
|
|||
install : true,
|
||||
install_dir : modules_install_dir,
|
||||
install_rpath: modules_install_dir,
|
||||
dependencies : pipewire_module_protocol_native_deps,
|
||||
dependencies : pipewire_module_protocol_deps,
|
||||
)
|
||||
|
||||
pipewire_module_protocol_pulse = shared_library('pipewire-module-protocol-pulse',
|
||||
|
|
@ -97,7 +97,7 @@ pipewire_module_protocol_pulse = shared_library('pipewire-module-protocol-pulse'
|
|||
install : true,
|
||||
install_dir : modules_install_dir,
|
||||
install_rpath: modules_install_dir,
|
||||
dependencies : [mathlib, dl_lib, pipewire_dep],
|
||||
dependencies : pipewire_module_protocol_deps,
|
||||
)
|
||||
|
||||
pipewire_module_client_node = shared_library('pipewire-module-client-node',
|
||||
|
|
|
|||
|
|
@ -44,6 +44,10 @@
|
|||
#include <pwd.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYSTEMD
|
||||
#include <systemd/sd-daemon.h>
|
||||
#endif
|
||||
|
||||
#include <pipewire/log.h>
|
||||
|
||||
#define spa_debug pw_log_debug
|
||||
|
|
@ -4390,16 +4394,31 @@ get_server_name(struct pw_context *context)
|
|||
return name;
|
||||
}
|
||||
|
||||
static int check_connect(struct server *server, int fd)
|
||||
static bool is_stale_socket(struct server *server, int fd)
|
||||
{
|
||||
int res;
|
||||
socklen_t size;
|
||||
|
||||
size = offsetof(struct sockaddr_un, sun_path) + strlen(server->addr.sun_path);
|
||||
if ((res = connect(fd, (struct sockaddr *)&server->addr, size)) < 0)
|
||||
return -errno;
|
||||
#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) {
|
||||
/* socket activated sockets are not stale */
|
||||
pw_log_info(NAME" %p: Found socket activation socket for '%s'",
|
||||
server, server->addr.sun_path);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
size = offsetof(struct sockaddr_un, sun_path) + strlen(server->addr.sun_path);
|
||||
if (connect(fd, (struct sockaddr *)&server->addr, size) < 0) {
|
||||
if (errno == ECONNREFUSED)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static int make_local_socket(struct server *server, char *name)
|
||||
|
|
@ -4437,7 +4456,7 @@ static int make_local_socket(struct server *server, char *name)
|
|||
}
|
||||
} else if (socket_stat.st_mode & S_IWUSR || socket_stat.st_mode & S_IWGRP) {
|
||||
/* socket is there, check if we can connect */
|
||||
if ((res = check_connect(server, fd)) < 0) {
|
||||
if (is_stale_socket(server, fd)) {
|
||||
/* we can't connect, probably stale, remove it */
|
||||
pw_log_warn(NAME" %p: unlink stale socket %s: %s", server,
|
||||
server->addr.sun_path, spa_strerror(res));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue