mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
protocol-native: attempt to remove socket
After we grab the lockfile we should remove the socket when it exists so that we can bind again. This should solve startup problems after a crash, which left the socket around and caused bind failures.
This commit is contained in:
parent
9a202272f2
commit
312864d9e9
1 changed files with 13 additions and 0 deletions
|
|
@ -480,10 +480,23 @@ static int add_socket(struct pw_protocol *protocol, struct server *s)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
|
struct stat socket_stat;
|
||||||
|
|
||||||
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;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
if (stat(s->addr.sun_path, &socket_stat) < 0) {
|
||||||
|
if (errno != ENOENT) {
|
||||||
|
res = -errno;
|
||||||
|
pw_log_error("server %p: stat %s failed with error: %m",
|
||||||
|
s, s->addr.sun_path);
|
||||||
|
goto error_close;
|
||||||
|
}
|
||||||
|
} else if (socket_stat.st_mode & S_IWUSR || socket_stat.st_mode & S_IWGRP) {
|
||||||
|
pw_log_warn("removing stale socket");
|
||||||
|
unlink(s->addr.sun_path);
|
||||||
|
}
|
||||||
|
|
||||||
size = offsetof(struct sockaddr_un, sun_path) + strlen(s->addr.sun_path);
|
size = offsetof(struct sockaddr_un, sun_path) + strlen(s->addr.sun_path);
|
||||||
if (bind(fd, (struct sockaddr *) &s->addr, size) < 0) {
|
if (bind(fd, (struct sockaddr *) &s->addr, size) < 0) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue