[pulseaudio-commits] [Git][pulseaudio/pulseaudio][master] 3 commits: win32: Fix minimum Windows version for inet_{ntop, pton}

PulseAudio Marge Bot (@pulseaudio-merge-bot) gitlab at gitlab.freedesktop.org
Wed Jun 16 09:09:00 UTC 2021



PulseAudio Marge Bot pushed to branch master at PulseAudio / pulseaudio


Commits:
ac8e7860 by Patrick Gaskin at 2021-06-16T09:05:58+00:00
win32: Fix minimum Windows version for inet_{ntop,pton}

https://docs.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-inet_ntop#requirements

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/546>

- - - - -
a01cce72 by Patrick Gaskin at 2021-06-16T09:05:58+00:00
win32: Fix environment variables set with pa_{unset,set}_env not taking effect

SetEnvironmentVariable is not visible to getenv.

See https://github.com/curl/curl/issues/4774.
See https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/getenv-wgetenv.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/546>

- - - - -
6222f610 by Patrick Gaskin at 2021-06-16T09:05:58+00:00
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>

- - - - -


6 changed files:

- src/daemon/meson.build
- src/pulsecore/arpa-inet.c
- src/pulsecore/arpa-inet.h
- src/pulsecore/core-util.c
- src/pulsecore/parseaddr.c
- src/pulsecore/socket-util.c


Changes:

=====================================
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'))
 


=====================================
src/pulsecore/arpa-inet.c
=====================================
@@ -21,7 +21,7 @@
 #include <config.h>
 #endif
 
-#if !defined(HAVE_ARPA_INET_H) && defined(OS_IS_WIN32) && (_WIN32_WINNT <= 0x0600)
+#if !defined(HAVE_ARPA_INET_H) && defined(OS_IS_WIN32) && (_WIN32_WINNT < 0x0600)
 
 #include <errno.h>
 


=====================================
src/pulsecore/arpa-inet.h
=====================================
@@ -12,7 +12,7 @@
 
 #include <pulsecore/socket.h>
 
-#if (_WIN32_WINNT <= 0x0600)
+#if (_WIN32_WINNT < 0x0600)
 
 const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt);
 


=====================================
src/pulsecore/core-util.c
=====================================
@@ -3005,7 +3005,16 @@ void pa_set_env(const char *key, const char *value) {
     /* This is not thread-safe */
 
 #ifdef OS_IS_WIN32
-    SetEnvironmentVariable(key, value);
+    int kl = strlen(key);
+    int vl = strlen(value);
+    char *tmp = pa_xmalloc(kl+vl+2);
+    memcpy(tmp, key, kl);
+    memcpy(tmp+kl+1, value, vl);
+    tmp[kl] = '=';
+    tmp[kl+1+vl] = '\0';
+    putenv(tmp);
+    /* Even though it should be safe to free it on Windows, we don't want to
+     * rely on undocumented behaviour. */
 #else
     setenv(key, value, 1);
 #endif
@@ -3017,7 +3026,14 @@ void pa_unset_env(const char *key) {
     /* This is not thread-safe */
 
 #ifdef OS_IS_WIN32
-    SetEnvironmentVariable(key, NULL);
+    int kl = strlen(key);
+    char *tmp = pa_xmalloc(kl+2);
+    memcpy(tmp, key, kl);
+    tmp[kl] = '=';
+    tmp[kl+1] = '\0';
+    putenv(tmp);
+    /* Even though it should be safe to free it on Windows, we don't want to
+     * rely on undocumented behaviour. */
 #else
     unsetenv(key);
 #endif


=====================================
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;


=====================================
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



View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/compare/9d273178738836d936a67498997b027ce0c72a72...6222f610e8ec4685153bd51eb3e34e5bc228ed2d

-- 
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/compare/9d273178738836d936a67498997b027ce0c72a72...6222f610e8ec4685153bd51eb3e34e5bc228ed2d
You're receiving this email because of your account on gitlab.freedesktop.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-commits/attachments/20210616/4d8d4258/attachment-0001.htm>


More information about the pulseaudio-commits mailing list