git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/1] Drop Windows XP-specific code to support IPv6
@ 2019-02-27  8:43 Johannes Schindelin via GitGitGadget
  2019-02-27  8:43 ` [PATCH 1/1] mingw: remove obsolete IPv6-related code Tanushree Tumane via GitGitGadget
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2019-02-27  8:43 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

We no longer support Windows XP, and can therefore rely on API functions
that are available since Windows Vista.

Tanushree Tumane (1):
  mingw: remove obsolete IPv6-related code

 compat/mingw.c | 178 +------------------------------------------------
 compat/mingw.h |   8 ---
 2 files changed, 3 insertions(+), 183 deletions(-)


base-commit: 8104ec994ea3849a968b4667d072fedd1e688642
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-144%2Fdscho%2Fremove-ipv6-fallback-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-144/dscho/remove-ipv6-fallback-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/144
-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/1] mingw: remove obsolete IPv6-related code
  2019-02-27  8:43 [PATCH 0/1] Drop Windows XP-specific code to support IPv6 Johannes Schindelin via GitGitGadget
@ 2019-02-27  8:43 ` Tanushree Tumane via GitGitGadget
  2019-04-29 22:58   ` Johannes Schindelin
  0 siblings, 1 reply; 3+ messages in thread
From: Tanushree Tumane via GitGitGadget @ 2019-02-27  8:43 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Tanushree Tumane

From: Tanushree Tumane <tanushreetumane@gmail.com>

To support IPv6, Git provided fall back functions for Windows versions
that did not support IPv6. However, as Git dropped support for Windows
XP and prior, those functions are not needed anymore.

Remove those fallbacks by reverting fe3b2b7b827c (Enable support for
IPv6 on MinGW, 2009-11-24) and using the functions directly (without
'ipv6_' prefix).

Signed-off-by: Tanushree Tumane <tanushreetumane@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 compat/mingw.c | 178 +------------------------------------------------
 compat/mingw.h |   8 ---
 2 files changed, 3 insertions(+), 183 deletions(-)

diff --git a/compat/mingw.c b/compat/mingw.c
index 8141f77189..80b6b288a1 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -1705,142 +1705,10 @@ int mingw_putenv(const char *namevalue)
 	return result ? 0 : -1;
 }
 
-/*
- * Note, this isn't a complete replacement for getaddrinfo. It assumes
- * that service contains a numerical port, or that it is null. It
- * does a simple search using gethostbyname, and returns one IPv4 host
- * if one was found.
- */
-static int WSAAPI getaddrinfo_stub(const char *node, const char *service,
-				   const struct addrinfo *hints,
-				   struct addrinfo **res)
-{
-	struct hostent *h = NULL;
-	struct addrinfo *ai;
-	struct sockaddr_in *sin;
-
-	if (node) {
-		h = gethostbyname(node);
-		if (!h)
-			return WSAGetLastError();
-	}
-
-	ai = xmalloc(sizeof(struct addrinfo));
-	*res = ai;
-	ai->ai_flags = 0;
-	ai->ai_family = AF_INET;
-	ai->ai_socktype = hints ? hints->ai_socktype : 0;
-	switch (ai->ai_socktype) {
-	case SOCK_STREAM:
-		ai->ai_protocol = IPPROTO_TCP;
-		break;
-	case SOCK_DGRAM:
-		ai->ai_protocol = IPPROTO_UDP;
-		break;
-	default:
-		ai->ai_protocol = 0;
-		break;
-	}
-	ai->ai_addrlen = sizeof(struct sockaddr_in);
-	if (hints && (hints->ai_flags & AI_CANONNAME))
-		ai->ai_canonname = h ? xstrdup(h->h_name) : NULL;
-	else
-		ai->ai_canonname = NULL;
-
-	sin = xcalloc(1, ai->ai_addrlen);
-	sin->sin_family = AF_INET;
-	/* Note: getaddrinfo is supposed to allow service to be a string,
-	 * which should be looked up using getservbyname. This is
-	 * currently not implemented */
-	if (service)
-		sin->sin_port = htons(atoi(service));
-	if (h)
-		sin->sin_addr = *(struct in_addr *)h->h_addr;
-	else if (hints && (hints->ai_flags & AI_PASSIVE))
-		sin->sin_addr.s_addr = INADDR_ANY;
-	else
-		sin->sin_addr.s_addr = INADDR_LOOPBACK;
-	ai->ai_addr = (struct sockaddr *)sin;
-	ai->ai_next = NULL;
-	return 0;
-}
-
-static void WSAAPI freeaddrinfo_stub(struct addrinfo *res)
-{
-	free(res->ai_canonname);
-	free(res->ai_addr);
-	free(res);
-}
-
-static int WSAAPI getnameinfo_stub(const struct sockaddr *sa, socklen_t salen,
-				   char *host, DWORD hostlen,
-				   char *serv, DWORD servlen, int flags)
-{
-	const struct sockaddr_in *sin = (const struct sockaddr_in *)sa;
-	if (sa->sa_family != AF_INET)
-		return EAI_FAMILY;
-	if (!host && !serv)
-		return EAI_NONAME;
-
-	if (host && hostlen > 0) {
-		struct hostent *ent = NULL;
-		if (!(flags & NI_NUMERICHOST))
-			ent = gethostbyaddr((const char *)&sin->sin_addr,
-					    sizeof(sin->sin_addr), AF_INET);
-
-		if (ent)
-			snprintf(host, hostlen, "%s", ent->h_name);
-		else if (flags & NI_NAMEREQD)
-			return EAI_NONAME;
-		else
-			snprintf(host, hostlen, "%s", inet_ntoa(sin->sin_addr));
-	}
-
-	if (serv && servlen > 0) {
-		struct servent *ent = NULL;
-		if (!(flags & NI_NUMERICSERV))
-			ent = getservbyport(sin->sin_port,
-					    flags & NI_DGRAM ? "udp" : "tcp");
-
-		if (ent)
-			snprintf(serv, servlen, "%s", ent->s_name);
-		else
-			snprintf(serv, servlen, "%d", ntohs(sin->sin_port));
-	}
-
-	return 0;
-}
-
-static HMODULE ipv6_dll = NULL;
-static void (WSAAPI *ipv6_freeaddrinfo)(struct addrinfo *res);
-static int (WSAAPI *ipv6_getaddrinfo)(const char *node, const char *service,
-				      const struct addrinfo *hints,
-				      struct addrinfo **res);
-static int (WSAAPI *ipv6_getnameinfo)(const struct sockaddr *sa, socklen_t salen,
-				      char *host, DWORD hostlen,
-				      char *serv, DWORD servlen, int flags);
-/*
- * gai_strerror is an inline function in the ws2tcpip.h header, so we
- * don't need to try to load that one dynamically.
- */
-
-static void socket_cleanup(void)
-{
-	WSACleanup();
-	if (ipv6_dll)
-		FreeLibrary(ipv6_dll);
-	ipv6_dll = NULL;
-	ipv6_freeaddrinfo = freeaddrinfo_stub;
-	ipv6_getaddrinfo = getaddrinfo_stub;
-	ipv6_getnameinfo = getnameinfo_stub;
-}
-
 static void ensure_socket_initialization(void)
 {
 	WSADATA wsa;
 	static int initialized = 0;
-	const char *libraries[] = { "ws2_32.dll", "wship6.dll", NULL };
-	const char **name;
 
 	if (initialized)
 		return;
@@ -1849,35 +1717,7 @@ static void ensure_socket_initialization(void)
 		die("unable to initialize winsock subsystem, error %d",
 			WSAGetLastError());
 
-	for (name = libraries; *name; name++) {
-		ipv6_dll = LoadLibraryExA(*name, NULL,
-					  LOAD_LIBRARY_SEARCH_SYSTEM32);
-		if (!ipv6_dll)
-			continue;
-
-		ipv6_freeaddrinfo = (void (WSAAPI *)(struct addrinfo *))
-			GetProcAddress(ipv6_dll, "freeaddrinfo");
-		ipv6_getaddrinfo = (int (WSAAPI *)(const char *, const char *,
-						   const struct addrinfo *,
-						   struct addrinfo **))
-			GetProcAddress(ipv6_dll, "getaddrinfo");
-		ipv6_getnameinfo = (int (WSAAPI *)(const struct sockaddr *,
-						   socklen_t, char *, DWORD,
-						   char *, DWORD, int))
-			GetProcAddress(ipv6_dll, "getnameinfo");
-		if (!ipv6_freeaddrinfo || !ipv6_getaddrinfo || !ipv6_getnameinfo) {
-			FreeLibrary(ipv6_dll);
-			ipv6_dll = NULL;
-		} else
-			break;
-	}
-	if (!ipv6_freeaddrinfo || !ipv6_getaddrinfo || !ipv6_getnameinfo) {
-		ipv6_freeaddrinfo = freeaddrinfo_stub;
-		ipv6_getaddrinfo = getaddrinfo_stub;
-		ipv6_getnameinfo = getnameinfo_stub;
-	}
-
-	atexit(socket_cleanup);
+	atexit((void(*)(void)) WSACleanup);
 	initialized = 1;
 }
 
@@ -1895,24 +1735,12 @@ struct hostent *mingw_gethostbyname(const char *host)
 	return gethostbyname(host);
 }
 
-void mingw_freeaddrinfo(struct addrinfo *res)
-{
-	ipv6_freeaddrinfo(res);
-}
-
+#undef getaddrinfo
 int mingw_getaddrinfo(const char *node, const char *service,
 		      const struct addrinfo *hints, struct addrinfo **res)
 {
 	ensure_socket_initialization();
-	return ipv6_getaddrinfo(node, service, hints, res);
-}
-
-int mingw_getnameinfo(const struct sockaddr *sa, socklen_t salen,
-		      char *host, DWORD hostlen, char *serv, DWORD servlen,
-		      int flags)
-{
-	ensure_socket_initialization();
-	return ipv6_getnameinfo(sa, salen, host, hostlen, serv, servlen, flags);
+	return getaddrinfo(node, service, hints, res);
 }
 
 int mingw_socket(int domain, int type, int protocol)
diff --git a/compat/mingw.h b/compat/mingw.h
index 30d9fb3e36..e883b40c7d 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -296,18 +296,10 @@ int mingw_gethostname(char *host, int namelen);
 struct hostent *mingw_gethostbyname(const char *host);
 #define gethostbyname mingw_gethostbyname
 
-void mingw_freeaddrinfo(struct addrinfo *res);
-#define freeaddrinfo mingw_freeaddrinfo
-
 int mingw_getaddrinfo(const char *node, const char *service,
 		      const struct addrinfo *hints, struct addrinfo **res);
 #define getaddrinfo mingw_getaddrinfo
 
-int mingw_getnameinfo(const struct sockaddr *sa, socklen_t salen,
-		      char *host, DWORD hostlen, char *serv, DWORD servlen,
-		      int flags);
-#define getnameinfo mingw_getnameinfo
-
 int mingw_socket(int domain, int type, int protocol);
 #define socket mingw_socket
 
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] mingw: remove obsolete IPv6-related code
  2019-02-27  8:43 ` [PATCH 1/1] mingw: remove obsolete IPv6-related code Tanushree Tumane via GitGitGadget
@ 2019-04-29 22:58   ` Johannes Schindelin
  0 siblings, 0 replies; 3+ messages in thread
From: Johannes Schindelin @ 2019-04-29 22:58 UTC (permalink / raw)
  To: Tanushree Tumane via GitGitGadget; +Cc: git, Junio C Hamano, Tanushree Tumane

Hi Junio,

it looks as if this patch was not yet picked up? This is a
straight-forward code removal in favor of dropping Windows XP support
(which we officially did, quite some time ago).

Is there anything you want me to do to get this at least into `pu`?

Ciao,
Dscho

On Wed, 27 Feb 2019, Tanushree Tumane via GitGitGadget wrote:

> From: Tanushree Tumane <tanushreetumane@gmail.com>
>
> To support IPv6, Git provided fall back functions for Windows versions
> that did not support IPv6. However, as Git dropped support for Windows
> XP and prior, those functions are not needed anymore.
>
> Remove those fallbacks by reverting fe3b2b7b827c (Enable support for
> IPv6 on MinGW, 2009-11-24) and using the functions directly (without
> 'ipv6_' prefix).
>
> Signed-off-by: Tanushree Tumane <tanushreetumane@gmail.com>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>  compat/mingw.c | 178 +------------------------------------------------
>  compat/mingw.h |   8 ---
>  2 files changed, 3 insertions(+), 183 deletions(-)
>
> diff --git a/compat/mingw.c b/compat/mingw.c
> index 8141f77189..80b6b288a1 100644
> --- a/compat/mingw.c
> +++ b/compat/mingw.c
> @@ -1705,142 +1705,10 @@ int mingw_putenv(const char *namevalue)
>  	return result ? 0 : -1;
>  }
>
> -/*
> - * Note, this isn't a complete replacement for getaddrinfo. It assumes
> - * that service contains a numerical port, or that it is null. It
> - * does a simple search using gethostbyname, and returns one IPv4 host
> - * if one was found.
> - */
> -static int WSAAPI getaddrinfo_stub(const char *node, const char *service,
> -				   const struct addrinfo *hints,
> -				   struct addrinfo **res)
> -{
> -	struct hostent *h = NULL;
> -	struct addrinfo *ai;
> -	struct sockaddr_in *sin;
> -
> -	if (node) {
> -		h = gethostbyname(node);
> -		if (!h)
> -			return WSAGetLastError();
> -	}
> -
> -	ai = xmalloc(sizeof(struct addrinfo));
> -	*res = ai;
> -	ai->ai_flags = 0;
> -	ai->ai_family = AF_INET;
> -	ai->ai_socktype = hints ? hints->ai_socktype : 0;
> -	switch (ai->ai_socktype) {
> -	case SOCK_STREAM:
> -		ai->ai_protocol = IPPROTO_TCP;
> -		break;
> -	case SOCK_DGRAM:
> -		ai->ai_protocol = IPPROTO_UDP;
> -		break;
> -	default:
> -		ai->ai_protocol = 0;
> -		break;
> -	}
> -	ai->ai_addrlen = sizeof(struct sockaddr_in);
> -	if (hints && (hints->ai_flags & AI_CANONNAME))
> -		ai->ai_canonname = h ? xstrdup(h->h_name) : NULL;
> -	else
> -		ai->ai_canonname = NULL;
> -
> -	sin = xcalloc(1, ai->ai_addrlen);
> -	sin->sin_family = AF_INET;
> -	/* Note: getaddrinfo is supposed to allow service to be a string,
> -	 * which should be looked up using getservbyname. This is
> -	 * currently not implemented */
> -	if (service)
> -		sin->sin_port = htons(atoi(service));
> -	if (h)
> -		sin->sin_addr = *(struct in_addr *)h->h_addr;
> -	else if (hints && (hints->ai_flags & AI_PASSIVE))
> -		sin->sin_addr.s_addr = INADDR_ANY;
> -	else
> -		sin->sin_addr.s_addr = INADDR_LOOPBACK;
> -	ai->ai_addr = (struct sockaddr *)sin;
> -	ai->ai_next = NULL;
> -	return 0;
> -}
> -
> -static void WSAAPI freeaddrinfo_stub(struct addrinfo *res)
> -{
> -	free(res->ai_canonname);
> -	free(res->ai_addr);
> -	free(res);
> -}
> -
> -static int WSAAPI getnameinfo_stub(const struct sockaddr *sa, socklen_t salen,
> -				   char *host, DWORD hostlen,
> -				   char *serv, DWORD servlen, int flags)
> -{
> -	const struct sockaddr_in *sin = (const struct sockaddr_in *)sa;
> -	if (sa->sa_family != AF_INET)
> -		return EAI_FAMILY;
> -	if (!host && !serv)
> -		return EAI_NONAME;
> -
> -	if (host && hostlen > 0) {
> -		struct hostent *ent = NULL;
> -		if (!(flags & NI_NUMERICHOST))
> -			ent = gethostbyaddr((const char *)&sin->sin_addr,
> -					    sizeof(sin->sin_addr), AF_INET);
> -
> -		if (ent)
> -			snprintf(host, hostlen, "%s", ent->h_name);
> -		else if (flags & NI_NAMEREQD)
> -			return EAI_NONAME;
> -		else
> -			snprintf(host, hostlen, "%s", inet_ntoa(sin->sin_addr));
> -	}
> -
> -	if (serv && servlen > 0) {
> -		struct servent *ent = NULL;
> -		if (!(flags & NI_NUMERICSERV))
> -			ent = getservbyport(sin->sin_port,
> -					    flags & NI_DGRAM ? "udp" : "tcp");
> -
> -		if (ent)
> -			snprintf(serv, servlen, "%s", ent->s_name);
> -		else
> -			snprintf(serv, servlen, "%d", ntohs(sin->sin_port));
> -	}
> -
> -	return 0;
> -}
> -
> -static HMODULE ipv6_dll = NULL;
> -static void (WSAAPI *ipv6_freeaddrinfo)(struct addrinfo *res);
> -static int (WSAAPI *ipv6_getaddrinfo)(const char *node, const char *service,
> -				      const struct addrinfo *hints,
> -				      struct addrinfo **res);
> -static int (WSAAPI *ipv6_getnameinfo)(const struct sockaddr *sa, socklen_t salen,
> -				      char *host, DWORD hostlen,
> -				      char *serv, DWORD servlen, int flags);
> -/*
> - * gai_strerror is an inline function in the ws2tcpip.h header, so we
> - * don't need to try to load that one dynamically.
> - */
> -
> -static void socket_cleanup(void)
> -{
> -	WSACleanup();
> -	if (ipv6_dll)
> -		FreeLibrary(ipv6_dll);
> -	ipv6_dll = NULL;
> -	ipv6_freeaddrinfo = freeaddrinfo_stub;
> -	ipv6_getaddrinfo = getaddrinfo_stub;
> -	ipv6_getnameinfo = getnameinfo_stub;
> -}
> -
>  static void ensure_socket_initialization(void)
>  {
>  	WSADATA wsa;
>  	static int initialized = 0;
> -	const char *libraries[] = { "ws2_32.dll", "wship6.dll", NULL };
> -	const char **name;
>
>  	if (initialized)
>  		return;
> @@ -1849,35 +1717,7 @@ static void ensure_socket_initialization(void)
>  		die("unable to initialize winsock subsystem, error %d",
>  			WSAGetLastError());
>
> -	for (name = libraries; *name; name++) {
> -		ipv6_dll = LoadLibraryExA(*name, NULL,
> -					  LOAD_LIBRARY_SEARCH_SYSTEM32);
> -		if (!ipv6_dll)
> -			continue;
> -
> -		ipv6_freeaddrinfo = (void (WSAAPI *)(struct addrinfo *))
> -			GetProcAddress(ipv6_dll, "freeaddrinfo");
> -		ipv6_getaddrinfo = (int (WSAAPI *)(const char *, const char *,
> -						   const struct addrinfo *,
> -						   struct addrinfo **))
> -			GetProcAddress(ipv6_dll, "getaddrinfo");
> -		ipv6_getnameinfo = (int (WSAAPI *)(const struct sockaddr *,
> -						   socklen_t, char *, DWORD,
> -						   char *, DWORD, int))
> -			GetProcAddress(ipv6_dll, "getnameinfo");
> -		if (!ipv6_freeaddrinfo || !ipv6_getaddrinfo || !ipv6_getnameinfo) {
> -			FreeLibrary(ipv6_dll);
> -			ipv6_dll = NULL;
> -		} else
> -			break;
> -	}
> -	if (!ipv6_freeaddrinfo || !ipv6_getaddrinfo || !ipv6_getnameinfo) {
> -		ipv6_freeaddrinfo = freeaddrinfo_stub;
> -		ipv6_getaddrinfo = getaddrinfo_stub;
> -		ipv6_getnameinfo = getnameinfo_stub;
> -	}
> -
> -	atexit(socket_cleanup);
> +	atexit((void(*)(void)) WSACleanup);
>  	initialized = 1;
>  }
>
> @@ -1895,24 +1735,12 @@ struct hostent *mingw_gethostbyname(const char *host)
>  	return gethostbyname(host);
>  }
>
> -void mingw_freeaddrinfo(struct addrinfo *res)
> -{
> -	ipv6_freeaddrinfo(res);
> -}
> -
> +#undef getaddrinfo
>  int mingw_getaddrinfo(const char *node, const char *service,
>  		      const struct addrinfo *hints, struct addrinfo **res)
>  {
>  	ensure_socket_initialization();
> -	return ipv6_getaddrinfo(node, service, hints, res);
> -}
> -
> -int mingw_getnameinfo(const struct sockaddr *sa, socklen_t salen,
> -		      char *host, DWORD hostlen, char *serv, DWORD servlen,
> -		      int flags)
> -{
> -	ensure_socket_initialization();
> -	return ipv6_getnameinfo(sa, salen, host, hostlen, serv, servlen, flags);
> +	return getaddrinfo(node, service, hints, res);
>  }
>
>  int mingw_socket(int domain, int type, int protocol)
> diff --git a/compat/mingw.h b/compat/mingw.h
> index 30d9fb3e36..e883b40c7d 100644
> --- a/compat/mingw.h
> +++ b/compat/mingw.h
> @@ -296,18 +296,10 @@ int mingw_gethostname(char *host, int namelen);
>  struct hostent *mingw_gethostbyname(const char *host);
>  #define gethostbyname mingw_gethostbyname
>
> -void mingw_freeaddrinfo(struct addrinfo *res);
> -#define freeaddrinfo mingw_freeaddrinfo
> -
>  int mingw_getaddrinfo(const char *node, const char *service,
>  		      const struct addrinfo *hints, struct addrinfo **res);
>  #define getaddrinfo mingw_getaddrinfo
>
> -int mingw_getnameinfo(const struct sockaddr *sa, socklen_t salen,
> -		      char *host, DWORD hostlen, char *serv, DWORD servlen,
> -		      int flags);
> -#define getnameinfo mingw_getnameinfo
> -
>  int mingw_socket(int domain, int type, int protocol);
>  #define socket mingw_socket
>
> --
> gitgitgadget
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-04-29 22:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-27  8:43 [PATCH 0/1] Drop Windows XP-specific code to support IPv6 Johannes Schindelin via GitGitGadget
2019-02-27  8:43 ` [PATCH 1/1] mingw: remove obsolete IPv6-related code Tanushree Tumane via GitGitGadget
2019-04-29 22:58   ` Johannes Schindelin

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).