]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
build: unix socket tidy-ups
authorViktor Szakats <commit@vsz.me>
Tue, 16 Dec 2025 00:37:10 +0000 (01:37 +0100)
committerViktor Szakats <commit@vsz.me>
Tue, 16 Dec 2025 12:41:25 +0000 (13:41 +0100)
- lib: delete two unused `<sys/un.h>` includes.

- lib: drop interim macro `WIN32_SOCKADDR_UN`.
  Follow-up to 0fe9018e1a1af0d906dfe934efe2f2b1ba48f060 #7737
  Also fixing a potential issue of leaving unix socket support disabled
  if any header would include Windows' `afunix.h`, and define
  `UNIX_PATH_MAX` on its own.

- connect: honor unix socket disable option.

- connect: simplify unix socket PP condition.
  `USE_UNIX_SOCKETS` already means the necessary header/type are
  available, guaranteed by configure. `AF_UNIX` is already used
  elsewhere in the code without explicit checks.

- curl_setup.h: document availability of `afunix.h` on Windows more.
  It requires mingw-w64 10+ or MS SDK 10.17763.0 VS2017 15.8+.

- curl_setup.h: use `afunix.h` with mingw-w64 v10+ to start avoiding
  the local workaround if possible.

- GHA/windows: test disable unix socket option on Windows.

Ref: https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/

Closes #19989

.github/workflows/windows.yml
lib/cf-ip-happy.c
lib/cf-socket.c
lib/connect.c
lib/curl_setup.h

index 3260e0c5b01b40d3322c99ee109b9d9e4ae77f85..700913e092f84d294b551dad04565c01ea9055f6 100644 (file)
@@ -429,7 +429,7 @@ jobs:
             env: 'x86_64'
             ver: '15.1.0'
             url: 'https://github.com/skeeto/w64devkit/releases/download/v2.2.0/w64devkit-x64-2.2.0.7z.exe'
-            config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=OFF -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=OFF'
+            config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=OFF -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=OFF -DENABLE_UNIX_SOCKETS=OFF'
             type: 'Release'
           - name: 'schannel'  # mingw-w64 10.0
             sys: 'mingw64'
index 029746354ccb2c6272fe71cfc5d77e17ca3061d7..d6501d0079bbc5c852aa26a61f4deb30ae2809cc 100644 (file)
@@ -27,9 +27,6 @@
 #ifdef HAVE_NETINET_IN_H
 #include <netinet/in.h> /* <netinet/tcp.h> may need it */
 #endif
-#ifdef HAVE_SYS_UN_H
-#include <sys/un.h> /* for sockaddr_un */
-#endif
 #ifdef HAVE_LINUX_TCP_H
 #include <linux/tcp.h>
 #elif defined(HAVE_NETINET_TCP_H)
index f9a883b0c3a6a9c61b74be33d718131731377551..3e22c4ad26b7e436dfc1ec256de9526096d57723 100644 (file)
@@ -27,9 +27,6 @@
 #ifdef HAVE_NETINET_IN_H
 #include <netinet/in.h> /* <netinet/tcp.h> may need it */
 #endif
-#ifdef HAVE_SYS_UN_H
-#include <sys/un.h> /* for sockaddr_un */
-#endif
 #ifdef HAVE_LINUX_TCP_H
 #include <linux/tcp.h>
 #elif defined(HAVE_NETINET_TCP_H)
index f1700e5b96c3871d1b5555010352a32efa046d97..42d5cd7a3fc48b1434ccd65f20def5020e3645cb 100644 (file)
@@ -218,7 +218,7 @@ bool Curl_addr2string(struct sockaddr *sa, curl_socklen_t salen,
 #ifdef USE_IPV6
   struct sockaddr_in6 *si6 = NULL;
 #endif
-#if (defined(HAVE_SYS_UN_H) || defined(WIN32_SOCKADDR_UN)) && defined(AF_UNIX)
+#ifdef USE_UNIX_SOCKETS
   struct sockaddr_un *su = NULL;
 #else
   (void)salen;
@@ -241,7 +241,7 @@ bool Curl_addr2string(struct sockaddr *sa, curl_socklen_t salen,
     }
     break;
 #endif
-#if (defined(HAVE_SYS_UN_H) || defined(WIN32_SOCKADDR_UN)) && defined(AF_UNIX)
+#ifdef USE_UNIX_SOCKETS
   case AF_UNIX:
     if(salen > (curl_socklen_t)sizeof(CURL_SA_FAMILY_T)) {
       su = (struct sockaddr_un *)sa;
index a7dc41493c0f8aafc4d9cc1540c440959e65cff9..d34b8a7407ceb7155668f45af799f12dd175a1d2 100644 (file)
@@ -1148,17 +1148,17 @@ int getpwuid_r(uid_t uid, struct passwd *pwd, char *buf,
 #endif
 
 #if defined(USE_UNIX_SOCKETS) && defined(_WIN32)
-#  ifndef UNIX_PATH_MAX
-     /* Replicating logic present in afunix.h
-        (distributed with newer Windows 10 SDK versions only) */
-#    define UNIX_PATH_MAX 108
-     /* !checksrc! disable TYPEDEFSTRUCT 1 */
-     typedef struct sockaddr_un {
-       CURL_SA_FAMILY_T sun_family;
-       char sun_path[UNIX_PATH_MAX];
-     } SOCKADDR_UN, *PSOCKADDR_UN;
-#    define WIN32_SOCKADDR_UN
-#  endif
+/* Offered by mingw-w64 v10+. MS SDK 10.17763/~VS2017+. */
+#if defined(__MINGW32__) && (__MINGW64_VERSION_MAJOR >= 10)
+#  include <afunix.h>
+#elif !defined(UNIX_PATH_MAX) /* Replicate logic present in afunix.h */
+#  define UNIX_PATH_MAX 108
+/* !checksrc! disable TYPEDEFSTRUCT 1 */
+typedef struct sockaddr_un {
+  CURL_SA_FAMILY_T sun_family;
+  char sun_path[UNIX_PATH_MAX];
+} SOCKADDR_UN, *PSOCKADDR_UN;
+#endif
 #endif
 
 #ifdef USE_OPENSSL