# HG changeset patch # User Simon Josefsson # Date 1285433325 -7200 # Node ID a35c1efcd66d62bbd26d39daa847c8a420688ab1 # Parent 03260cfd24e5f9266db2b4c26b393e6ac91dc311 getaddrinfo: Initialize sockets, to make it work under Windows. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-09-25 Simon Josefsson + + * modules/getaddrinfo (Depends-on): Depend on the sockets module. + * lib/getaddrinfo.c (use_win32_p): Call gl_sockets_startup to make + sure Windows sockets are working before calling getaddrinfo. + * tests/test-getaddrinfo.c (main): Don't call WSAStartup here. + * doc/gnulib.texi (Windows sockets): Fix typo. + 2010-09-25 Bruno Haible Tests for module 'regex-quote'. diff --git a/doc/gnulib.texi b/doc/gnulib.texi --- a/doc/gnulib.texi +++ b/doc/gnulib.texi @@ -989,7 +989,7 @@ Windows 2000 does not have getaddrinfo in its @file{WS2_32.DLL}. Thus, if you want to assume Windows XP or later, you can add -AC_DEFINE(WINVER, 0x0501) to avoid compiling to (partial) getaddrinfo +AC_DEFINE(WINVER, 0x0501) to avoid compiling the (partial) getaddrinfo implementation. If you want to support Windows 2000, don't do anything. The diff --git a/lib/getaddrinfo.c b/lib/getaddrinfo.c --- a/lib/getaddrinfo.c +++ b/lib/getaddrinfo.c @@ -59,6 +59,9 @@ # define WIN32_NATIVE #endif +/* gl_sockets_startup */ +#include "sockets.h" + #ifdef WIN32_NATIVE typedef int (WSAAPI *getaddrinfo_func) (const char*, const char*, const struct addrinfo*, @@ -101,6 +104,8 @@ return 0; } + gl_sockets_startup (SOCKETS_1_1); + return 1; } #endif diff --git a/modules/getaddrinfo b/modules/getaddrinfo --- a/modules/getaddrinfo +++ b/modules/getaddrinfo @@ -17,6 +17,7 @@ strdup servent hostent +sockets configure.ac: gl_GETADDRINFO diff --git a/tests/test-getaddrinfo.c b/tests/test-getaddrinfo.c --- a/tests/test-getaddrinfo.c +++ b/tests/test-getaddrinfo.c @@ -161,25 +161,6 @@ int main (void) { -#if _WIN32 - { - WORD requested; - WSADATA data; - int err; - - requested = MAKEWORD (1, 1); - err = WSAStartup (requested, &data); - if (err != 0) - return 1; - - if (data.wVersion < requested) - { - WSACleanup (); - return 2; - } - } -#endif - return simple (HOST1, SERV1) + simple (HOST2, SERV2) + simple (HOST3, SERV3)