summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Gaskin <patrick@pgaskin.net>2021-05-30 15:25:10 -0400
committerPulseAudio Marge Bot <pulseaudio-maintainers@lists.freedesktop.org>2021-06-16 09:05:58 +0000
commit6222f610e8ec4685153bd51eb3e34e5bc228ed2d (patch)
treec62bffea91f0d3fc54d3a7b02fdb6f57e31b269f
parenta01cce726f175f43ee4b2bb733ad3d54d0de8415 (diff)
downloadpulseaudio-6222f610e8ec4685153bd51eb3e34e5bc228ed2d.tar.gz
win32: Misc Unix socket fixes
* Make pa_parse_address recognize Unix socket addresses with Windows-style absolute paths. * Treat WASEINVAL as a stale socket. * Make HAVE_AF_UNIX in config templates recognize winsock2.h. Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/546>
-rw-r--r--src/daemon/meson.build2
-rw-r--r--src/pulsecore/parseaddr.c5
-rw-r--r--src/pulsecore/socket-util.c2
3 files changed, 7 insertions, 2 deletions
diff --git a/src/daemon/meson.build b/src/daemon/meson.build
index e19b29077..262e193b2 100644
--- a/src/daemon/meson.build
+++ b/src/daemon/meson.build
@@ -100,7 +100,7 @@ default_conf = configuration_data()
default_conf.merge_from(cdata)
default_conf.set('PA_BINARY', cdata.get_unquoted('PA_BINARY'))
default_conf.set('PA_SOEXT', cdata.get_unquoted('PA_SOEXT'))
-default_conf.set10('HAVE_AF_UNIX', cc.has_header('sys/un.h'))
+default_conf.set10('HAVE_AF_UNIX', cc.has_header('sys/un.h') ? true : cc.has_header('winsock2.h'))
default_conf.set10('OS_IS_WIN32', host_machine.system() == 'windows')
default_conf.set10('HAVE_MKFIFO', cc.has_function('mkfifo'))
diff --git a/src/pulsecore/parseaddr.c b/src/pulsecore/parseaddr.c
index b909f5280..c47544f76 100644
--- a/src/pulsecore/parseaddr.c
+++ b/src/pulsecore/parseaddr.c
@@ -105,8 +105,13 @@ int pa_parse_address(const char *name, pa_parsed_address *ret_p) {
} else
p = name;
+#ifndef OS_IS_WIN32
if (*p == '/')
ret_p->type = PA_PARSED_ADDRESS_UNIX;
+#else
+ if (strlen(p) >= 3 && p[1] == ':' && p[2] == '\\' && ((p[0] >= 'A' && p[0] <= 'Z') || (p[0] >= 'a' && p[0] <= 'z')))
+ ret_p->type = PA_PARSED_ADDRESS_UNIX;
+#endif
else if (pa_startswith(p, "unix:")) {
ret_p->type = PA_PARSED_ADDRESS_UNIX;
p += sizeof("unix:")-1;
diff --git a/src/pulsecore/socket-util.c b/src/pulsecore/socket-util.c
index 83d4c9c6c..f2c8c3c31 100644
--- a/src/pulsecore/socket-util.c
+++ b/src/pulsecore/socket-util.c
@@ -243,7 +243,7 @@ int pa_unix_socket_is_stale(const char *fn) {
if (errno == ECONNREFUSED)
ret = 1;
#else
- if (WSAGetLastError() == WSAECONNREFUSED)
+ if (WSAGetLastError() == WSAECONNREFUSED || WSAGetLastError() == WSAEINVAL)
ret = 1;
#endif
} else