From: Paul Eggert Date: Fri, 25 Sep 2015 18:16:27 +0000 (-0700) Subject: sockets: MS Windows initalization fixes X-Git-Tag: v1.0~6945 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=f28235237df7ab45ff4a17e21891faa8f4ea8dcf;p=gnulib.git sockets: MS Windows initalization fixes Problem reported by Test User in: http://lists.gnu.org/archive/html/help-shishi/2015-09/msg00001.html * lib/sockets.h (SOCKETS_1_0, SOCKETS_2_0, SOCKETS_2_1): Correct the endianness. * lib/sockets.c (gl_sockets_startup): Return 2 on any version number mismatch, not just on <. Cleanup before any such failure. --- diff --git a/ChangeLog b/ChangeLog index b42d31aaeb..abce49aca2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2015-09-25 Paul Eggert + + sockets: MS Windows initalization fixes + Problem reported by Test User in: + http://lists.gnu.org/archive/html/help-shishi/2015-09/msg00001.html + * lib/sockets.h (SOCKETS_1_0, SOCKETS_2_0, SOCKETS_2_1): + Correct the endianness. + * lib/sockets.c (gl_sockets_startup): Return 2 on any version + number mismatch, not just on <. Cleanup before any such failure. + 2015-09-25 Mats Erik Andersson gc: fix detection of installed libgcrypt version diff --git a/lib/sockets.c b/lib/sockets.c index 0b60562c4c..e644ff12c9 100644 --- a/lib/sockets.c +++ b/lib/sockets.c @@ -121,8 +121,11 @@ gl_sockets_startup (int version _GL_UNUSED) if (err != 0) return 1; - if (data.wVersion < version) - return 2; + if (data.wVersion != version) + { + WSACleanup (); + return 2; + } if (initialized_sockets_version == 0) register_fd_hook (close_fd_maybe_socket, ioctl_fd_maybe_socket, diff --git a/lib/sockets.h b/lib/sockets.h index c863dfbef4..173d032443 100644 --- a/lib/sockets.h +++ b/lib/sockets.h @@ -20,11 +20,11 @@ #ifndef SOCKETS_H # define SOCKETS_H 1 -#define SOCKETS_1_0 0x100 /* don't use - does not work on Windows XP */ -#define SOCKETS_1_1 0x101 -#define SOCKETS_2_0 0x200 /* don't use - does not work on Windows XP */ -#define SOCKETS_2_1 0x201 -#define SOCKETS_2_2 0x202 +#define SOCKETS_1_0 0x0001 +#define SOCKETS_1_1 0x0101 +#define SOCKETS_2_0 0x0002 +#define SOCKETS_2_1 0x0102 +#define SOCKETS_2_2 0x0202 int gl_sockets_startup (int version) #if !WINDOWS_SOCKETS